Example #1
0
  private String doRunAndGetErrorLog(String content) throws Exception {
    WikiPage testPage = crawler.addPage(root, PathParser.parse("TestPage"), content);
    request.setResource(testPage.getName());

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

    assertHasRegexp("ErrorLog", results);

    WikiPage errorLog = errorLogsParentPage.getChildPage(testPage.getName());
    return errorLog.getData().getContent();
  }
 private WikiPage getPropertiesContentFromPage(WikiPage page) throws Exception {
   request = new MockRequest();
   request.setResource(page.getName());
   responder = new PropertiesResponder();
   SimpleResponse response =
       (SimpleResponse) responder.makeResponse(new FitNesseContext(root), request);
   content = response.getContent();
   return page;
 }
Example #3
0
  @Test
  public void testSimpleRun() throws Exception {
    doSimpleRun(passFixtureTable());

    assertSubString(testPage.getName(), results);
    assertSubString("Test Results", results);
    assertSubString("class", results);
    assertNotSubString("ClassNotFoundException", results);
  }
  protected void movePage(WikiPage movedPage, WikiPage targetPage) throws Exception {
    PageData pageData = movedPage.getData();

    targetPage.commit(pageData);

    moveChildren(movedPage, targetPage);

    WikiPage parentOfMovedPage = movedPage.getParent();
    parentOfMovedPage.removeChildPage(movedPage.getName());
  }
  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());
  }
 public void pageImportError(WikiPage localPage, Exception e) throws Exception {
   errorOccured = true;
   System.out.println(
       "Exception while importing \"local page\": "
           + localPage.getName()
           + ", exception: "
           + e.getMessage());
   if (e.getCause() != null) System.out.println("  cause: " + e.getCause().getMessage());
   e.printStackTrace(System.out);
   testResponder.addToResponse(e.toString());
 }
Example #7
0
  @Test
  public void testHasExitValueHeader() throws Exception {
    WikiPage testPage =
        crawler.addPage(
            root, PathParser.parse("TestPage"), classpathWidgets() + passFixtureTable());
    request.setResource(testPage.getName());

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

    assertSubString("Exit-Code: 0", results);
  }
 @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);
   }
 }
Example #9
0
  @Test
  public void testFixtureThatCrashes() throws Exception {
    responder.setFastTest(false);
    WikiPage testPage =
        crawler.addPage(
            root, PathParser.parse("TestPage"), classpathWidgets() + crashFixtureTable());
    request.setResource(testPage.getName());

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

    String results = sender.sentData();
    assertSubString("ErrorLog", results);
  }
Example #10
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);
  }
Example #11
0
  private void doSimpleRunWithTags(String fixtureTable, String tags) throws Exception {
    String simpleRunPageName = "TestPage";
    testPage =
        crawler.addPage(
            root, PathParser.parse(simpleRunPageName), classpathWidgets() + fixtureTable);
    if (tags != null) {
      PageData pageData = testPage.getData();
      pageData.setAttribute(PageData.PropertySUITES, tags);
      testPage.commit(pageData);
    }
    request.setResource(testPage.getName());

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

    results = sender.sentData();
  }
Example #12
0
 @Override
 public String getName() {
   return sourcePage.getName();
 }
Example #13
0
 protected void moveChildren(WikiPage movedPage, WikiPage newParentPage) throws Exception {
   List<WikiPage> children = movedPage.getChildren();
   for (WikiPage page : children) {
     movePage(page, newParentPage.addChildPage(page.getName()));
   }
 }
Example #14
0
 protected void writeHead(WikiPage testPage) {
   testResponse.version = new FitNesseVersion().toString();
   testResponse.rootPath = testPage.getName();
 }
Example #15
0
 @Override
 public void testComplete(WikiPage test, TestSummary testSummary, TimeMeasurement timeMeasurement)
     throws IOException {
   super.testComplete(test, testSummary, timeMeasurement);
   processTestResults(test.getName(), testSummary, timeMeasurement);
 }