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.FitNesseContext;
06: import fitnesse.Responder;
07: import fitnesse.http.MockRequest;
08: import fitnesse.http.SimpleResponse;
09: import fitnesse.testutil.AbstractRegex;
10:
11: public class ErrorResponderTest extends AbstractRegex {
12: public void testResponse() throws Exception {
13: Responder responder = new ErrorResponder(new Exception(
14: "some error message"));
15: SimpleResponse response = (SimpleResponse) responder
16: .makeResponse(new FitNesseContext(), new MockRequest());
17:
18: assertEquals(400, response.getStatus());
19:
20: String body = response.getContent();
21:
22: assertHasRegexp("<html>", body);
23: assertHasRegexp("<body", body);
24: assertHasRegexp("java.lang.Exception: some error message", body);
25: }
26:
27: public void testWithMessage() throws Exception {
28: Responder responder = new ErrorResponder("error Message");
29: SimpleResponse response = (SimpleResponse) responder
30: .makeResponse(new FitNesseContext(), new MockRequest());
31: String body = response.getContent();
32:
33: assertSubString("error Message", body);
34: }
35: }
|