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.wiki;
04:
05: import fitnesse.testutil.AbstractRegex;
06: import java.util.*;
07:
08: public class FixtureListBuilderTest extends AbstractRegex {
09: private FixtureListBuilder builder;
10:
11: private PageCrawler crawler;
12:
13: private WikiPage root;
14:
15: protected void setUp() throws Exception {
16: root = InMemoryPage.makeRoot("RooT");
17: crawler = root.getPageCrawler();
18: builder = new FixtureListBuilder();
19: }
20:
21: public void testGetFixtureNames() throws Exception {
22: WikiPagePath levelOnePath = PathParser.parse("LevelOne");
23: WikiPagePath levelTwoPath = PathParser.parse("LevelTwo");
24: WikiPagePath levelThreePath = PathParser.parse("LevelThree");
25: WikiPagePath fullPath = PathParser
26: .parse("LevelOne.LevelTwo.LevelThree");
27:
28: WikiPage level1 = crawler
29: .addPage(root, levelOnePath,
30: "!fixture Fixture.One\r\nNot.A.Fixture\r\n!fixture FixtureTwo");
31: WikiPage level2 = crawler.addPage(level1, levelTwoPath,
32: "!fixture FixtureThree");
33: crawler.addPage(level2, levelThreePath, "Level three");
34:
35: List fixtureNames = builder.getFixtureNames(crawler.getPage(
36: root, fullPath));
37: assertEquals(3, fixtureNames.size());
38: assertEquals("Fixture.One", fixtureNames.get(1));
39: assertEquals("FixtureTwo", fixtureNames.get(2));
40: assertEquals("FixtureThree", fixtureNames.get(0));
41: }
42:
43: public void testThatFixtureNamesAreGatherFromLinearInheritance()
44: throws Exception {
45: WikiPage parent = crawler.addPage(root, PathParser
46: .parse("ParenT"), "!fixture parent");
47: WikiPage child = crawler.addPage(parent, PathParser
48: .parse("ChilD"), "!fixture child");
49: List fixtureNames = builder.getFixtureNames(child);
50: assertEquals(2, fixtureNames.size());
51: assertTrue(fixtureNames.contains("parent"));
52: assertTrue(fixtureNames.contains("child"));
53: }
54: }
|