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.editing;
04:
05: import fitnesse.FitNesseContext;
06: import fitnesse.Responder;
07: import fitnesse.http.MockRequest;
08: import fitnesse.http.Response;
09: import fitnesse.responders.refactoring.NewStiqPageResponder;
10: import fitnesse.testutil.AbstractRegex;
11: import fitnesse.wiki.InMemoryPage;
12: import fitnesse.wiki.PageCrawler;
13: import fitnesse.wiki.PathParser;
14: import fitnesse.wiki.WikiPage;
15: import fitnesse.wiki.WikiPagePath;
16:
17: public class CreateStiqPageResponderTest extends AbstractRegex {
18: private WikiPage root;
19:
20: public MockRequest request;
21:
22: public Responder responder;
23:
24: private PageCrawler crawler;
25:
26: public void setUp() throws Exception {
27: root = InMemoryPage.makeRoot("RooT");
28: crawler = root.getPageCrawler();
29: request = new MockRequest();
30: responder = new CreateStiqPageResponder();
31:
32: crawler.addPage(root, PathParser.parse("ChildPage"));
33: request.setResource("ChildPage");
34: request.addInput(
35: NewStiqPageResponder.STIQ_PAGE_NAME_INPUT_NAME,
36: "NewStiqTest");
37: request.addInput(
38: NewStiqPageResponder.STIQ_PAGE_TYPE_SELECT_NAME,
39: NewStiqPageResponder.STIQ_PAGE_TYPE_TEST);
40: }
41:
42: public void testNewPageIsChildOfCreator() throws Exception {
43: Response response = responder.makeResponse(new FitNesseContext(
44: root), request);
45: assertNotNull(response);
46: WikiPage newStiqTest = crawler.getPage(root,
47: (WikiPagePath) PathParser
48: .parse("ChildPage.NewStiqTest"));
49: assertTrue(newStiqTest.getName() == "NewStiqTest");
50: }
51:
52: public void testResponseIsParent() throws Exception {
53: Response response = responder.makeResponse(new FitNesseContext(
54: root), request);
55: assertEquals(303, response.getStatus());
56: assertDoesntHaveRegexp("Location: ChildPage.NewStiqTest",
57: response.makeHttpHeaders());
58: assertHasRegexp("Location: ChildPage", response
59: .makeHttpHeaders());
60:
61: }
62: }
|