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.wiki.*;
06: import fitnesse.http.*;
07: import fitnesse.*;
08: import fitnesse.testutil.AbstractRegex;
09:
10: public class MergeResponderTest extends AbstractRegex {
11: private WikiPage source;
12:
13: private MockRequest request;
14:
15: public void setUp() throws Exception {
16: source = InMemoryPage.makeRoot("RooT");
17: source.getPageCrawler().addPage(source,
18: PathParser.parse("SimplePage"), "this is SimplePage");
19: request = new MockRequest();
20: request.setResource("SimplePage");
21: request.addInput(EditResponder.SAVE_ID, "");
22: request.addInput(EditResponder.CONTENT_INPUT_NAME,
23: "some new content");
24: }
25:
26: public void tearDown() throws Exception {
27: }
28:
29: public void testHtml() throws Exception {
30: Responder responder = new MergeResponder(request);
31: SimpleResponse response = (SimpleResponse) responder
32: .makeResponse(new FitNesseContext(source),
33: new MockRequest());
34: assertHasRegexp("name=\\\"" + EditResponder.CONTENT_INPUT_NAME
35: + "\\\"", response.getContent());
36: assertHasRegexp("this is SimplePage", response.getContent());
37: assertHasRegexp("name=\\\"oldContent\\\"", response
38: .getContent());
39: assertHasRegexp("some new content", response.getContent());
40: }
41:
42: public void testAttributeValues() throws Exception {
43: request.addInput(WikiPage.ACTION_EDIT, "On");
44: request.addInput(WikiPage.ACTION_TEST, "On");
45: request.addInput(WikiPage.ACTION_SEARCH, "On");
46: Responder responder = new MergeResponder(request);
47: SimpleResponse response = (SimpleResponse) responder
48: .makeResponse(new FitNesseContext(source),
49: new MockRequest());
50:
51: assertHasRegexp("type=\"hidden\"", response.getContent());
52: assertHasRegexp("name=\"" + WikiPage.ACTION_EDIT + "\"",
53: response.getContent());
54: assertHasRegexp("name=\"" + WikiPage.ACTION_TEST + "\"",
55: response.getContent());
56: assertHasRegexp("name=\"" + WikiPage.ACTION_SEARCH + "\"",
57: response.getContent());
58: }
59: }
|