1 package servletunit.struts.tests; 2 3 import servletunit.struts.MockStrutsTestCase; 4 import servletunit.HttpServletResponseSimulator; 5 import junit.framework.AssertionFailedError; 6 7 14 public class TestResponseStatus extends MockStrutsTestCase { 15 16 public TestResponseStatus(String testName) { 17 super(testName); 18 } 19 20 public void setUp() throws Exception { 21 super.setUp(); 22 setServletConfigFile("/WEB-INF/web.xml"); 23 } 24 25 public void testResponseCode() { 26 setRequestPathInfo("/badActionPath"); 27 try { 28 actionPerform(); 29 } catch (AssertionFailedError afe) { 30 int statusCode = ((HttpServletResponseSimulator) getResponse()).getStatusCode(); 31 assertTrue("unexpected response code",statusCode == 404 || statusCode == 400); 33 return; 34 } 35 fail("expected some error code!"); 36 37 } 38 39 40 } 41 | Popular Tags |