StrutsTestCase中setContextDirectory的问题
package configapp.app1;
import servletunit.struts.MockStrutsTestCase;
import java.io.File;
public class TestApp1Action extends MockStrutsTestCase{
public TestApp1Action() {
}
public void setUp() throws Exception {
super.setUp();
}
public void testSuccessfulLogin() {
setContextDirectory(new File("C:\\Documents and Settings\\YJT1\\jbproject\\configapp\\newweb"));
this.setServletConfigFile("C:\\Documents and Settings\\YJT1\\jbproject\\configapp\\newweb\\WEB-INF\\web.xml");
this.addRequestParameter("username1","liuming");
this.addRequestParameter("password1","wudi");
setRequestPathInfo("/app1/app1Action");
actionPerform();
this.verifyNoActionErrors();
verifyForward("showresult");
}
public void testNullInfoLogin() {
setContextDirectory(new File("C:\\Documents and Settings\\YJT1\\jbproject\\configapp\\newweb"));
this.setServletConfigFile("C:\\Documents and Settings\\YJT1\\jbproject\\configapp\\newweb\\WEB-INF\\web.xml");
this.addRequestParameter("username1","");
this.addRequestParameter("password1","");
setRequestPathInfo("/app1/app1Action");
actionPerform();
this.verifyActionErrors(new String[]{"error.username.required","error.password.required"});
this.verifyInputForward();
}
}
这个测试可以执行并且正确,但是如何把相对路径改称绝对路径.在WEB程序运行的时候可以很轻易的通过WEB.xml获得相对路径,但通过ANT整体测试的时候web程序并没有运行,如何获得相对路径?