コード例 #1
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());
  }
コード例 #2
0
ファイル: TestResponderTest.java プロジェクト: xjie/fitnesse
  @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);
  }
コード例 #3
0
 @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());
 }
コード例 #4
0
ファイル: TestResponderTest.java プロジェクト: xjie/fitnesse
 @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);
 }
コード例 #5
0
ファイル: PageCrawlerTest.java プロジェクト: smryoo/fitnesse
  public void testRecursiveAddbyName() throws Exception {
    crawler.addPage(root, PathParser.parse("AaAa"), "its content");
    assertTrue(root.hasChildPage("AaAa"));

    crawler.addPage(root, PathParser.parse("AaAa.BbBb"), "floop");
    assertTrue(crawler.pageExists(root, PathParser.parse("AaAa.BbBb")));
    assertEquals(
        "floop", crawler.getPage(root, PathParser.parse("AaAa.BbBb")).getData().getContent());
  }
コード例 #6
0
 @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());
 }
コード例 #7
0
ファイル: PageCrawlerTest.java プロジェクト: smryoo/fitnesse
  public void testPageExistsUsingPath() throws Exception {
    assertTrue(crawler.pageExists(page1, PathParser.parse("ChildOne")));
    assertTrue(crawler.pageExists(root, child1FullPath));
    assertTrue(crawler.pageExists(root, grandChild1FullPath));
    assertTrue(crawler.pageExists(root, PathParser.parse(".PageOne")));
    assertTrue(crawler.pageExists(root, PathParser.parse(".PageOne.ChildOne.GrandChildOne")));

    assertFalse(crawler.pageExists(page1, PathParser.parse("BlahBlah")));
    assertFalse(crawler.pageExists(page1, PathParser.parse("PageOne.BlahBlah")));
  }
コード例 #8
0
 @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());
 }
コード例 #9
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());
 }
コード例 #10
0
 @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);
   }
 }
コード例 #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()));
 }
コード例 #12
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()));
 }
コード例 #13
0
ファイル: PageCrawlerTest.java プロジェクト: smryoo/fitnesse
 public void testGetFullPath() throws Exception {
   assertEquals(page1Path, crawler.getFullPath(page1));
   assertEquals(page2Path, crawler.getFullPath(page2));
   assertEquals(child1FullPath, crawler.getFullPath(child1));
   assertEquals(grandChild1FullPath, crawler.getFullPath(grandChild1));
   assertEquals(PathParser.parse(""), crawler.getFullPath(root));
 }
コード例 #14
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());
 }
コード例 #15
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());
 }
コード例 #16
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()));
 }
コード例 #17
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);
 }
コード例 #18
0
  @Before
  public void setUp() throws Exception {
    fileSystem = new MemoryFileSystem();
    context = FitNesseUtil.makeTestContext(fileSystem);
    root = context.getRootPage(); // #  root
    pageOne = WikiPageUtil.addPage(root, PathParser.parse("PageOne"), ""); // #    |--PageOne
    WikiPageUtil.addPage(
        pageOne, PathParser.parse("ChildOne"), "ChildOne"); // #    |    `--ChildOne
    WikiPage pageTwo = WikiPageUtil.addPage(root, PathParser.parse("PageTwo"), "");
    childTwo =
        WikiPageUtil.addPage(pageTwo, PathParser.parse("ChildTwo"), ""); // #         |--ChildTwo
    WikiPageUtil.addPage(pageTwo, PathParser.parse("ChildThree"), ""); // #         `--ChildThree

    request = new MockRequest();
    request.setResource("PageOne");
    responder = new SymbolicLinkResponder(fileSystem);
  }
コード例 #19
0
 @Test
 public void testBigContent() throws Exception {
   StringBuffer buffer = new StringBuffer();
   for (int i = 0; i < 1000; i++) buffer.append("abcdefghijklmnopqrstuvwxyz");
   crawler.addPage(root, PathParser.parse("BigPage"), buffer.toString());
   String content = root.getChildPage("BigPage").getData().getContent();
   assertTrue(buffer.toString().equals(content));
 }
コード例 #20
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"));
 }
コード例 #21
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"));
 }
コード例 #22
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);
 }
コード例 #23
0
ファイル: TestResponderTest.java プロジェクト: xjie/fitnesse
  @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);
  }
コード例 #24
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;
  }
コード例 #25
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));
  }
コード例 #26
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()));
 }
コード例 #27
0
 @Test
 public void testLoadChildrenWhenPageIsDeletedManualy() throws Exception {
   WikiPage page = crawler.addPage(root, PathParser.parse("TestPage"));
   page.getChildren();
   FileUtil.deleteFileSystemDirectory(((FileSystemPage) page).getFileSystemPath());
   try {
     page.getChildren();
   } catch (Exception e) {
     fail("No Exception should be thrown");
   }
 }
コード例 #28
0
ファイル: PageCrawlerTest.java プロジェクト: smryoo/fitnesse
  public void testGetAbsolutePathForChild() throws Exception {
    WikiPagePath somePagePath = PathParser.parse("SomePage");
    WikiPagePath somePageFullPath = crawler.getFullPathOfChild(root, somePagePath);
    assertEquals("SomePage", PathParser.render(somePageFullPath));

    WikiPagePath pageOnePath = page1Path;
    WikiPagePath pageOneFullPath = crawler.getFullPathOfChild(root, pageOnePath);
    assertEquals("PageOne", PathParser.render(pageOneFullPath));

    WikiPagePath SomePageChildFullPath = crawler.getFullPathOfChild(child1, somePagePath);
    assertEquals("PageOne.ChildOne.SomePage", PathParser.render(SomePageChildFullPath));

    WikiPagePath otherPagePath = PathParser.parse("SomePage.OtherPage");
    WikiPagePath otherPageFullPath = crawler.getFullPathOfChild(root, otherPagePath);
    assertEquals("SomePage.OtherPage", PathParser.render(otherPageFullPath));

    WikiPagePath somePageAbsolutePath = PathParser.parse(".SomePage");
    WikiPagePath somePageAbsoluteFullPath =
        crawler.getFullPathOfChild(child1, somePageAbsolutePath);
    assertEquals("SomePage", PathParser.render(somePageAbsoluteFullPath));
  }
コード例 #29
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;
  }
コード例 #30
0
  @Test
  public void testAddFailWhenPageAlreadyHasNonSymChild() throws Exception {
    WikiPageUtil.addPage(pageOne, PathParser.parse("SymLink"), "");

    request.addInput("linkName", "SymLink");
    request.addInput("linkPath", "PageTwo");
    Response response = invokeResponder();

    assertEquals(412, response.getStatus());
    String content = ((SimpleResponse) response).getContent();
    assertSubString("already has a child named SymLink", content);
    assertSubString("Error Occurred", content);
  }