use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class PebbleTemplateTest method testNoSuchTemplate.
@Test
public void testNoSuchTemplate(TestContext should) {
TemplateEngine engine = PebbleTemplateEngine.create(vertx);
final JsonObject context = new JsonObject();
engine.render(context, "non-existing", should.asyncAssertFailure());
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class ThymeleafTemplateNoCacheTest method testCachingDisabled.
@Test
public void testCachingDisabled(TestContext should) throws IOException {
System.setProperty("vertxweb.environment", "development");
TemplateEngine engine = ThymeleafTemplateEngine.create(vertx);
File temp = File.createTempFile("template", ".html", new File("target/classes"));
temp.deleteOnExit();
try (PrintWriter out = new PrintWriter(temp)) {
out.print("before");
out.flush();
}
engine.render(new JsonObject(), temp.getParent() + "/" + temp.getName(), should.asyncAssertSuccess(render -> {
should.assertEquals("before", ThymeleafTemplateTest.normalizeCRLF(render.toString()));
try (PrintWriter out2 = new PrintWriter(temp)) {
out2.print("after");
out2.flush();
} catch (IOException e) {
should.fail(e);
}
engine.render(new JsonObject(), temp.getParent() + "/" + temp.getName(), should.asyncAssertSuccess(render2 -> {
should.assertEquals("after", ThymeleafTemplateTest.normalizeCRLF(render2.toString()));
}));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class RockerTemplateEngineTest method testNoSuchTemplate.
@Test
public void testNoSuchTemplate(TestContext should) {
TemplateEngine engine = RockerTemplateEngine.create();
final JsonObject context = new JsonObject();
engine.render(context, "nosuchtemplate.rocker.html", should.asyncAssertFailure());
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class RockerTemplateEngineTest method testTemplateHandlerNoExtension.
@Test
public void testTemplateHandlerNoExtension(TestContext should) {
TemplateEngine engine = RockerTemplateEngine.create();
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox").put("context", new JsonObject().put("path", "/TestRockerTemplate2"));
engine.render(context, "somedir/TestRockerTemplate2", should.asyncAssertSuccess(render -> {
should.assertEquals("Hello badger and fox\nRequest path is /TestRockerTemplate2\n", normalizeCRLF(render.toString()));
}));
}
use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.
the class RockerTemplateEngineTest method testTemplateHandlerChangeExtension.
@Test
public void testTemplateHandlerChangeExtension(TestContext should) {
TemplateEngine engine = RockerTemplateEngine.create("rocker.raw");
final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox").put("context", new JsonObject().put("path", "/TestRockerTemplate3"));
engine.render(context, "somedir/TestRockerTemplate3", should.asyncAssertSuccess(render -> {
should.assertEquals("\nCheerio badger and fox\nRequest path is /TestRockerTemplate3\n", normalizeCRLF(render.toString()));
}));
}
Aggregations