@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); } }
@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); } }