Exemplo n.º 1
0
  @Test
  public void testKeySet() throws Exception {
    properties = new WikiPageProperties();
    properties.set("one");
    properties.set("two");
    properties.set("three");
    Set<?> keys = properties.keySet();

    assertTrue(keys.contains("one"));
    assertTrue(keys.contains("two"));
    assertTrue(keys.contains("three"));
    assertFalse(keys.contains("four"));
  }
Exemplo n.º 2
0
  public void testSymbolicLinkListing() throws Exception {
    WikiPage page = root.addChildPage("SomePage");
    page.addChildPage("SomeChild");
    WikiPage pageOne = root.addChildPage("PageOne"); // ...page must exist!
    pageOne.addChildPage("ChildOne"); // ...page must exist!

    PageData data = page.getData();
    WikiPageProperties props = data.getProperties();
    WikiPageProperty symProp = props.set(SymbolicPage.PROPERTY_NAME);
    symProp.set("InternalAbsPage", ".PageOne.ChildOne");
    symProp.set("InternalRelPage", "PageOne.ChildOne");
    symProp.set("InternalSubPage", ">SomeChild");
    symProp.set("ExternalPage", "file://some/page");
    page.commit(data);

    getPropertiesContentFromPage(page);

    assertSubString("<td>InternalAbsPage</td>", content);
    assertSubString("<input type=\"text\" name=\"InternalAbsPage\"", content);
    assertSubString("<a href=\".PageOne.ChildOne\">.PageOne.ChildOne</a>", content);
    assertMatches("<a href=\".*\">&nbsp;Rename:</a>", content);

    assertSubString("<td>InternalRelPage</td>", content);
    assertSubString("<input type=\"text\" name=\"InternalRelPage\"", content);
    assertSubString("<a href=\".PageOne.ChildOne\">PageOne.ChildOne</a>", content);

    assertSubString("<td>InternalSubPage</td>", content);
    assertSubString("<input type=\"text\" name=\"InternalSubPage\"", content);
    assertSubString("<a href=\".SomePage.SomeChild\">&gt;SomeChild</a>", content);

    assertSubString("<td>file://some/page</td>", content);
  }
Exemplo n.º 3
0
  @Test
  public void testResponse() throws Exception {
    WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("ChildPage"), "child content");
    PageData data = page.getData();
    WikiPageProperties properties = data.getProperties();
    properties.set(PageData.PropertySUITES, "Wiki Page tags");
    page.commit(data);

    final MockRequest request = new MockRequest();
    request.setResource("ChildPage");

    final Responder responder = new WikiPageResponder();
    final SimpleResponse response = (SimpleResponse) responder.makeResponse(context, request);

    assertEquals(200, response.getStatus());

    final String body = response.getContent();

    assertSubString("<html>", body);
    assertSubString("<body", body);
    assertSubString("child content", body);
    assertSubString("href=\"ChildPage?whereUsed\"", body);
    assertSubString("Cache-Control: max-age=0", response.makeHttpHeaders());
    assertSubString("<h5> Wiki Page tags</h5>", body);
  }
Exemplo n.º 4
0
  public void testResponse() throws Exception {
    WikiPage page = crawler.addPage(root, PathParser.parse("PageOne"));
    PageData data = page.getData();
    data.setContent("some content");
    WikiPageProperties properties = data.getProperties();
    properties.set("Test", "true");
    properties.set(WikiPageProperties.VIRTUAL_WIKI_ATTRIBUTE, "http://www.fitnesse.org");
    page.commit(data);

    MockRequest request = new MockRequest();
    request.setResource("PageOne");

    Responder responder = new PropertiesResponder();
    SimpleResponse response =
        (SimpleResponse) responder.makeResponse(new FitNesseContext(root), request);
    assertEquals("max-age=0", response.getHeader("Cache-Control"));

    String content = response.getContent();
    assertSubString("PageOne", content);
    assertSubString("value=\"http://www.fitnesse.org\"", content);
    assertDoesntHaveRegexp("textarea name=\"extensionXml\"", content);
    assertHasRegexp("<input.*value=\"Save Properties\".*>", content);

    assertHasRegexp("<input.*value=\"saveProperties\"", content);

    assertSubString("<input type=\"checkbox\" name=\"Test\" checked=\"true\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"Search\" checked=\"true\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"Edit\" checked=\"true\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"Properties\" checked=\"true\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"Suite\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"Prune\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"Versions\" checked=\"true\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"Refactor\" checked=\"true\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"WhereUsed\" checked=\"true\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"RecentChanges\" checked=\"true\"/>", content);

    assertSubString("<input type=\"checkbox\" name=\"" + WikiPage.SECURE_READ + "\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"" + WikiPage.SECURE_WRITE + "\"/>", content);
    assertSubString("<input type=\"checkbox\" name=\"" + WikiPage.SECURE_TEST + "\"/>", content);
  }
  private void saveNewProperties(String path, Properties oldProps) throws Exception {
    File newPropsFile = new File(path + FileSystemPage.propertiesFilename);
    WikiPageProperties newProps = new WikiPageProperties();

    for (Iterator iterator = oldProps.keySet().iterator(); iterator.hasNext(); ) {
      String key = (String) iterator.next();
      String value = (String) oldProps.get(key);
      if (!"false".equals(value)) newProps.set(key, value);
    }

    FileOutputStream os = new FileOutputStream(newPropsFile);
    newProps.save(os);
    os.close();
  }
Exemplo n.º 6
0
  public void testSymbolicLinkListingForBackwardPath() throws Exception {
    WikiPage page = root.addChildPage("SomePage");
    WikiPage child = page.addChildPage("SomeChild");
    page.addChildPage("OtherChild");

    PageData data = child.getData();
    WikiPageProperties props = data.getProperties();
    WikiPageProperty symProp = props.set(SymbolicPage.PROPERTY_NAME);
    symProp.set("InternalBackPage", "<SomePage.OtherChild");
    page.commit(data);

    getPropertiesContentFromPage(page);

    assertSubString("InternalBackPage", content);
    assertSubString("<a href=\".SomePage.OtherChild\">&lt;SomePage.OtherChild</a>", content);
  }