本文整理汇总了Java中org.jbake.app.DBUtil类的典型用法代码示例。如果您正苦于以下问题:Java DBUtil类的具体用法?Java DBUtil怎么用?Java DBUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DBUtil类属于org.jbake.app包,在下文中一共展示了DBUtil类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderSitemap
import org.jbake.app.DBUtil; //导入依赖的package包/类
@Test
public void renderSitemap() throws Exception {
DocumentTypes.addDocumentType("paper");
DBUtil.updateSchema(db);
renderer.renderSitemap("sitemap.xml");
File outputFile = new File(destinationFolder, "sitemap.xml");
Assert.assertTrue(outputFile.exists());
// verify
String output = FileUtils.readFileToString(outputFile, Charset.defaultCharset());
for (String string : getOutputStrings("sitemap")) {
assertThat(output).contains(string);
}
assertThat(output).doesNotContain("draft-paper.html");
}
示例2: renderCustomTypePaper
import org.jbake.app.DBUtil; //导入依赖的package包/类
@Test
public void renderCustomTypePaper() throws Exception {
// setup
config.setProperty("template.paper.file", "paper." + templateExtension);
DocumentTypes.addDocumentType("paper");
DBUtil.updateSchema(db);
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 = "published-paper.html";
File sampleFile = new File(sourceFolder.getPath() + File.separator + "content" + File.separator + "papers" + 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("paper")) {
assertThat(output).contains(string);
}
}
示例3: renderCustomTypePaper
import org.jbake.app.DBUtil; //导入依赖的package包/类
@Test
public void renderCustomTypePaper() throws Exception {
// setup
config.setProperty("template.paper.file", "paper." + templateExtension);
DocumentTypes.addDocumentType("paper");
DBUtil.updateSchema(db);
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 = "published-paper.html";
File sampleFile = new File(sourceFolder.getPath() + File.separator + "content" + File.separator + "papers" + 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("paper")) {
assertThat(output).contains(string);
}
}
示例4: setup
import org.jbake.app.DBUtil; //导入依赖的package包/类
@Before
public void setup() throws Exception {
currentLocale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
ModelExtractorsDocumentTypeListener listener = new ModelExtractorsDocumentTypeListener();
DocumentTypes.addListener(listener);
URL sourceUrl = this.getClass().getResource("/");
sourceFolder = new File(sourceUrl.getFile());
if (!sourceFolder.exists()) {
throw new Exception("Cannot find sample data structure!");
}
destinationFolder = folder.getRoot();
templateFolder = new File(sourceFolder, templateDir);
if (!templateFolder.exists()) {
throw new Exception("Cannot find template folder!");
}
config = ConfigUtil.load(new File(this.getClass().getResource("/").getFile()));
Iterator<String> keys = config.getKeys();
while (keys.hasNext()) {
String key = keys.next();
if (key.startsWith("template") && key.endsWith(".file")) {
String old = (String) config.getProperty(key);
config.setProperty(key, old.substring(0, old.length() - 4) + "." + templateExtension);
}
}
Assert.assertEquals(".html", config.getString(ConfigUtil.Keys.OUTPUT_EXTENSION));
db = DBUtil.createDataStore("memory", "documents"+System.currentTimeMillis());
crawler = new Crawler(db, sourceFolder, config);
crawler.crawl(new File(sourceFolder.getPath() + File.separator + "content"));
parser = new Parser(config, sourceFolder.getPath());
renderer = new Renderer(db, destinationFolder, templateFolder, config);
setupExpectedOutputStrings();
}