예제 #1
0
  public void testChildPageAdded() throws Exception {
    importer.enterChildPage(pageOne, Clock.currentDate());
    importer.enterChildPage(childPageOne, Clock.currentDate());

    PageData data = childPageOne.getData();
    assertEquals("child one", data.getContent());
  }
예제 #2
0
  public void testAutoUpdate_NewPage() throws Exception {
    importer.setAutoUpdateSetting(true);
    importer.enterChildPage(pageOne, Clock.currentDate());

    WikiImportProperty importProps =
        WikiImportProperty.createFrom(pageOne.getData().getProperties());
    assertTrue(importProps.isAutoUpdate());
  }
예제 #3
0
  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());
  }
예제 #4
0
  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);
 }
예제 #6
0
  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());
  }
예제 #7
0
  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());
  }
예제 #8
0
  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>();
  }
예제 #9
0
  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());
  }
예제 #10
0
  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());
  }
예제 #11
0
 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());
   }
 }
예제 #12
0
  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());
  }
예제 #13
0
  public void testGetPageTree() throws Exception {
    Document doc = importer.getPageTree();
    assertNotNull(doc);
    String xml = XmlUtil.xmlAsString(doc);

    assertSubString("PageOne", xml);
    assertSubString("PageTwo", xml);
  }
예제 #14
0
 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());
   }
 }
예제 #15
0
  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);
  }
예제 #16
0
  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());
 }
예제 #19
0
 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()));
 }