コード例 #1
0
  @Test
  public void renderPost() throws Exception {
    // setup
    String filename = "second-post.html";

    File sampleFile =
        new File(
            sourceFolder.getPath()
                + File.separator
                + "content"
                + File.separator
                + "blog"
                + File.separator
                + "2013"
                + File.separator
                + filename);
    Map<String, Object> content = parser.processFile(sampleFile);
    content.put(Crawler.Attributes.URI, "/" + filename);
    renderer.render(content);
    File outputFile = new File(destinationFolder, filename);
    Assert.assertTrue(outputFile.exists());

    // verify
    String output = FileUtils.readFileToString(outputFile, Charset.defaultCharset());
    for (String string : getOutputStrings("post")) {
      assertThat(output).contains(string);
    }
  }
コード例 #2
0
  @Test
  public void renderPage() throws Exception {
    // setup
    Crawler crawler = new Crawler(db, sourceFolder, config);
    crawler.crawl(new File(sourceFolder.getPath() + File.separator + "content"));
    Parser parser = new Parser(config, sourceFolder.getPath());
    Renderer renderer = new Renderer(db, destinationFolder, templateFolder, config);
    String filename = "about.html";

    File sampleFile =
        new File(sourceFolder.getPath() + File.separator + "content" + File.separator + filename);
    Map<String, Object> content = parser.processFile(sampleFile);
    content.put(Crawler.Attributes.URI, "/" + filename);
    renderer.render(content);
    File outputFile = new File(destinationFolder, filename);
    Assert.assertTrue(outputFile.exists());

    // verify
    String output = FileUtils.readFileToString(outputFile);
    for (String string : getOutputStrings("page")) {
      assertThat(output).contains(string);
    }
  }