@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());
 }
 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;
 }
 @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()));
 }
 @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()));
 }
 @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()));
 }
  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;
  }
 @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"));
 }
Esempio n. 8
0
 private void addJsonAttribute(JSONObject jsonObject, String attribute) {
   try {
     jsonObject.put(attribute, pageData.hasAttribute(attribute));
   } catch (JSONException e) {
     throw new RuntimeException(e);
   }
 }
Esempio n. 9
0
  private void makeFormSections() {
    makePropertiesForm();

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

    makeSymbolicLinkSection();
  }
Esempio 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()));
 }
Esempio 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);
  }
Esempio 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();
  }
Esempio 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];
 }
Esempio 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);
 }
Esempio 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()));
 }
Esempio 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()));
 }