@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 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()); }
@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); }
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 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()); }
@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")); }
@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"); }