1 17 18 package servletunit.struts.tests; 19 20 import servletunit.struts.MockStrutsTestCase; 21 22 import java.io.File ; 23 24 28 29 public class TestMockStrutsTestCase extends MockStrutsTestCase { 30 31 public TestMockStrutsTestCase(String testCase) { 32 super(testCase); 33 } 34 35 public void setUp() throws Exception { 36 super.setUp(); 37 setServletConfigFile("/WEB-INF/web.xml"); 38 } 39 40 public void testSetInitParameter() throws Exception { 41 setInitParameter("testName", "testValue"); 42 assertEquals("testValue", getActionServlet().getInitParameter("testName")); 43 } 44 45 public void testSetContextDirectory() { 46 File file = new File (System.getProperty("basedir")); 47 setContextDirectory(file); 48 assertEquals(new File (file,"test.html").getAbsolutePath(),getRequest().getRealPath("/test.html")); 49 } 50 51 public void testGetRealPathNotSet() { 52 assertNull(getRequest().getRealPath("/test.html")); 53 } 54 55 } 56 | Popular Tags |