예제 #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
  @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);
  }
  /**
   * Setup the Animator to achieve path morphing.
   *
   * @param anim The target Animator which will be updated.
   * @param arrayAnimator TypedArray for the ValueAnimator.
   * @return the PathDataEvaluator.
   */
  private static TypeEvaluator setupAnimatorForPath(ValueAnimator anim, TypedArray arrayAnimator) {
    TypeEvaluator evaluator = null;
    String fromString = arrayAnimator.getString(R.styleable.Animator_vc_valueFrom);
    String toString = arrayAnimator.getString(R.styleable.Animator_vc_valueTo);
    PathParser.PathDataNode[] nodesFrom = PathParser.createNodesFromPathData(fromString);
    PathParser.PathDataNode[] nodesTo = PathParser.createNodesFromPathData(toString);

    if (nodesFrom != null) {
      if (nodesTo != null) {
        anim.setObjectValues(nodesFrom, nodesTo);
        if (!PathParser.canMorph(nodesFrom, nodesTo)) {
          throw new InflateException(
              arrayAnimator.getPositionDescription()
                  + " Can't morph from "
                  + fromString
                  + " to "
                  + toString);
        }
      } else {
        anim.setObjectValues((Object) nodesFrom);
      }
      evaluator = new PathDataEvaluator(PathParser.deepCopyNodes(nodesFrom));
    } else if (nodesTo != null) {
      anim.setObjectValues((Object) nodesTo);
      evaluator = new PathDataEvaluator(PathParser.deepCopyNodes(nodesTo));
    }

    if (DBG_ANIMATOR_INFLATER && evaluator != null) {
      Log.v(LOG_TAG, "create a new PathDataEvaluator here");
    }

    return evaluator;
  }
 @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());
 }
예제 #5
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);
 }
예제 #6
0
  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());
  }
예제 #7
0
  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")));
  }
 @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());
 }
예제 #10
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());
 }
 @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);
   }
 }
예제 #12
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()));
 }
예제 #13
0
 public String getLocalPageName() {
   if (page != null) {
     WikiPagePath localPagePath = page.getPageCrawler().getFullPath(page);
     return PathParser.render(localPagePath);
   }
   return null;
 }
예제 #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 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
 @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()));
 }
예제 #18
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();
 }
예제 #19
0
 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));
 }
  @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);
  }
예제 #21
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"));
 }
 @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));
 }
 @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"));
 }
예제 #25
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);
  }
예제 #26
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);
 }
예제 #27
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));
  }
예제 #28
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;
  }
예제 #29
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()));
 }
 @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");
   }
 }