public void testChildPageAdded() throws Exception { importer.enterChildPage(pageOne, Clock.currentDate()); importer.enterChildPage(childPageOne, Clock.currentDate()); PageData data = childPageOne.getData(); assertEquals("child one", data.getContent()); }
public void testAutoUpdate_NewPage() throws Exception { importer.setAutoUpdateSetting(true); importer.enterChildPage(pageOne, Clock.currentDate()); WikiImportProperty importProps = WikiImportProperty.createFrom(pageOne.getData().getProperties()); assertTrue(importProps.isAutoUpdate()); }
public void testContextIsNotOrphanWhenUpdatingNonRoot() throws Exception { addLocalPageWithImportProperty(localRoot, "PageOne", false); importer.parseUrl("http://localhost:" + FitNesseUtil.port + "/PageOne"); importer.importWiki(localRoot.getChildPage("PageOne")); assertEquals(0, importer.getOrphans().size()); }
public void testWholeTreeOrphaned() throws Exception { importer.importWiki(localRoot); remoteRoot.removeChildPage("PageOne"); importer.importWiki(localRoot); assertFalse(localRoot.hasChildPage("PageOne")); }
private void createResponder() throws Exception { WikiImporter importer = new WikiImporter(); importer.setDeleteOrphanOption(false); responder = new WikiImportingResponder(importer); responder.path = new WikiPagePath(); ChunkedResponse response = new ChunkedResponse("html", new MockChunkedDataProvider()); response.sendTo(new MockResponseSender()); responder.setResponse(response); }
public void testExiting() throws Exception { importer.enterChildPage(pageOne, Clock.currentDate()); importer.enterChildPage(childPageOne, Clock.currentDate()); importer.exitPage(); importer.exitPage(); importer.enterChildPage(pageTwo, Clock.currentDate()); PageData data = pageTwo.getData(); assertEquals("page two", data.getContent()); }
public void testEnterChildPageWhenRemotePageNotModified() throws Exception { importer.enterChildPage(pageOne, Clock.currentDate()); importer.exitPage(); PageData data = pageOne.getData(); data.setContent("new content"); pageOne.commit(data); importer.enterChildPage(pageOne, new Date(0)); assertEquals("new content", pageOne.getData().getContent()); }
public void setUp() throws Exception { createRemoteRoot(); createLocalRoot(); FitNesseUtil.startFitnesse(remoteRoot); importer = new WikiImporter(); importer.setWikiImporterClient(this); importer.parseUrl("http://localhost:" + FitNesseUtil.port); imports = new LinkedList<WikiPage>(); errors = new LinkedList<Exception>(); }
public void testAutoUpdateWhenRemotePageNotModified() throws Exception { importer.enterChildPage(pageOne, Clock.currentDate()); importer.exitPage(); PageData data = pageOne.getData(); data.setContent("new content"); pageOne.commit(data); importer.setAutoUpdateSetting(true); importer.enterChildPage(pageOne, new Date(0)); WikiImportProperty importProps = WikiImportProperty.createFrom(pageOne.getData().getProperties()); assertTrue(importProps.isAutoUpdate()); }
public void testImportingWiki() throws Exception { localRoot = InMemoryPage.makeRoot("LocalRoot"); importer.importWiki(localRoot); assertEquals(2, localRoot.getChildren().size()); assertEquals(3, imports.size()); assertEquals(0, errors.size()); }
public void testParsingBadUrl() throws Exception { try { importer.parseUrl("blah"); fail("should have exception"); } catch (Exception e) { assertEquals("blah is not a valid URL.", e.getMessage()); } }
public void testAutoUpdatePropertySetOnRoot() throws Exception { addLocalPageWithImportProperty(localRoot, "PageOne", false); importer.parseUrl("http://localhost:" + FitNesseUtil.port + "/PageOne"); importer.setAutoUpdateSetting(true); WikiPage importedPage = localRoot.getChildPage("PageOne"); importer.importWiki(importedPage); WikiImportProperty importProp = WikiImportProperty.createFrom(importedPage.getData().getProperties()); assertTrue(importProp.isAutoUpdate()); importer.setAutoUpdateSetting(false); importer.importWiki(importedPage); importProp = WikiImportProperty.createFrom(importedPage.getData().getProperties()); assertFalse(importProp.isAutoUpdate()); }
public void testGetPageTree() throws Exception { Document doc = importer.getPageTree(); assertNotNull(doc); String xml = XmlUtil.xmlAsString(doc); assertSubString("PageOne", xml); assertSubString("PageTwo", xml); }
public void testParsingUrlWithNonWikiWord() throws Exception { try { importer.parseUrl("http://blah.com/notawikiword"); fail("should throw exception"); } catch (Exception e) { assertEquals( "The URL's resource path, notawikiword, is not a valid WikiWord.", e.getMessage()); } }
private void performImportWithExtraLocalPages() throws Exception { addLocalPageWithImportProperty(localRoot, "PageThree", false); addLocalPageWithImportProperty(pageOne, "ChildTwo", false); addLocalPageWithImportProperty(childPageOne, "GrandChildOne", false); localRoot.addChildPage("PageThatDoesntImport"); addLocalPageWithImportProperty(localRoot, "OtherImportRoot", true); importer.importWiki(localRoot); }
public void testFindsOrphansOnLocalWiki() throws Exception { performImportWithExtraLocalPages(); List<WikiPagePath> orphans = importer.getOrphans(); assertEquals(3, orphans.size()); assertTrue(orphans.contains(new WikiPagePath().addNameToEnd("PageThree"))); assertTrue( orphans.contains(new WikiPagePath().addNameToEnd("PageOne").addNameToEnd("ChildTwo"))); assertTrue( orphans.contains( new WikiPagePath() .addNameToEnd("PageOne") .addNameToEnd("ChildOne") .addNameToEnd("GrandChildOne"))); assertFalse(orphans.contains(new WikiPagePath().addNameToEnd("PageThatDoesntImport"))); assertFalse(orphans.contains(new WikiPagePath().addNameToEnd("OtherImportRoot"))); }
public void run(TestResponder testResponder, PageData data) throws Exception { this.testResponder = testResponder; this.data = data; importProperty = WikiImportProperty.createFrom(data.getProperties()); if (importProperty != null && importProperty.isAutoUpdate()) { testResponder.addToResponse("<span class=\"meta\">Updating imported content...</span>"); testResponder.addToResponse("<span class=\"meta\">"); try { wikiImporter = importerFactory.newImporter(this); wikiImporter.parseUrl(importProperty.getSourceUrl()); wikiPage = data.getWikiPage(); doUpdating(); if (!errorOccured) testResponder.addToResponse("done"); } catch (Exception e) { pageImportError(data.getWikiPage(), e); } testResponder.addToResponse("</span>"); } }
protected void updatePagePassedIn() throws Exception { wikiImporter.importRemotePageContent(wikiPage); data.setContent(wikiPage.getData().getContent()); }
private void testUrlParsing(String url, String host, int port, String path) throws Exception { importer.parseUrl(url); assertEquals(host, importer.getRemoteHostname()); assertEquals(port, importer.getRemotePort()); assertEquals(path, PathParser.render(importer.getRemotePath())); }