Example #1
0
 public void testUparrowOnPageThatDoesNotExist() throws Exception {
   WikiPage page = crawler.addPage(root, PathParser.parse("FrontPage"));
   AliasLinkWidget w = new AliasLinkWidget(new WidgetRoot(page), "[[tag][^TestPage]]");
   assertEquals(
       "tag<a title=\"create page\" href=\"FrontPage.TestPage?edit&amp;nonExistent=true\">[?]</a>",
       w.render());
 }
Example #2
0
 public void testQuestionMarkDoesNotAppear() throws Exception {
   WikiPage page = crawler.addPage(root, PathParser.parse("FrontPage"));
   AliasLinkWidget w =
       new AliasLinkWidget(
           new WidgetRoot(page), "[[here][http://www.objectmentor.com/FitNesse/fitnesse.zip]]");
   assertDoesntHaveRegexp("[?]", w.render());
 }
Example #3
0
 public void testHtmlAtTopLevelPageWithAnchor() throws Exception {
   crawler.addPage(root, PathParser.parse("TestPage"));
   ParentWidget wroot = new WidgetRoot(new PagePointer(root, PathParser.parse("TestPage")));
   AliasLinkWidget w = new AliasLinkWidget(wroot, "[[tag][TestPage#anchor]]");
   String html = w.render();
   assertEquals("<a href=\"TestPage#anchor\">tag</a>", html);
 }
Example #4
0
 public void testUparrowOnPageThatDoesExist() throws Exception {
   WikiPage page = crawler.addPage(root, PathParser.parse("TestPage"));
   crawler.addPage(page, PathParser.parse("SubPage"));
   ParentWidget wroot = new WidgetRoot(page);
   AliasLinkWidget w = new AliasLinkWidget(wroot, "[[tag][^SubPage]]");
   String html = w.render();
   assertEquals("<a href=\"TestPage.SubPage\">tag</a>", html);
 }
Example #5
0
 public void testUsageOnRootPageDoesntCrash() throws Exception {
   AliasLinkWidget w = new AliasLinkWidget(new WidgetRoot(root), "[[here][PageOne]]");
   try {
     w.render();
   } catch (Exception e) {
     fail("should not throw Exception: " + e);
   }
 }
Example #6
0
 public void testHtmlForPageThatDoesNotExist() throws Exception {
   crawler.addPage(root, PathParser.parse("FrontPage"));
   ParentWidget parentWidget =
       new WidgetRoot(new PagePointer(root, PathParser.parse("FrontPage")));
   AliasLinkWidget w = new AliasLinkWidget(parentWidget, "[[tag][TestPage]]");
   assertEquals(
       "tag<a title=\"create page\" href=\"TestPage?edit&amp;nonExistent=true\">[?]</a>",
       w.render());
 }
Example #7
0
  public void testLinkToNonExistentWikiPageOnVirtualPage() throws Exception {
    // When a virtual page contains a link to a non-existent page, the ? should
    // issue an edit request to the remote machine

    ProxyPage virtualPage =
        new ProxyPage("VirtualPage", root, "host", 9999, PathParser.parse("RealPage.VirtualPage"));
    AliasLinkWidget widget =
        new AliasLinkWidget(new WidgetRoot(virtualPage), "[[link][NonExistentPage]]");
    assertEquals(
        "link<a title=\"create page\" href=\"http://host:9999/RealPage.NonExistentPage?edit&amp;nonExistent=true\" target=\"NonExistentPage\">[?]</a>",
        widget.render());
  }
Example #8
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());
 }
Example #9
0
 public void testAsWikiText() throws Exception {
   String ALIAS_LINK = "[[this][that]]";
   AliasLinkWidget w = new AliasLinkWidget(new WidgetRoot(root), ALIAS_LINK);
   assertEquals(ALIAS_LINK, w.asWikiText());
 }
Example #10
0
 public void testStandardLinkWithAnchor() throws Exception {
   AliasLinkWidget w = new AliasLinkWidget(new WidgetRoot(root), "[[x][http://a.com#zap]]");
   assertEquals("<a href=\"http://a.com#zap\">x</a>", w.render());
 }
Example #11
0
 public void testVariableIsRenderedInAliasTag() throws Exception {
   ParentWidget wroot = new WidgetRoot(root);
   wroot.addVariable("X", "Y");
   AliasLinkWidget w = new AliasLinkWidget(wroot, "[[${X}][x]]");
   assertEquals("<a href=\"x\">Y</a>", w.render());
 }