01: package servletunit.struts.tests;
02:
03: import servletunit.struts.MockStrutsTestCase;
04: import servletunit.HttpServletResponseSimulator;
05: import junit.framework.AssertionFailedError;
06:
07: /**
08: * Created by IntelliJ IDEA.
09: * User: deryl
10: * Date: May 20, 2003
11: * Time: 5:16:57 PM
12: * To change this template use Options | File Templates.
13: */
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())
31: .getStatusCode();
32: // todo: backwards compatible with struts 1.1
33: assertTrue("unexpected response code", statusCode == 404
34: || statusCode == 400);
35: return;
36: }
37: fail("expected some error code!");
38:
39: }
40:
41: }
|