@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 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"));
 }
 @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);
 }
示例#4
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()));
 }
  @Test
  public void testRunWithSuiteFromRoot() throws Exception {
    addImportPropertyToPage(pageOne, true, true);

    testResponder.importWikiPages();

    assertEquals("", pageOne.getData().getContent());
    assertEquals(MockWikiImporter.mockContent, childOne.getData().getContent());
    assertEquals(MockWikiImporter.mockContent, childTwo.getData().getContent());
    assertEquals("Updating imported content... Done.", sentMessages);
  }
示例#6
0
  public void testEnterChildPageWhenRemotePageNotModified() throws Exception {
    importer.enterChildPage(pageOne, Clock.currentDate());
    importer.exitPage();

    PageData data = pageOne.getData();
    data.setContent("new content");
    pageOne.commit(data);

    importer.enterChildPage(pageOne, new Date(0));

    assertEquals("new content", pageOne.getData().getContent());
  }
 @Test
 public void testPersistentAttributes() throws Exception {
   WikiPage createdPage = crawler.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"));
 }
 @Test
 public void testDelTree() throws Exception {
   WikiPage levelOne = crawler.addPage(root, PathParser.parse("LevelOne"));
   WikiPage levelTwo = crawler.addPage(levelOne, PathParser.parse("LevelTwo"));
   levelOne.commit(levelOne.getData());
   levelTwo.commit(levelTwo.getData());
   File childOne = new File(defaultPath + "/RooT/LevelOne");
   File childTwo = new File(defaultPath + "/RooT/LevelOne/LevelTwo");
   assertTrue(childOne.exists());
   root.removeChildPage("LevelOne");
   assertFalse(childTwo.exists());
   assertFalse(childOne.exists());
 }
示例#9
0
  public void testAutoUpdateWhenRemotePageNotModified() throws Exception {
    importer.enterChildPage(pageOne, Clock.currentDate());
    importer.exitPage();

    PageData data = pageOne.getData();
    data.setContent("new content");
    pageOne.commit(data);

    importer.setAutoUpdateSetting(true);
    importer.enterChildPage(pageOne, new Date(0));

    WikiImportProperty importProps =
        WikiImportProperty.createFrom(pageOne.getData().getProperties());
    assertTrue(importProps.isAutoUpdate());
  }
  @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));
  }
示例#11
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()));
 }
  public void testSymbolicLinkListing() throws Exception {
    WikiPage page = root.addChildPage("SomePage");
    page.addChildPage("SomeChild");
    WikiPage pageOne = root.addChildPage("PageOne"); // ...page must exist!
    pageOne.addChildPage("ChildOne"); // ...page must exist!

    PageData data = page.getData();
    WikiPageProperties props = data.getProperties();
    WikiPageProperty symProp = props.set(SymbolicPage.PROPERTY_NAME);
    symProp.set("InternalAbsPage", ".PageOne.ChildOne");
    symProp.set("InternalRelPage", "PageOne.ChildOne");
    symProp.set("InternalSubPage", ">SomeChild");
    symProp.set("ExternalPage", "file://some/page");
    page.commit(data);

    getPropertiesContentFromPage(page);

    assertSubString("<td>InternalAbsPage</td>", content);
    assertSubString("<input type=\"text\" name=\"InternalAbsPage\"", content);
    assertSubString("<a href=\".PageOne.ChildOne\">.PageOne.ChildOne</a>", content);
    assertMatches("<a href=\".*\">&nbsp;Rename:</a>", content);

    assertSubString("<td>InternalRelPage</td>", content);
    assertSubString("<input type=\"text\" name=\"InternalRelPage\"", content);
    assertSubString("<a href=\".PageOne.ChildOne\">PageOne.ChildOne</a>", content);

    assertSubString("<td>InternalSubPage</td>", content);
    assertSubString("<input type=\"text\" name=\"InternalSubPage\"", content);
    assertSubString("<a href=\".SomePage.SomeChild\">&gt;SomeChild</a>", content);

    assertSubString("<td>file://some/page</td>", content);
  }
示例#13
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);
  }
 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;
 }
示例#15
0
 private TableTable makeTableTable(String tableText) throws Exception {
   WikiPageUtil.setPageContents(root, tableText);
   TableScanner ts = new HtmlTableScanner(root.getData().getHtml());
   Table t = ts.getTable(0);
   testContext = new SlimTestContextImpl();
   return new TableTable(t, "id", testContext);
 }
示例#16
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()));
 }
示例#17
0
  public void testChildPageAdded() throws Exception {
    importer.enterChildPage(pageOne, Clock.currentDate());
    importer.enterChildPage(childPageOne, Clock.currentDate());

    PageData data = childPageOne.getData();
    assertEquals("child one", data.getContent());
  }
示例#18
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());
 }
示例#20
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());
 }
  @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);
  }
示例#22
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));
 }
示例#23
0
  public void testAutoUpdatePropertySetOnRoot() throws Exception {
    addLocalPageWithImportProperty(localRoot, "PageOne", false);
    importer.parseUrl("http://localhost:" + FitNesseUtil.port + "/PageOne");
    importer.setAutoUpdateSetting(true);
    WikiPage importedPage = localRoot.getChildPage("PageOne");
    importer.importWiki(importedPage);

    WikiImportProperty importProp =
        WikiImportProperty.createFrom(importedPage.getData().getProperties());
    assertTrue(importProp.isAutoUpdate());

    importer.setAutoUpdateSetting(false);
    importer.importWiki(importedPage);

    importProp = WikiImportProperty.createFrom(importedPage.getData().getProperties());
    assertFalse(importProp.isAutoUpdate());
  }
示例#24
0
  public void testAutoUpdate_NewPage() throws Exception {
    importer.setAutoUpdateSetting(true);
    importer.enterChildPage(pageOne, Clock.currentDate());

    WikiImportProperty importProps =
        WikiImportProperty.createFrom(pageOne.getData().getProperties());
    assertTrue(importProps.isAutoUpdate());
  }
示例#25
0
 @Override
 public String getContent() {
   if (containsWikitext()) {
     return getDecoratedContent();
   } else {
     return sourcePage.getData().getContent();
   }
 }
  @Test
  public void testRunWithTestingOnePageWithoutAutoUpdate() throws Exception {
    addImportPropertyToPage(pageOne, false, false);

    testResponder.importWikiPages();

    assertEquals("", pageOne.getData().getContent());
    assertEquals("", sentMessages);
  }
  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));
  }
示例#28
0
  @Test
  public void testEmptyTestPage() throws Exception {
    PageData data = root.getData();
    data.setContent(classpathWidgets());
    root.commit(data);
    testPage = crawler.addPage(root, PathParser.parse("EmptyTestPage"));
    request.setResource(testPage.getName());

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

    WikiPagePath errorLogPath = PathParser.parse("ErrorLogs.EmptyTestPage");
    WikiPage errorLogPage = crawler.getPage(root, errorLogPath);
    String errorLogContent = errorLogPage.getData().getContent();
    assertNotSubString("Exception", errorLogContent);
  }
 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");
  }