@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());
  }
  @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);
  }
示例#3
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);
  }
 @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());
 }
 @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());
 }
  @Ignore
  @Test
  public void MoreComplexDependency() throws Exception {
    // Complex test : Full tree resolved from
    // http://repository.jboss.org/maven2/

    WikiPage root = InMemoryPage.makeRoot("RooT");

    PageCrawler crawler = root.getPageCrawler();
    // http://repository.jboss.org/nexus/content/groups/public
    WikiPage page =
        crawler.addPage(
            root,
            PathParser.parse("ClassPath"),
            "!define REMOTE_REPO {http://maven.springframework.org/milestone;  }\n!define LOCAL_REPO {target/repo}\n!artifact org.springframework:spring-core:3.0.0.RC1\n");

    List<String> paths = page.getData().getClasspaths();
    System.out.println(paths);
    assertEquals(
        repoDir
            + "/org/springframework/spring-core/3.0.0.RC1/spring-core-3.0.0.RC1.jar:"
            + repoDir
            + "/org/springframework/spring-asm/3.0.0.RC1/spring-asm-3.0.0.RC1.jar:"
            + repoDir
            + "/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:"
            + repoDir
            + "/org/jboss/logging/com.springsource.org.jboss.logging/2.0.5.GA/com.springsource.org.jboss.logging-2.0.5.GA.jar:"
            + repoDir
            + "/org/jboss/util/com.springsource.org.jboss.util/2.2.9.GA/com.springsource.org.jboss.util-2.2.9.GA.jar",
        paths.get(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 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()));
 }
 private String getPathForSetUpTearDown(WikiPage page, String setUpTearDownName) throws Exception {
   String path = null;
   WikiPage suiteSetUpTearDown = PageCrawlerImpl.getClosestInheritedPage(setUpTearDownName, page);
   if (suiteSetUpTearDown != null)
     path = suiteSetUpTearDown.getPageCrawler().getFullPath(suiteSetUpTearDown).toString();
   return path;
 }
 private WikiPage addTestPage(WikiPage page, String name, String content) {
   WikiPage testPage = WikiPageUtil.addPage(page, PathParser.parse(name), content);
   PageData data = testPage.getData();
   data.setAttribute("Test");
   testPage.commit(data);
   return testPage;
 }
 @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);
 }
 @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"));
 }
示例#14
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"));
 }
示例#15
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));
 }
示例#16
0
  public void testWholeTreeOrphaned() throws Exception {
    importer.importWiki(localRoot);

    remoteRoot.removeChildPage("PageOne");

    importer.importWiki(localRoot);

    assertFalse(localRoot.hasChildPage("PageOne"));
  }
示例#17
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;
  }
  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));
  }
 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);
 }
  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");
  }
 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);
 }
示例#22
0
  public void testOrphansAreRemoved() throws Exception {
    performImportWithExtraLocalPages();

    assertFalse(localRoot.hasChildPage("PageThree"));
    assertFalse(pageOne.hasChildPage("ChildTwo"));
    assertFalse(childPageOne.hasChildPage("GrandChildOne"));

    assertTrue(localRoot.hasChildPage("PageThatDoesntImport"));
    assertTrue(localRoot.hasChildPage("OtherImportRoot"));
  }
 private void addImportPropertyToPage(WikiPage page, boolean isRoot, boolean autoUpdate)
     throws Exception {
   PageData data = page.getData();
   String sourceUrl = FitNesseUtil.URL + "PageOne";
   WikiImportProperty importProps = new WikiImportProperty(sourceUrl);
   importProps.setRoot(isRoot);
   importProps.setAutoUpdate(autoUpdate);
   importProps.addTo(data.getProperties());
   pageOne.commit(data);
 }
示例#24
0
  public void testDefaultRootPage() throws Exception {
    WikiPageFactory wikiPageFactory = new WikiPageFactory();
    factory.loadWikiPage(wikiPageFactory);
    assertEquals(FileSystemPage.class, wikiPageFactory.getWikiPageClass());

    WikiPage page = wikiPageFactory.makeRootPage("testPath", "TestRoot", factory);
    assertNotNull(page);
    assertEquals(FileSystemPage.class, page.getClass());
    assertEquals("TestRoot", page.getName());
  }
示例#25
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()));
 }
示例#26
0
  public boolean shouldIncludeScenarioLibraries() {
    // Should consider all of the decorated content to resolve those variables.
    String testSystem = sourcePage.getVariable(WikiPageIdentity.TEST_SYSTEM);
    boolean isSlim =
        "slim".equalsIgnoreCase(testSystem) || "slimCoverage".equalsIgnoreCase(testSystem);
    String includeScenarioLibraries = sourcePage.getVariable("INCLUDE_SCENARIO_LIBRARIES");
    boolean includeScenarios = "true".equalsIgnoreCase(includeScenarioLibraries);
    boolean notIncludeScenarios = "false".equalsIgnoreCase(includeScenarioLibraries);

    return includeScenarios || (!notIncludeScenarios && isSlim);
  }
  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);
  }
 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());
  }
  private void removeSymbolicLink(Request request, WikiPage page) {
    String linkToRemove = request.getInput("removal");

    PageData data = page.getData();
    WikiPageProperty properties = data.getProperties();
    WikiPageProperty symLinks = getSymLinkProperty(properties);
    symLinks.remove(linkToRemove);
    if (symLinks.keySet().isEmpty()) properties.remove(SymbolicPage.PROPERTY_NAME);
    page.commit(data);
    setRedirect(resource);
  }