Exemplo n.º 1
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()));
 }
 @Test
 public void testTwoLevel() throws Exception {
   WikiPage levelA = crawler.addPage(root, PathParser.parse("PageA"));
   WikiPage page = crawler.addPage(levelA, PathParser.parse("PageB"));
   page.commit(page.getData());
   assertTrue(new File(defaultPath + "/RooT/PageA/PageB").exists());
 }
Exemplo n.º 3
0
  @Test
  public void testPagesForTestSystemAreSurroundedBySuiteSetupAndTeardown() throws Exception {
    WikiPage slimPage = addTestPage(suite, "AaSlimTest", simpleSlimDecisionTable);
    WikiPage setUp = crawler.addPage(root, PathParser.parse("SuiteSetUp"), "suite set up");
    WikiPage tearDown = crawler.addPage(root, PathParser.parse("SuiteTearDown"), "suite tear down");

    testPages = new LinkedList<WikiPage>();
    testPages.add(setUp);
    testPages.add(slimPage);
    testPages.add(testPage);
    testPages.add(tearDown);

    MultipleTestsRunner runner = new MultipleTestsRunner(testPages, context, suite, null);
    Map<TestSystem.Descriptor, LinkedList<TestPage>> map = runner.makeMapOfPagesByTestSystem();
    TestSystem.Descriptor fitDescriptor =
        TestSystem.getDescriptor(testPage.getData(), context.pageFactory, false);
    TestSystem.Descriptor slimDescriptor =
        TestSystem.getDescriptor(slimPage.getData(), context.pageFactory, false);

    List<TestPage> fitList = map.get(fitDescriptor);
    List<TestPage> slimList = map.get(slimDescriptor);

    assertEquals(3, fitList.size());
    assertEquals(3, slimList.size());

    assertEquals(setUp, fitList.get(0).getSourcePage());
    assertEquals(testPage, fitList.get(1).getSourcePage());
    assertEquals(tearDown, fitList.get(2).getSourcePage());

    assertEquals(setUp, slimList.get(0).getSourcePage());
    assertEquals(slimPage, slimList.get(1).getSourcePage());
    assertEquals(tearDown, slimList.get(2).getSourcePage());
  }
Exemplo n.º 4
0
  /**
   * Compare two pages (WikiPage version). Compares them by name first. If the same name, compares
   * their versions.
   *
   * @param page1 the first page
   * @param page2 the second page
   * @return see java.util.Comparator
   * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
   */
  public int compare(WikiPage page1, WikiPage page2) {
    if (page1 == page2) return 0; // the same object

    int res = m_comparator.compare(page1.getName(), page2.getName());
    if (res == 0) res = page1.getVersion() - page2.getVersion();
    return res;
  }
Exemplo n.º 5
0
 @Test
 public void DirectoryWithContentIsFileSystemPage() throws Exception {
   fileSystem.makeFile("./somepath/WikiPage/content.txt", "stuff");
   fileSystem.makeFile("./somepath/WikiPage/subsuite/myfile.html", "stuff");
   WikiPage page = pageRepository.makeChildPage("WikiPage", rootPage);
   assertEquals(FileSystemPage.class, page.getClass());
 }
Exemplo n.º 6
0
  /**
   * Updates the lucene index for a single page.
   *
   * @param page The WikiPage to check
   * @param text The page text to index.
   */
  protected synchronized void updateLuceneIndex(WikiPage page, String text) {
    IndexWriter writer = null;

    log.debug("Updating Lucene index for page '" + page.getName() + "'...");

    Directory luceneDir = null;
    try {
      pageRemoved(page);

      // Now add back the new version.
      luceneDir = new SimpleFSDirectory(new File(m_luceneDirectory), null);
      writer = getIndexWriter(luceneDir);

      luceneIndexPage(page, text, writer);
    } catch (IOException e) {
      log.error("Unable to update page '" + page.getName() + "' from Lucene index", e);
      // reindexPage( page );
    } catch (Exception e) {
      log.error("Unexpected Lucene exception - please check configuration!", e);
      // reindexPage( page );
    } finally {
      close(writer);
    }

    log.debug("Done updating Lucene index for page '" + page.getName() + "'.");
  }
Exemplo n.º 7
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.º 8
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.º 9
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.º 10
0
  @Test
  public void testSuiteSetUpAndTearDownIsCalledIfSingleTestIsRun() throws Exception {
    responder.setFastTest(false);
    WikiPage suitePage = crawler.addPage(root, PathParser.parse("TestSuite"), classpathWidgets());
    WikiPage testPage =
        crawler.addPage(
            suitePage, PathParser.parse("TestPage"), outputWritingTable("Output of TestPage"));
    crawler.addPage(
        suitePage,
        PathParser.parse(SuiteContentsFinder.SUITE_SETUP_NAME),
        outputWritingTable("Output of SuiteSetUp"));
    crawler.addPage(
        suitePage,
        PathParser.parse(SuiteContentsFinder.SUITE_TEARDOWN_NAME),
        outputWritingTable("Output of SuiteTearDown"));

    WikiPagePath testPagePath = crawler.getFullPath(testPage);
    String resource = PathParser.render(testPagePath);
    request.setResource(resource);

    Response response = responder.makeResponse(context, request);
    MockResponseSender sender = new MockResponseSender();
    sender.doSending(response);
    results = sender.sentData();

    assertEquals("Output Captured", getExecutionStatusMessage());
    assertHasRegexp("ErrorLog", results);

    WikiPage errorLog = crawler.getPage(errorLogsParentPage, testPagePath);
    String errorLogContent = errorLog.getData().getContent();
    assertHasRegexp("Output of SuiteSetUp", errorLogContent);
    assertHasRegexp("Output of TestPage", errorLogContent);
    assertHasRegexp("Output of SuiteTearDown", errorLogContent);
  }
Exemplo n.º 11
0
 @Test
 public void testLastModifiedTime() throws Exception {
   WikiPage page = crawler.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.º 12
0
 @Test
 public void testDefaultAttributes() throws Exception {
   WikiPage page = crawler.addPage(root, PathParser.parse("PageOne"), "something");
   assertTrue(page.getData().hasAttribute("Edit"));
   assertTrue(page.getData().hasAttribute("Search"));
   assertFalse(page.getData().hasAttribute("Test"));
   assertFalse(page.getData().hasAttribute("TestSuite"));
 }
Exemplo n.º 13
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.º 14
0
 @Test
 public void testCanSaveOutOfOrderIfFromSameEditSession() throws Exception {
   PageData data = somePage.getData();
   long ticket = 99;
   long time = SaveRecorder.pageSaved(data, ticket, clock);
   somePage.commit(data);
   assertFalse(SaveRecorder.changesShouldBeMerged(time - 1, ticket, data));
 }
 @Test
 public void testUsernameColumnWithoutUser() throws Exception {
   recentChangesWikiPage.updateRecentChanges(page1);
   WikiPage recentChanges = rootPage.getChildPage("RecentChanges");
   List<String> lines = recentChangesWikiPage.getRecentChangesLines(recentChanges.getData());
   String line = lines.get(0).toString();
   assertSubString("|PageOne||", line);
 }
 @Before
 public void setUp() throws Exception {
   rootPage = InMemoryPage.makeRoot("RooT");
   newPage = rootPage.addChildPage("SomeNewPage");
   page1 = rootPage.addChildPage("PageOne");
   page2 = rootPage.addChildPage("PageTwo");
   recentChangesWikiPage = new RecentChangesWikiPage();
 }
 @Test
 public void testNoDuplicates() throws Exception {
   recentChangesWikiPage.updateRecentChanges(page1);
   recentChangesWikiPage.updateRecentChanges(page1);
   WikiPage recentChanges = rootPage.getChildPage("RecentChanges");
   List<String> lines = recentChangesWikiPage.getRecentChangesLines(recentChanges.getData());
   assertEquals(1, lines.size());
   assertHasRegexp("PageOne", lines.get(0));
 }
Exemplo n.º 18
0
  public void testGetVirtualWikiValue() throws Exception {
    WikiPage page = crawler.addPage(root, PathParser.parse("PageOne"));
    PageData data = page.getData();

    assertEquals("", PropertiesResponder.getVirtualWikiValue(data));

    data.setAttribute(WikiPageProperties.VIRTUAL_WIKI_ATTRIBUTE, "http://www.objectmentor.com");
    assertEquals("http://www.objectmentor.com", PropertiesResponder.getVirtualWikiValue(data));
  }
Exemplo n.º 19
0
  private WikiPage addTestPage(WikiPage page, String name, String content) throws Exception {
    WikiPage testPage = crawler.addPage(page, PathParser.parse(name), content);
    PageData data = testPage.getData();
    data.setAttribute("Test");
    testPage.commit(data);
    testPages.add(testPage);

    return testPage;
  }
Exemplo n.º 20
0
 public void testMakeSecurityPropertiesHtml() throws Exception {
   WikiPage page = root.addChildPage("SomePage");
   PageData data = page.getData();
   String html = new PropertiesResponder().makeSecurityCheckboxesHtml(data).html();
   assertSubString("<div style=\"float: left; width: 150px;\">Security:", html);
   assertSubString("<input type=\"checkbox\" name=\"secure-read\"/> - secure-read", html);
   assertSubString("<input type=\"checkbox\" name=\"secure-write\"/> - secure-write", html);
   assertSubString("<input type=\"checkbox\" name=\"secure-test\"/> - secure-test", html);
 }
Exemplo n.º 21
0
 @Test
 public void DirectoryOfHtmlFilesIsExternalSuitePageChild() throws Exception {
   fileSystem.makeFile("./somepath/ExternalSuite/subsuite/myfile.html", "stuff");
   ExternalSuitePage page =
       (ExternalSuitePage) pageRepository.makeChildPage("ExternalSuite", rootPage);
   WikiPage child = pageRepository.findChildren(page).get(0);
   assertEquals(ExternalSuitePage.class, child.getClass());
   assertEquals("SubsuitE", child.getName());
 }
  private void prepareSymlinkOnPageOne() {
    PageData data = pageOne.getData();
    WikiPageProperty symLinks = data.getProperties().set(SymbolicPage.PROPERTY_NAME);
    symLinks.set("SymLink", "PageTwo");
    pageOne.commit(data);
    assertNotNull(pageOne.getChildPage("SymLink"));

    request.addInput("rename", "SymLink");
  }
Exemplo n.º 23
0
 private boolean isInternalPageThatDoesntExist(String linkPath) {
   String expandedPath = WikiWordReference.expandPrefix(page, linkPath);
   WikiPagePath path = PathParser.parse(expandedPath);
   if (path == null) {
     return true;
   }
   WikiPage start = path.isRelativePath() ? page.getParent() : page; // TODO -AcD- a better way?
   return !start.getPageCrawler().pageExists(path);
 }
 @Test
 public void testFirstRecentChange() throws Exception {
   assertEquals(false, rootPage.hasChildPage("RecentChanges"));
   recentChangesWikiPage.updateRecentChanges(newPage);
   assertEquals(true, rootPage.hasChildPage("RecentChanges"));
   WikiPage recentChanges = rootPage.getChildPage("RecentChanges");
   List<String> lines = recentChangesWikiPage.getRecentChangesLines(recentChanges.getData());
   assertEquals(1, lines.size());
   assertHasRegexp("SomeNewPage", lines.get(0));
 }
Exemplo n.º 25
0
 public List getNormalChildren() throws Exception {
   List children = realPage.getChildren();
   List symChildren = new LinkedList();
   for (Iterator iterator = children.iterator(); iterator.hasNext(); ) {
     WikiPage child = (WikiPage) iterator.next();
     if (!(child instanceof SymbolicPage))
       symChildren.add(new SymbolicPage(child.getName(), child, this));
   }
   return symChildren;
 }
Exemplo n.º 26
0
  public void testdoesntTraverseSymbolicPages() throws Exception {
    PageData data = page1.getData();
    data.getProperties().set(SymbolicPage.PROPERTY_NAME).set("SymLink", "PageTwo");
    page1.commit(data);

    crawler.traverse(root, this);
    assertEquals(6, traversedPages.size());

    assertFalse(traversedPages.contains("SymLink"));
  }
Exemplo n.º 27
0
 @Test
 public void testTiming() throws Exception {
   PageData data = somePage.getData();
   long savedTicket = 0;
   long editTicket = 1;
   long time = SaveRecorder.pageSaved(data, savedTicket, clock);
   somePage.commit(data);
   assertTrue(SaveRecorder.changesShouldBeMerged(time - 1, editTicket, somePage.getData()));
   assertFalse(SaveRecorder.changesShouldBeMerged(time + 1, editTicket, somePage.getData()));
 }
Exemplo n.º 28
0
  public void testSuitesDisplayed() throws Exception {
    WikiPage page = getContentFromSimplePropertiesPage();
    PageData data = page.getData();
    data.setAttribute(PageData.PropertySUITES, "smoke");
    page.commit(data);

    getPropertiesContentFromPage(page);

    assertSubString("Suites", content);
    assertSubString("<input type=\"text\" name=\"Suites\" value=\"smoke\" size=\"40\"/>", content);
  }
Exemplo n.º 29
0
 public void testMakeNavigationPropertiesHtml() throws Exception {
   WikiPage page = root.addChildPage("SomePage");
   PageData data = page.getData();
   String html = new PropertiesResponder().makeNavigationCheckboxesHtml(data).html();
   assertSubString("<div style=\"float: left; width: 150px;\">Navigation:", html);
   assertSubString("<input type=\"checkbox\" name=\"Files\" checked=\"true\"/> - Files", html);
   assertSubString(
       "<input type=\"checkbox\" name=\"RecentChanges\" checked=\"true\"/> - RecentChanges", html);
   assertSubString("<input type=\"checkbox\" name=\"Search\" checked=\"true\"/> - Search", html);
   assertSubString("<input type=\"checkbox\" name=\"Prune\"/> - Prune", html);
 }
  private void executeSymbolicLinkTestWith(String linkName, String linkPath) throws Exception {
    request.addInput("linkName", linkName);
    request.addInput("linkPath", linkPath);
    Response response = invokeResponder();

    checkPageOneRedirectToProperties(response);

    WikiPage symLink = pageOne.getChildPage("SymLink");
    assertNotNull(symLink);
    assertEquals(SymbolicPage.class, symLink.getClass());
  }