Search in sources :

Example 26 with TemplateEngine

use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.

the class HTTLTemplateEngineTest method testTemplateHandlerNoExtension.

@Test
public void testTemplateHandlerNoExtension(TestContext should) {
    TemplateEngine engine = HTTLTemplateEngine.create(vertx);
    final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
    engine.render(context, "somedir/test-httl-template1", should.asyncAssertSuccess(render -> {
        should.assertEquals("<!--  -->\nHello badger and fox\n", normalizeCRLF(render.toString()));
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) PrintWriter(java.io.PrintWriter) BeforeClass(org.junit.BeforeClass) FileSystemOptions(io.vertx.core.file.FileSystemOptions) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) Vertx(io.vertx.core.Vertx) RunWith(org.junit.runner.RunWith) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) IOException(java.io.IOException) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) File(java.io.File) HTTLTemplateEngine(io.vertx.ext.web.templ.httl.HTTLTemplateEngine) JsonObject(io.vertx.core.json.JsonObject) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) HTTLTemplateEngine(io.vertx.ext.web.templ.httl.HTTLTemplateEngine) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 27 with TemplateEngine

use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.

the class HTTLTemplateEngineTest method testTemplateHandlerChangeExtension.

@Test
public void testTemplateHandlerChangeExtension(TestContext should) {
    TemplateEngine engine = HTTLTemplateEngine.create(vertx, "mvl");
    final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
    engine.render(context, "somedir/test-httl-template1", should.asyncAssertSuccess(render -> {
        should.assertEquals("<!--  -->\nCheerio badger and fox\n", normalizeCRLF(render.toString()));
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) PrintWriter(java.io.PrintWriter) BeforeClass(org.junit.BeforeClass) FileSystemOptions(io.vertx.core.file.FileSystemOptions) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) Vertx(io.vertx.core.Vertx) RunWith(org.junit.runner.RunWith) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) IOException(java.io.IOException) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) File(java.io.File) HTTLTemplateEngine(io.vertx.ext.web.templ.httl.HTTLTemplateEngine) JsonObject(io.vertx.core.json.JsonObject) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) HTTLTemplateEngine(io.vertx.ext.web.templ.httl.HTTLTemplateEngine) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 28 with TemplateEngine

use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.

the class FreeMarkerTemplateTest method testTemplateHandlerNoExtension.

@Test
public void testTemplateHandlerNoExtension(TestContext should) {
    TemplateEngine engine = FreeMarkerTemplateEngine.create(vertx);
    final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
    context.put("context", new JsonObject().put("path", "/test-freemarker-template2.ftl"));
    engine.render(context, "somedir/test-freemarker-template2", should.asyncAssertSuccess(render -> {
        should.assertEquals("Hello badger and fox\nRequest path is /test-freemarker-template2.ftl\n", normalizeCRLF(render.toString()));
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) PrintWriter(java.io.PrintWriter) BeforeClass(org.junit.BeforeClass) FileSystemOptions(io.vertx.core.file.FileSystemOptions) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) Vertx(io.vertx.core.Vertx) RunWith(org.junit.runner.RunWith) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) IOException(java.io.IOException) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) File(java.io.File) FreeMarkerTemplateEngine(io.vertx.ext.web.templ.freemarker.FreeMarkerTemplateEngine) JsonObject(io.vertx.core.json.JsonObject) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) FreeMarkerTemplateEngine(io.vertx.ext.web.templ.freemarker.FreeMarkerTemplateEngine) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 29 with TemplateEngine

use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.

the class FreeMarkerTemplateTest method testTemplateHandlerChangeExtension.

@Test
public void testTemplateHandlerChangeExtension(TestContext should) {
    TemplateEngine engine = FreeMarkerTemplateEngine.create(vertx, "mvl");
    final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
    context.put("context", new JsonObject().put("path", "/test-freemarker-template2.ftl"));
    engine.render(context, "somedir/test-freemarker-template2", should.asyncAssertSuccess(render -> {
        should.assertEquals("Cheerio badger and fox\nRequest path is /test-freemarker-template2.ftl\n", normalizeCRLF(render.toString()));
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) PrintWriter(java.io.PrintWriter) BeforeClass(org.junit.BeforeClass) FileSystemOptions(io.vertx.core.file.FileSystemOptions) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) Vertx(io.vertx.core.Vertx) RunWith(org.junit.runner.RunWith) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) IOException(java.io.IOException) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) File(java.io.File) FreeMarkerTemplateEngine(io.vertx.ext.web.templ.freemarker.FreeMarkerTemplateEngine) JsonObject(io.vertx.core.json.JsonObject) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) FreeMarkerTemplateEngine(io.vertx.ext.web.templ.freemarker.FreeMarkerTemplateEngine) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 30 with TemplateEngine

use of io.vertx.ext.web.common.template.TemplateEngine in project vertx-web by vert-x3.

the class JadeTemplateTest method testTemplateHandlerNoExtension.

@Test
public void testTemplateHandlerNoExtension(TestContext should) {
    TemplateEngine engine = JadeTemplateEngine.create(vertx);
    final JsonObject context = new JsonObject().put("foo", "badger").put("bar", "fox");
    context.put("context", new JsonObject().put("path", "/test-jade-template2.jade"));
    engine.render(context, "somedir/test-jade-template2", should.asyncAssertSuccess(render -> {
        should.assertEquals("<!DOCTYPE html><html><head><title>badger/test-jade-template2.jade</title></head><body></body></html>", normalizeCRLF(render.toString()));
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) PrintWriter(java.io.PrintWriter) BeforeClass(org.junit.BeforeClass) FileSystemOptions(io.vertx.core.file.FileSystemOptions) Assert.assertNotNull(org.junit.Assert.assertNotNull) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) Vertx(io.vertx.core.Vertx) RunWith(org.junit.runner.RunWith) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test) IOException(java.io.IOException) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) JadeTemplateEngine(io.vertx.ext.web.templ.jade.JadeTemplateEngine) File(java.io.File) JsonObject(io.vertx.core.json.JsonObject) TemplateEngine(io.vertx.ext.web.common.template.TemplateEngine) JadeTemplateEngine(io.vertx.ext.web.templ.jade.JadeTemplateEngine) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Aggregations

TemplateEngine (io.vertx.ext.web.common.template.TemplateEngine)75 Test (org.junit.Test)74 JsonObject (io.vertx.core.json.JsonObject)70 TestContext (io.vertx.ext.unit.TestContext)57 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)57 RunWith (org.junit.runner.RunWith)57 File (java.io.File)53 IOException (java.io.IOException)53 PrintWriter (java.io.PrintWriter)53 Vertx (io.vertx.core.Vertx)52 VertxOptions (io.vertx.core.VertxOptions)52 FileSystemOptions (io.vertx.core.file.FileSystemOptions)52 BeforeClass (org.junit.BeforeClass)52 JsonArray (io.vertx.core.json.JsonArray)16 PebbleTemplateEngine (io.vertx.ext.web.templ.pebble.PebbleTemplateEngine)13 PebbleEngine (com.mitchellbosecke.pebble.PebbleEngine)11 TestExtension (io.vertx.ext.web.templ.extension.TestExtension)11 PebbleVertxLoader (io.vertx.ext.web.templ.pebble.impl.PebbleVertxLoader)11 ArrayList (java.util.ArrayList)11 Assert.assertNotNull (org.junit.Assert.assertNotNull)10