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.wiki.*;
07: import fitnesse.testutil.AbstractRegex;
08: import fitnesse.http.*;
09: import junit.swingui.TestRunner;
10:
11: public class NotFoundResponderTest extends AbstractRegex {
12: public static void main(String[] args) {
13: TestRunner.main(new String[] { "NotFoundResponderTest" });
14: }
15:
16: public void setUp() throws Exception {
17: }
18:
19: public void tearDown() throws Exception {
20: }
21:
22: public void testResponse() throws Exception {
23: MockRequest request = new MockRequest();
24: request.setResource("some page");
25:
26: Responder responder = new NotFoundResponder();
27: SimpleResponse response = (SimpleResponse) responder
28: .makeResponse(new FitNesseContext(), request);
29:
30: assertEquals(404, response.getStatus());
31:
32: String body = response.getContent();
33:
34: assertHasRegexp("<html>", body);
35: assertHasRegexp("<body", body);
36: assertHasRegexp("some page", body);
37: assertHasRegexp("Not Found", body);
38: }
39:
40: public void testHasEditLinkForWikiWords() throws Exception {
41: MockRequest request = new MockRequest();
42: request.setResource("PageOne.PageTwo");
43: WikiPage root = InMemoryPage.makeRoot("RooT");
44:
45: Responder responder = new NotFoundResponder();
46: SimpleResponse response = (SimpleResponse) responder
47: .makeResponse(new FitNesseContext(root), request);
48:
49: assertHasRegexp("href=\"PageOne[.]PageTwo[?]edit\"", response
50: .getContent());
51: }
52:
53: }
|