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.fixtures;
04:
05: import junit.framework.TestCase;
06: import fitnesse.wiki.*;
07:
08: public class PageCreatorTest extends TestCase {
09: protected void setUp() throws Exception {
10: FitnesseFixtureContext.root = InMemoryPage.makeRoot("root");
11: }
12:
13: public void testCreatePage() throws Exception {
14: WikiPage testPage = makePage("TestPage", "contents", "attr=val");
15: assertNotNull(testPage);
16: PageData data = testPage.getData();
17: assertEquals("contents", data.getContent());
18: assertEquals("val", data.getAttribute("attr"));
19: }
20:
21: private WikiPage makePage(String pageName, String pageContent,
22: String pageAttributes) throws Exception {
23: PageCreator creator = new PageCreator();
24: creator.pageName = pageName;
25: creator.pageContents = pageContent;
26: creator.pageAttributes = pageAttributes;
27: assertTrue(creator.valid());
28: WikiPage testPage = FitnesseFixtureContext.root
29: .getChildPage("TestPage");
30: return testPage;
31: }
32:
33: public void testMultipleAttributes() throws Exception {
34: WikiPage testPage = makePage("TestPage", "Contents",
35: "att1=one,att2=two");
36: PageData data = testPage.getData();
37: assertEquals("one", data.getAttribute("att1"));
38: assertEquals("two", data.getAttribute("att2"));
39: }
40: }
|