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.versions;
04:
05: import fitnesse.testutil.AbstractRegex;
06: import fitnesse.wiki.*;
07: import fitnesse.http.*;
08: import fitnesse.*;
09:
10: public class VersionResponderTest extends AbstractRegex {
11: private String oldVersion;
12:
13: private SimpleResponse response;
14:
15: private WikiPage root;
16:
17: private WikiPage page;
18:
19: private void makeTestResponse(String pageName) throws Exception {
20: root = InMemoryPage.makeRoot("RooT");
21: page = root.getPageCrawler().addPage(root,
22: PathParser.parse(pageName), "original content");
23: PageData data = page.getData();
24: data.setContent("new stuff");
25: VersionInfo commitRecord = page.commit(data);
26: oldVersion = commitRecord.getName();
27:
28: MockRequest request = new MockRequest();
29: request.setResource(pageName);
30: request.addInput("version", oldVersion);
31:
32: Responder responder = new VersionResponder();
33: response = (SimpleResponse) responder.makeResponse(
34: new FitNesseContext(root), request);
35: }
36:
37: public void testVersionName() throws Exception {
38: makeTestResponse("PageOne");
39:
40: assertHasRegexp("original content", response.getContent());
41: assertDoesntHaveRegexp("new stuff", response.getContent());
42: assertHasRegexp(oldVersion, response.getContent());
43: }
44:
45: public void testButtons() throws Exception {
46: makeTestResponse("PageOne");
47:
48: assertDoesntHaveRegexp("Edit button", response.getContent());
49: assertDoesntHaveRegexp("Search button", response.getContent());
50: assertDoesntHaveRegexp("Test button", response.getContent());
51: assertDoesntHaveRegexp("Suite button", response.getContent());
52: assertDoesntHaveRegexp("Versions button", response.getContent());
53:
54: assertHasRegexp("Rollback button", response.getContent());
55: }
56:
57: public void testNameNoAtRootLevel() throws Exception {
58: makeTestResponse("PageOne.PageTwo");
59: assertSubString("PageOne.PageTwo?responder=", response
60: .getContent());
61: }
62: }
|