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.search;
04:
05: import fitnesse.wiki.*;
06: import fitnesse.http.*;
07: import fitnesse.testutil.AbstractRegex;
08: import fitnesse.FitNesseContext;
09:
10: public class WhereUsedResponderTest extends AbstractRegex {
11: private WikiPage root;
12:
13: private WikiPage pageTwo;
14:
15: public void setUp() throws Exception {
16: root = InMemoryPage.makeRoot("RooT");
17: PageCrawler crawler = root.getPageCrawler();
18: crawler.addPage(root, PathParser.parse("PageOne"), "PageOne");
19: pageTwo = crawler.addPage(root, PathParser.parse("PageTwo"),
20: "PageOne");
21: crawler.addPage(pageTwo, PathParser.parse("ChildPage"),
22: ".PageOne");
23: }
24:
25: public void testResponse() throws Exception {
26: MockRequest request = new MockRequest();
27: request.setResource("PageOne");
28: WhereUsedResponder responder = new WhereUsedResponder();
29:
30: Response response = responder.makeResponse(new FitNesseContext(
31: root), request);
32: MockResponseSender sender = new MockResponseSender();
33: response.readyToSend(sender);
34: sender.waitForClose(5000);
35:
36: String content = sender.sentData();
37: assertEquals(200, response.getStatus());
38: assertHasRegexp("Where Used", content);
39: assertHasRegexp(">PageOne<", content);
40: assertHasRegexp(">PageTwo<", content);
41: assertHasRegexp(">PageTwo\\.ChildPage<", content);
42: }
43: }
|