Exemplo n.º 1
0
 @Test
 public void testUnicodeCharacters() throws Exception {
   WikiPage page =
       WikiPageUtil.addPage(root, PathParser.parse("SomePage"), "\uba80\uba81\uba82\uba83");
   PageData data = page.getData();
   assertEquals("\uba80\uba81\uba82\uba83", data.getContent());
 }
Exemplo n.º 2
0
 private JSONObject makeJson() {
   response.setContentType("text/json");
   JSONObject jsonObject = new JSONObject();
   String attributes[] =
       new String[] {
         TEST.toString(),
         PropertySEARCH,
         PropertyEDIT,
         PropertyPROPERTIES,
         PropertyVERSIONS,
         PropertyREFACTOR,
         PropertyWHERE_USED,
         PropertyRECENT_CHANGES,
         SUITE.toString(),
         PropertyPRUNE,
         PropertySECURE_READ,
         PropertySECURE_WRITE,
         PropertySECURE_TEST,
         PropertyFILES
       };
   for (String attribute : attributes) addJsonAttribute(jsonObject, attribute);
   if (pageData.hasAttribute(PropertyHELP)) {
     jsonObject.put(PropertyHELP, pageData.getAttribute(PropertyHELP));
   }
   if (pageData.hasAttribute(PropertySUITES)) {
     JSONArray tags = new JSONArray();
     for (String tag : pageData.getAttribute(PropertySUITES).split(",")) {
       if (StringUtils.isNotBlank(tag)) {
         tags.put(tag.trim());
       }
     }
     jsonObject.put(PropertySUITES, tags);
   }
   return jsonObject;
 }
Exemplo n.º 3
0
 @Test
 public void testDefaultAttributesForSuitePageNames() throws Exception {
   WikiPage suitePage3 = WikiPageUtil.addPage(root, PathParser.parse("TestPageSuite"));
   PageData data = suitePage3.getData();
   assertFalse(data.hasAttribute(TEST.toString()));
   assertTrue(data.hasAttribute(SUITE.toString()));
 }
Exemplo n.º 4
0
 @Test
 public void testThatTestAtEndOfNameSetsTestProperty() throws Exception {
   WikiPage testPage2 = WikiPageUtil.addPage(root, PathParser.parse("PageTest"));
   PageData data = testPage2.getData();
   assertTrue(data.hasAttribute(TEST.toString()));
   assertFalse(data.hasAttribute(SUITE.toString()));
 }
Exemplo n.º 5
0
 @Test
 public void testThatSuiteAtBeginningOfNameSetsSuiteProperty() throws Exception {
   WikiPage suitePage1 = WikiPageUtil.addPage(root, PathParser.parse("SuitePage"));
   PageData data = suitePage1.getData();
   assertFalse(data.hasAttribute(TEST.toString()));
   assertTrue(data.hasAttribute(SUITE.toString()));
 }
Exemplo n.º 6
0
  public static PageType fromWikiPage(WikiPage page) {
    PageData data = page.getData();
    if (data.hasAttribute(SUITE.toString())) {
      return SUITE;
    }

    if (data.hasAttribute(TEST.toString())) {
      return TEST;
    }

    return STATIC;
  }
Exemplo n.º 7
0
 @Test
 public void testPersistentAttributes() throws Exception {
   WikiPage createdPage = WikiPageUtil.addPage(root, PathParser.parse("FrontPage"));
   PageData data = createdPage.getData();
   data.setAttribute("Test", "true");
   data.setAttribute("Search", "true");
   createdPage.commit(data);
   assertTrue(data.hasAttribute("Test"));
   assertTrue(data.hasAttribute("Search"));
   WikiPage page = root.getChildPage("FrontPage");
   assertTrue(page.getData().hasAttribute("Test"));
   assertTrue(page.getData().hasAttribute("Search"));
 }
Exemplo n.º 8
0
 private void addJsonAttribute(JSONObject jsonObject, String attribute) {
   try {
     jsonObject.put(attribute, pageData.hasAttribute(attribute));
   } catch (JSONException e) {
     throw new RuntimeException(e);
   }
 }
Exemplo n.º 9
0
  private void makeFormSections() {
    makePropertiesForm();

    WikiImportProperty importProperty = WikiImportProperty.createFrom(pageData.getProperties());
    if (importProperty != null) makeImportUpdateForm(importProperty);
    else makeImportForm();

    makeSymbolicLinkSection();
  }
Exemplo n.º 10
0
 @Test
 public void testDefaultAttributesForNormalPageNames() throws Exception {
   WikiPage normalPage = WikiPageUtil.addPage(root, PathParser.parse("NormalPage"));
   PageData data = normalPage.getData();
   assertTrue(data.hasAttribute(PropertyEDIT));
   assertTrue(data.hasAttribute(PropertySEARCH));
   assertTrue(data.hasAttribute(PropertyVERSIONS));
   assertTrue(data.hasAttribute(PropertyFILES));
   assertFalse(data.hasAttribute(TEST.toString()));
   assertFalse(data.hasAttribute(SUITE.toString()));
 }
Exemplo n.º 11
0
  private void makeSymbolicLinkSection() {
    WikiPageProperty symLinksProperty =
        pageData.getProperties().getProperty(SymbolicPage.PROPERTY_NAME);
    if (symLinksProperty == null) return;
    List<Symlink> symlinks = new ArrayList<Symlink>();
    Set<String> symbolicLinkNames = symLinksProperty.keySet();
    for (String name : symbolicLinkNames) {
      String link = symLinksProperty.get(name);

      String path = makePathForSymbolicLink(link);
      symlinks.add(new Symlink(name, Utils.escapeHTML(link), path));
    }
    html.put("symlinks", symlinks);
  }
Exemplo n.º 12
0
  private String makeHtml(FitNesseContext context, Request request) {
    html = context.pageFactory.newPage();
    html.setNavTemplate("viewNav");
    html.put("viewLocation", request.getResource());
    html.setTitle("Properties: " + resource);

    String tags = "";
    if (pageData != null) {
      tags = pageData.getAttribute(PageData.PropertySUITES);
    }

    html.setPageTitle(new PageTitle("Page Properties", path, tags));
    html.put("pageData", pageData);
    html.setMainTemplate("propertiesPage");
    makeLastModifiedTag();
    makeFormSections();

    return html.html();
  }
Exemplo n.º 13
0
 private String getCheckedAttribute(PageData pageData, String[] attributes) {
   for (int i = attributes.length - 1; i > 0; i--) {
     if (pageData.hasAttribute(attributes[i])) return attributes[i];
   }
   return attributes[0];
 }
Exemplo n.º 14
0
 private void makeLastModifiedTag() {
   String username = pageData.getAttribute(LAST_MODIFYING_USER);
   if (username == null || "".equals(username))
     html.put("lastModified", "Last modified anonymously");
   else html.put("lastModified", "Last modified by " + username);
 }
Exemplo n.º 15
0
 @Test
 public void testDefaultAttributesForSuiteTearDownPageNames() throws Exception {
   WikiPage suiteTearDownPage = WikiPageUtil.addPage(root, PathParser.parse(SUITE_TEARDOWN_NAME));
   PageData data = suiteTearDownPage.getData();
   assertFalse(data.hasAttribute(SUITE.toString()));
 }
Exemplo n.º 16
0
 @Test
 public void testThatExampleAtEndOfNameSetsTestProperty() throws Exception {
   WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("PageExample"));
   PageData data = page.getData();
   assertTrue(data.hasAttribute(TEST.toString()));
 }