@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());
 }
Esempio n. 2
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);
  }
 @Before
 public void setUp() throws Exception {
   PageCrawler crawler = root.getPageCrawler();
   crawler.addPage(root, PathParser.parse("PageOne"), "PageOne");
   WikiPage pageTwo = crawler.addPage(root, PathParser.parse("PageTwo"), "PageOne");
   crawler.addPage(pageTwo, PathParser.parse("ChildPage"), ".PageOne");
 }
Esempio n. 4
0
 public void testHtmlAtTopLevelPageWithAnchor() throws Exception {
   crawler.addPage(root, PathParser.parse("TestPage"));
   ParentWidget wroot = new WidgetRoot(new PagePointer(root, PathParser.parse("TestPage")));
   AliasLinkWidget w = new AliasLinkWidget(wroot, "[[tag][TestPage#anchor]]");
   String html = w.render();
   assertEquals("<a href=\"TestPage#anchor\">tag</a>", html);
 }
Esempio n. 5
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());
  }
Esempio n. 6
0
 @Test
 public void testResultsHaveHeaderAndFooter() throws Exception {
   crawler.addPage(root, PathParser.parse("PageHeader"), "HEADER");
   crawler.addPage(root, PathParser.parse("PageFooter"), "FOOTER");
   doSimpleRun(passFixtureTable());
   assertSubString("HEADER", results);
   assertSubString("FOOTER", results);
 }
Esempio n. 7
0
 public void testUparrowOnPageThatDoesExist() throws Exception {
   WikiPage page = crawler.addPage(root, PathParser.parse("TestPage"));
   crawler.addPage(page, PathParser.parse("SubPage"));
   ParentWidget wroot = new WidgetRoot(page);
   AliasLinkWidget w = new AliasLinkWidget(wroot, "[[tag][^SubPage]]");
   String html = w.render();
   assertEquals("<a href=\"TestPage.SubPage\">tag</a>", html);
 }
Esempio n. 8
0
 public WikiPage createRemoteRoot() throws Exception {
   remoteRoot = InMemoryPage.makeRoot("RooT");
   PageCrawler crawler = remoteRoot.getPageCrawler();
   crawler.addPage(remoteRoot, PathParser.parse("PageOne"), "page one");
   crawler.addPage(remoteRoot, PathParser.parse("PageOne.ChildOne"), "child one");
   crawler.addPage(remoteRoot, PathParser.parse("PageTwo"), "page two");
   return remoteRoot;
 }
Esempio n. 9
0
 public void testHtmlForPageThatDoesNotExist() throws Exception {
   crawler.addPage(root, PathParser.parse("FrontPage"));
   ParentWidget parentWidget =
       new WidgetRoot(new PagePointer(root, PathParser.parse("FrontPage")));
   AliasLinkWidget w = new AliasLinkWidget(parentWidget, "[[tag][TestPage]]");
   assertEquals(
       "tag<a title=\"create page\" href=\"TestPage?edit&amp;nonExistent=true\">[?]</a>",
       w.render());
 }
 @Test
 public void testContent() throws Exception {
   WikiPagePath rootPath = PathParser.parse("root");
   assertEquals("", crawler.getPage(root, rootPath).getData().getContent());
   crawler.addPage(root, PathParser.parse("AaAa"), "A content");
   assertEquals("A content", root.getChildPage("AaAa").getData().getContent());
   WikiPagePath bPath = PathParser.parse("AaAa.BbBb");
   crawler.addPage(root, bPath, "B content");
   assertEquals("B content", crawler.getPage(root, bPath).getData().getContent());
 }
 @Test
 public void testRemovePage() throws Exception {
   WikiPage levelOne = crawler.addPage(root, PathParser.parse("LevelOne"));
   levelOne.commit(levelOne.getData());
   crawler.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());
 }
Esempio n. 12
0
 @Test
 public void testDelTree() throws Exception {
   WikiPage levelOne = WikiPageUtil.addPage(root, PathParser.parse("LevelOne"));
   WikiPage levelTwo = WikiPageUtil.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());
 }
Esempio n. 13
0
 public void testHtmlOnSubPage() throws Exception {
   crawler.addPage(root, PathParser.parse("ParenT"), "Content");
   WikiPage parent = root.getChildPage("ParenT");
   crawler.addPage(parent, PathParser.parse("ChilD"), "ChilD");
   crawler.addPage(parent, PathParser.parse("ChildTwo"), "ChildTwo");
   WikiPage child = parent.getChildPage("ChilD");
   ParentWidget parentWidget =
       new WidgetRoot(new PagePointer(root, PathParser.parse("ParenT.ChilD")));
   AliasLinkWidget w = new AliasLinkWidget(parentWidget, "[[tag][ChildTwo]]");
   assertEquals("<a href=\"ParenT.ChildTwo\">tag</a>", w.render());
   AliasLinkWidget w2 = new AliasLinkWidget(new WidgetRoot(child), "[[tag][.ParenT]]");
   assertEquals("<a href=\"ParenT\">tag</a>", w2.render());
 }
 @Test
 public void testGetChidren() throws Exception {
   crawler.addPage(root, PathParser.parse("AaAa"), "A content");
   crawler.addPage(root, PathParser.parse("BbBb"), "B content");
   crawler.addPage(root, PathParser.parse("CcCc"), "C content");
   new File(defaultPath + "/root/someOtherDir").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) || "CcCc".equals(name);
     assertTrue("WikiPAge is not a valid one: " + name, isOk);
   }
 }
  @Test
  public void testHeadersAndFooters() throws Exception {
    WikiPageUtil.addPage(root, PathParser.parse("NormalPage"), "normal");
    WikiPageUtil.addPage(root, PathParser.parse("TestPage"), "test page");
    WikiPageUtil.addPage(root, PathParser.parse("PageHeader"), "header");
    WikiPageUtil.addPage(root, PathParser.parse("PageFooter"), "footer");
    WikiPageUtil.addPage(root, PathParser.parse("SetUp"), "setup");
    WikiPageUtil.addPage(root, PathParser.parse("TearDown"), "teardown");
    WikiPageUtil.addPage(root, PathParser.parse("SuiteSetUp"), "suite setup");
    WikiPageUtil.addPage(root, PathParser.parse("SuiteTearDown"), "suite teardown");

    SimpleResponse response = requestPage("NormalPage");
    String content = response.getContent();
    assertHasRegexp("header", content);
    assertHasRegexp("normal", content);
    assertHasRegexp("footer", content);
    assertDoesntHaveRegexp("setup", content);
    assertDoesntHaveRegexp("teardown", content);
    assertDoesntHaveRegexp("suite setup", content);
    assertDoesntHaveRegexp("suite teardown", content);

    response = requestPage("TestPage");
    content = response.getContent();
    assertHasRegexp("header", content);
    assertHasRegexp("test page", content);
    assertHasRegexp("footer", content);
    assertHasRegexp("setup", content);
    assertHasRegexp("teardown", content);
    assertHasRegexp("suite setup", content);
    assertHasRegexp("suite teardown", content);
  }
  @Before
  public void setUp() throws Exception {
    standardOutAndErrorRecorder = new StandardOutAndErrorRecorder();

    WikiPage root = InMemoryPage.makeRoot("RooT");
    pageOne = WikiPageUtil.addPage(root, PathParser.parse("PageOne"), "");
    childOne = WikiPageUtil.addPage(pageOne, PathParser.parse("ChildOne"), "");
    childTwo = WikiPageUtil.addPage(pageOne, PathParser.parse("ChildTwo"), "");

    mockWikiImporter = new MockWikiImporter();

    testResponder = new MockTestResponder(mockWikiImporter);

    testResponder.page = pageOne;
  }
Esempio n. 17
0
 protected String title() throws Exception {
   WikiPagePath fullPath = getPageCrawler().getFullPath(page);
   TagGroup group = new TagGroup();
   group.add(HtmlUtil.makeLink(PathParser.render(fullPath), page.getName()));
   group.add(HtmlUtil.makeItalic(pageType()));
   return group.html();
 }
Esempio n. 18
0
 public void testUparrowOnPageThatDoesNotExist() throws Exception {
   WikiPage page = crawler.addPage(root, PathParser.parse("FrontPage"));
   AliasLinkWidget w = new AliasLinkWidget(new WidgetRoot(page), "[[tag][^TestPage]]");
   assertEquals(
       "tag<a title=\"create page\" href=\"FrontPage.TestPage?edit&amp;nonExistent=true\">[?]</a>",
       w.render());
 }
  @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);
  }
Esempio n. 20
0
 protected String createRedirectionUrl(WikiPage newParent, String newName) throws Exception {
   PageCrawler crawler = newParent.getPageCrawler();
   if (crawler.isRoot(newParent)) {
     return newName;
   }
   return PathParser.render(crawler.getFullPath(newParent).addNameToEnd(newName));
 }
Esempio n. 21
0
 @Test
 public void testBreadCrumbsWithPageType() throws Exception {
   String trail = "TstPg1.TstPg2.TstPg3.TstPg4";
   page.setPageTitle(new PageTitle("Some Type", PathParser.parse(trail)));
   String breadcrumbs = page.html();
   assertSubString("<a href=\"/TstPg1.TstPg2.TstPg3.TstPg4\">TstPg4</a>", breadcrumbs);
 }
 @Before
 public void setUp() throws Exception {
   context = FitNesseUtil.makeTestContext();
   suite =
       WikiPageUtil.addPage(
           context.getRootPage(), PathParser.parse("SuitePage"), "This is the test suite\n");
 }
 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;
 }
Esempio n. 24
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());
 }
Esempio n. 25
0
 @Test
 public void testCreateBase() throws Exception {
   FileSystemPage levelA =
       (FileSystemPage) WikiPageUtil.addPage(root, PathParser.parse("PageA"), "");
   assertEquals(new File(defaultPath + "/RooT/PageA"), levelA.getFileSystemPath());
   assertTrue(new File(defaultPath + "/RooT/PageA").exists());
 }
Esempio n. 26
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()));
 }
Esempio n. 27
0
 public void testQuestionMarkDoesNotAppear() throws Exception {
   WikiPage page = crawler.addPage(root, PathParser.parse("FrontPage"));
   AliasLinkWidget w =
       new AliasLinkWidget(
           new WidgetRoot(page), "[[here][http://www.objectmentor.com/FitNesse/fitnesse.zip]]");
   assertDoesntHaveRegexp("[?]", w.render());
 }
Esempio n. 28
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()));
 }
  @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));
  }
Esempio n. 30
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()));
 }