Exemplo n.º 1
0
 public void testHtmlOnSubPage() throws Exception {
   crawler.addPage(root, PathParser.parse("ParenT"), "Content");
   WikiPage parent = root.getChildPage("ParenT");
   crawler.addPage(parent, PathParser.parse("ChilD"), "ChilD");
   crawler.addPage(parent, PathParser.parse("ChildTwo"), "ChildTwo");
   WikiPage child = parent.getChildPage("ChilD");
   ParentWidget parentWidget =
       new WidgetRoot(new PagePointer(root, PathParser.parse("ParenT.ChilD")));
   AliasLinkWidget w = new AliasLinkWidget(parentWidget, "[[tag][ChildTwo]]");
   assertEquals("<a href=\"ParenT.ChildTwo\">tag</a>", w.render());
   AliasLinkWidget w2 = new AliasLinkWidget(new WidgetRoot(child), "[[tag][.ParenT]]");
   assertEquals("<a href=\"ParenT\">tag</a>", w2.render());
 }
  @Test
  public void testRemoval() throws Exception {
    PageData data = pageOne.getData();
    WikiPageProperty symLinks = data.getProperties().set(SymbolicPage.PROPERTY_NAME);
    symLinks.set("SymLink", "PageTwo");
    pageOne.commit(data);
    assertNotNull(pageOne.getChildPage("SymLink"));

    request.addInput("removal", "SymLink");
    Response response = invokeResponder();
    checkPageOneRedirectToProperties(response);

    assertNull(pageOne.getChildPage("SymLink"));
  }
Exemplo n.º 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());
  }
Exemplo n.º 4
0
 @Test
 public void testCanFindExistingPages() throws Exception {
   WikiPageUtil.addPage(root, PathParser.parse("FrontPage"), "front page");
   WikiPage newRoot =
       new FileSystemPageFactory()
           .makePage(new File(base, "RooT"), "RooT", null, new SystemVariableSource());
   assertNotNull(newRoot.getChildPage("FrontPage"));
 }
  private void prepareSymlinkOnPageOne() {
    PageData data = pageOne.getData();
    WikiPageProperty symLinks = data.getProperties().set(SymbolicPage.PROPERTY_NAME);
    symLinks.set("SymLink", "PageTwo");
    pageOne.commit(data);
    assertNotNull(pageOne.getChildPage("SymLink"));

    request.addInput("rename", "SymLink");
  }
  @Test
  public void testRename() throws Exception {
    prepareSymlinkOnPageOne();
    request.addInput("newname", "NewLink");
    Response response = invokeResponder();
    checkPageOneRedirectToProperties(response);

    assertNotNull(pageOne.getChildPage("NewLink"));
  }
  private void executeSymbolicLinkTestWith(String linkName, String linkPath) throws Exception {
    request.addInput("linkName", linkName);
    request.addInput("linkPath", linkPath);
    Response response = invokeResponder();

    checkPageOneRedirectToProperties(response);

    WikiPage symLink = pageOne.getChildPage("SymLink");
    assertNotNull(symLink);
    assertEquals(SymbolicPage.class, symLink.getClass());
  }
  @Test
  public void testSubmitGoodFormToSibling() throws Exception {
    request.addInput("linkName", "SymTwo");
    request.addInput("linkPath", "PageTwo");
    Response response = invokeResponder();

    checkPageOneRedirectToProperties(response);

    WikiPage symLink = pageOne.getChildPage("SymTwo");
    assertNotNull(symLink);
    assertEquals(SymbolicPage.class, symLink.getClass());
  }
  @Test
  public void testSubmitGoodFormToBackwardRelative() throws Exception {
    request.setResource("PageTwo.ChildTwo");
    request.addInput("linkName", "SymLink");
    request.addInput("linkPath", "<PageTwo.ChildThree");
    Response response = invokeResponder();

    checkChildTwoRedirectToProperties(response);

    WikiPage symLink = childTwo.getChildPage("SymLink");
    assertNotNull(symLink);
    assertEquals(SymbolicPage.class, symLink.getClass());
  }
Exemplo n.º 10
0
  private String doRunAndGetErrorLog(String content) throws Exception {
    WikiPage testPage = crawler.addPage(root, PathParser.parse("TestPage"), content);
    request.setResource(testPage.getName());

    Response response = responder.makeResponse(context, request);
    MockResponseSender sender = new MockResponseSender();
    sender.doSending(response);
    String results = sender.sentData();

    assertHasRegexp("ErrorLog", results);

    WikiPage errorLog = errorLogsParentPage.getChildPage(testPage.getName());
    return errorLog.getData().getContent();
  }
  @Test
  public void testReplaceAllowedOnSymChild() throws Exception {
    request.addInput("linkName", "SymLink");
    request.addInput("linkPath", "PageTwo");
    Response response = invokeResponder();

    request.addInput("linkName", "SymLink");
    request.addInput("linkPath", ">ChildOne");
    response = invokeResponder();

    checkPageOneRedirectToProperties(response);

    WikiPage symLink = pageOne.getChildPage("SymLink");
    assertNotNull(symLink);
    assertEquals(SymbolicPage.class, symLink.getClass());
    assertTrue(symLink.getHtml().contains("ChildOne"));
  }
Exemplo n.º 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());
  }
  @Test
  public void testSubmitFormForLinkToExternalRoot() throws Exception {
    // Ise canonical names, since that's how they will be resolved.
    fileSystem.makeDirectory(new File("/somedir"));
    fileSystem.makeDirectory(new File("/somedir/ExternalRoot"));

    request.addInput("linkName", "SymLink");
    request.addInput("linkPath", "file:/somedir/ExternalRoot");
    Response response = invokeResponder();

    checkPageOneRedirectToProperties(response);

    WikiPage symLink = pageOne.getChildPage("SymLink");
    assertNotNull(symLink);
    assertEquals(SymbolicPage.class, symLink.getClass());

    WikiPage realPage = ((SymbolicPage) symLink).getRealPage();
    assertEquals(WikiFilePage.class, realPage.getClass());
    assertEquals(
        new File("/somedir/ExternalRoot"), ((FileBasedWikiPage) realPage).getFileSystemPath());
  }
 private void reloadPages() {
   pageOne = root.getChildPage("PageOne");
   WikiPage pageTwo = root.addChildPage("PageTwo");
   childTwo = pageTwo.addChildPage("ChildTwo");
 }
Exemplo n.º 15
0
 @Test
 public void testCanFindExistingPages() throws Exception {
   crawler.addPage(root, PathParser.parse("FrontPage"), "front page");
   WikiPage newRoot = new FileSystemPage(defaultPath, "RooT");
   assertNotNull(newRoot.getChildPage("FrontPage"));
 }