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
 @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.º 3
0
 @Test
 public void testTwoLevel() throws Exception {
   WikiPage levelA = WikiPageUtil.addPage(root, PathParser.parse("PageA"));
   WikiPage page = WikiPageUtil.addPage(levelA, PathParser.parse("PageB"));
   page.commit(page.getData());
   assertTrue(new File(defaultPath + "/RooT/PageA/PageB").exists());
 }
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
 @Test
 public void testLastModifiedTime() throws Exception {
   WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("SomePage"), "some text");
   page.commit(page.getData());
   long now = Clock.currentTimeInMillis();
   Date lastModified = page.getData().getProperties().getLastModificationTime();
   assertTrue(now - lastModified.getTime() <= 5000);
 }
Exemplo n.º 7
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"));
 }
Exemplo n.º 8
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.º 9
0
 @Test
 public void testRemovePage() throws Exception {
   WikiPage levelOne = WikiPageUtil.addPage(root, PathParser.parse("LevelOne"));
   levelOne.commit(levelOne.getData());
   WikiPageUtil.addPage(levelOne, PathParser.parse("LevelTwo"));
   levelOne.removeChildPage("LevelTwo");
   File fileOne = new File(defaultPath + "/RooT/LevelOne");
   File fileTwo = new File(defaultPath + "/RooT/LevelOne/LevelTwo");
   assertTrue(fileOne.exists());
   assertFalse(fileTwo.exists());
 }
Exemplo n.º 10
0
 @Test
 public void testLoadChildrenWhenPageIsDeletedManualy() throws Exception {
   WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("TestPage"));
   page.getChildren();
   FileUtil.deleteFileSystemDirectory(((FileSystemPage) page).getFileSystemPath());
   try {
     page.getChildren();
   } catch (Exception e) {
     fail("No Exception should be thrown");
   }
 }
Exemplo n.º 11
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.º 12
0
 @Test
 public void testGetChidren() throws Exception {
   WikiPageUtil.addPage(root, PathParser.parse("AaAa"), "A content");
   WikiPageUtil.addPage(root, PathParser.parse("BbBb"), "B content");
   WikiPageUtil.addPage(root, PathParser.parse("c"), "C content");
   new File(defaultPath + "/root/.someOtherDir").mkdir();
   new File(defaultPath + "/root/someOther.SubDir").mkdir();
   List<WikiPage> children = root.getChildren();
   assertEquals(3, children.size());
   for (WikiPage child : children) {
     String name = child.getName();
     boolean isOk = "AaAa".equals(name) || "BbBb".equals(name) || "c".equals(name);
     assertTrue("WikiPAge is not a valid one: " + name, isOk);
   }
 }
Exemplo n.º 13
0
  private String makePathForSymbolicLink(String linkPath) {
    WikiPagePath wikiPagePath = PathParser.parse(linkPath);

    if (wikiPagePath != null) {
      WikiPage parent = wikiPagePath.isRelativePath() ? page.getParent() : page;
      PageCrawler crawler = parent.getPageCrawler();
      WikiPage target = crawler.getPage(wikiPagePath);
      WikiPagePath fullPath;
      if (target != null) {
        fullPath = target.getPageCrawler().getFullPath();
        fullPath.makeAbsolute();
      } else fullPath = new WikiPagePath();
      return fullPath.toString();
    }
    return null;
  }
Exemplo n.º 14
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.º 15
0
  public Response makeResponse(FitNesseContext context, Request request) {
    response = new SimpleResponse();
    resource = request.getResource();
    path = PathParser.parse(resource);
    PageCrawler crawler = context.root.getPageCrawler();
    page = crawler.getPage(path, new MockingPageCrawler());
    if (page == null) return new NotFoundResponder().makeResponse(context, request);

    pageData = page.getData();
    makeContent(context, request);
    response.setMaxAge(0);
    return response;
  }
Exemplo n.º 16
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.º 17
0
 @Test
 public void testThatExampleAtEndOfNameSetsTestProperty() throws Exception {
   WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("PageExample"));
   PageData data = page.getData();
   assertTrue(data.hasAttribute(TEST.toString()));
 }