@Test public void testPagesForTestSystemAreSurroundedBySuiteSetupAndTeardown() throws Exception { WikiPage slimPage = addTestPage(suite, "AaSlimTest", simpleSlimDecisionTable); WikiPage setUp = crawler.addPage(root, PathParser.parse("SuiteSetUp"), "suite set up"); WikiPage tearDown = crawler.addPage(root, PathParser.parse("SuiteTearDown"), "suite tear down"); testPages = new LinkedList<WikiPage>(); testPages.add(setUp); testPages.add(slimPage); testPages.add(testPage); testPages.add(tearDown); MultipleTestsRunner runner = new MultipleTestsRunner(testPages, context, suite, null); Map<TestSystem.Descriptor, LinkedList<TestPage>> map = runner.makeMapOfPagesByTestSystem(); TestSystem.Descriptor fitDescriptor = TestSystem.getDescriptor(testPage.getData(), context.pageFactory, false); TestSystem.Descriptor slimDescriptor = TestSystem.getDescriptor(slimPage.getData(), context.pageFactory, false); List<TestPage> fitList = map.get(fitDescriptor); List<TestPage> slimList = map.get(slimDescriptor); assertEquals(3, fitList.size()); assertEquals(3, slimList.size()); assertEquals(setUp, fitList.get(0).getSourcePage()); assertEquals(testPage, fitList.get(1).getSourcePage()); assertEquals(tearDown, fitList.get(2).getSourcePage()); assertEquals(setUp, slimList.get(0).getSourcePage()); assertEquals(slimPage, slimList.get(1).getSourcePage()); assertEquals(tearDown, slimList.get(2).getSourcePage()); }
@Test public void testDefaultAttributes() throws Exception { WikiPage page = crawler.addPage(root, PathParser.parse("PageOne"), "something"); assertTrue(page.getData().hasAttribute("Edit")); assertTrue(page.getData().hasAttribute("Search")); assertFalse(page.getData().hasAttribute("Test")); assertFalse(page.getData().hasAttribute("TestSuite")); }
@Test public void testLastModifiedTime() throws Exception { WikiPage page = crawler.addPage(root, PathParser.parse("SomePage"), "some text"); page.commit(page.getData()); long now = Clock.currentTimeInMillis(); Date lastModified = page.getData().getProperties().getLastModificationTime(); assertTrue(now - lastModified.getTime() <= 5000); }
@Test public void testDelTree() throws Exception { WikiPage levelOne = crawler.addPage(root, PathParser.parse("LevelOne")); WikiPage levelTwo = crawler.addPage(levelOne, PathParser.parse("LevelTwo")); levelOne.commit(levelOne.getData()); levelTwo.commit(levelTwo.getData()); File childOne = new File(defaultPath + "/RooT/LevelOne"); File childTwo = new File(defaultPath + "/RooT/LevelOne/LevelTwo"); assertTrue(childOne.exists()); root.removeChildPage("LevelOne"); assertFalse(childTwo.exists()); assertFalse(childOne.exists()); }
@Test public void testPersistentAttributes() throws Exception { WikiPage createdPage = crawler.addPage(root, PathParser.parse("FrontPage")); PageData data = createdPage.getData(); data.setAttribute("Test", "true"); data.setAttribute("Search", "true"); createdPage.commit(data); assertTrue(data.hasAttribute("Test")); assertTrue(data.hasAttribute("Search")); WikiPage page = root.getChildPage("FrontPage"); assertTrue(page.getData().hasAttribute("Test")); assertTrue(page.getData().hasAttribute("Search")); }
@Test public void testDefaultAttributesForSuitePageNames() throws Exception { WikiPage suitePage3 = WikiPageUtil.addPage(root, PathParser.parse("TestPageSuite")); PageData data = suitePage3.getData(); assertFalse(data.hasAttribute(TEST.toString())); assertTrue(data.hasAttribute(SUITE.toString())); }
@Test public void testThatTestAtEndOfNameSetsTestProperty() throws Exception { WikiPage testPage2 = WikiPageUtil.addPage(root, PathParser.parse("PageTest")); PageData data = testPage2.getData(); assertTrue(data.hasAttribute(TEST.toString())); assertFalse(data.hasAttribute(SUITE.toString())); }
@Test public void testThatSuiteAtBeginningOfNameSetsSuiteProperty() throws Exception { WikiPage suitePage1 = WikiPageUtil.addPage(root, PathParser.parse("SuitePage")); PageData data = suitePage1.getData(); assertFalse(data.hasAttribute(TEST.toString())); assertTrue(data.hasAttribute(SUITE.toString())); }
@Test public void testUnicodeCharacters() throws Exception { WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("SomePage"), "\uba80\uba81\uba82\uba83"); PageData data = page.getData(); assertEquals("\uba80\uba81\uba82\uba83", data.getContent()); }
@Test public void testTwoLevel() throws Exception { WikiPage levelA = crawler.addPage(root, PathParser.parse("PageA")); WikiPage page = crawler.addPage(levelA, PathParser.parse("PageB")); page.commit(page.getData()); assertTrue(new File(defaultPath + "/RooT/PageA/PageB").exists()); }
private WikiPage addTestPage(WikiPage page, String name, String content) throws Exception { WikiPage testPage = crawler.addPage(page, PathParser.parse(name), content); PageData data = testPage.getData(); data.setAttribute("Test"); testPage.commit(data); testPages.add(testPage); return testPage; }
@Test public void testGenerateSuiteMapWithMultipleTestSystems() throws Exception { WikiPage slimPage = addTestPage(suite, "SlimTest", simpleSlimDecisionTable); MultipleTestsRunner runner = new MultipleTestsRunner(testPages, context, suite, null); Map<TestSystem.Descriptor, LinkedList<TestPage>> map = runner.makeMapOfPagesByTestSystem(); TestSystem.Descriptor fitDescriptor = TestSystem.getDescriptor(testPage.getData(), context.pageFactory, false); TestSystem.Descriptor slimDescriptor = TestSystem.getDescriptor(slimPage.getData(), context.pageFactory, false); List<TestPage> fitList = map.get(fitDescriptor); List<TestPage> slimList = map.get(slimDescriptor); assertEquals(1, fitList.size()); assertEquals(1, slimList.size()); assertEquals(testPage, fitList.get(0).getSourcePage()); assertEquals(slimPage, slimList.get(0).getSourcePage()); }
@Test public void testDefaultAttributesForNormalPageNames() throws Exception { WikiPage normalPage = WikiPageUtil.addPage(root, PathParser.parse("NormalPage")); PageData data = normalPage.getData(); assertTrue(data.hasAttribute(PropertyEDIT)); assertTrue(data.hasAttribute(PropertySEARCH)); assertTrue(data.hasAttribute(PropertyVERSIONS)); assertTrue(data.hasAttribute(PropertyFILES)); assertFalse(data.hasAttribute(TEST.toString())); assertFalse(data.hasAttribute(SUITE.toString())); }
@Test public void testRemovePage() throws Exception { WikiPage levelOne = WikiPageUtil.addPage(root, PathParser.parse("LevelOne")); levelOne.commit(levelOne.getData()); WikiPageUtil.addPage(levelOne, PathParser.parse("LevelTwo")); levelOne.removeChildPage("LevelTwo"); File fileOne = new File(defaultPath + "/RooT/LevelOne"); File fileTwo = new File(defaultPath + "/RooT/LevelOne/LevelTwo"); assertTrue(fileOne.exists()); assertFalse(fileTwo.exists()); }
@Before public void setUp() throws Exception { suitePageName = "SuitePage"; root = InMemoryPage.makeRoot("RooT"); context = FitNesseUtil.makeTestContext(root); crawler = root.getPageCrawler(); PageData data = root.getData(); data.setContent(classpathWidgets()); root.commit(data); suite = crawler.addPage(root, PathParser.parse(suitePageName), "This is the test suite\n"); testPages = new LinkedList<WikiPage>(); testPage = addTestPage(suite, "TestOne", "My test"); }
@Test public void testThatExampleAtEndOfNameSetsTestProperty() throws Exception { WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("PageExample")); PageData data = page.getData(); assertTrue(data.hasAttribute(TEST.toString())); }
@Test public void testDefaultAttributesForSuiteTearDownPageNames() throws Exception { WikiPage suiteTearDownPage = WikiPageUtil.addPage(root, PathParser.parse(SUITE_TEARDOWN_NAME)); PageData data = suiteTearDownPage.getData(); assertFalse(data.hasAttribute(SUITE.toString())); }