01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.responders;
04:
05: import fitnesse.*;
06: import fitnesse.testutil.RegexTest;
07: import fitnesse.http.*;
08:
09: public class ErrorResponderTest extends RegexTest {
10: public void testResponse() throws Exception {
11: Responder responder = new ErrorResponder(new Exception(
12: "some error message"));
13: SimpleResponse response = (SimpleResponse) responder
14: .makeResponse(new FitNesseContext(), new MockRequest());
15:
16: assertEquals(400, response.getStatus());
17:
18: String body = response.getContent();
19:
20: assertHasRegexp("<html>", body);
21: assertHasRegexp("<body", body);
22: assertHasRegexp("java.lang.Exception: some error message", body);
23: }
24:
25: public void testWithMessage() throws Exception {
26: Responder responder = new ErrorResponder("error Message");
27: SimpleResponse response = (SimpleResponse) responder
28: .makeResponse(new FitNesseContext(), new MockRequest());
29: String body = response.getContent();
30:
31: assertSubString("error Message", body);
32: }
33: }
|