本文整理匯總了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();
}