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 junit.framework.*;
06: import junit.swingui.TestRunner;
07: import fitnesse.wiki.*;
08: import fitnesse.http.*;
09: import fitnesse.*;
10:
11: public class RollbackResponderTest extends TestCase {
12: private WikiPage root;
13:
14: private WikiPage page;
15:
16: private Response response;
17:
18: public static void main(String[] args) {
19: TestRunner.main(new String[] { "RollbackResponderTest" });
20: }
21:
22: public void setUp() throws Exception {
23: root = InMemoryPage.makeRoot("RooT");
24: page = root.getPageCrawler().addPage(root,
25: PathParser.parse("PageOne"), "original content");
26: PageData data = page.getData();
27: data.setContent("new stuff");
28: data.setProperties(new WikiPageProperties());
29: VersionInfo commitRecord = page.commit(data);
30:
31: MockRequest request = new MockRequest();
32: request.setResource("PageOne");
33: request.addInput("version", commitRecord.getName());
34:
35: Responder responder = new RollbackResponder();
36: response = responder.makeResponse(new FitNesseContext(root),
37: request);
38: }
39:
40: public void tearDown() throws Exception {
41: }
42:
43: public void testStuff() throws Exception {
44: assertEquals(303, response.getStatus());
45: assertEquals("PageOne", response.getHeader("Location"));
46:
47: PageData data = page.getData();
48: assertEquals("original content", data.getContent());
49: assertEquals(true, data.hasAttribute(WikiPage.ACTION_EDIT));
50: }
51: }
|