Search in sources :

Example 1 with TemplateHandlerImpl

use of io.vertx.ext.web.handler.impl.TemplateHandlerImpl in project vertx-web by vert-x3.

the class TemplateHandlerImplTest method testTurnOffIndex.

@Test
public void testTurnOffIndex() {
    TemplateEngine templateEngine = mock(TemplateEngine.class);
    RoutingContext routingContext = mock(RoutingContext.class);
    when(routingContext.normalisedPath()).thenReturn("/");
    Route currentRoute = mock(Route.class);
    when(currentRoute.getPath()).thenReturn("/");
    when(routingContext.currentRoute()).thenReturn(currentRoute);
    TemplateHandler templateHandler = new TemplateHandlerImpl(templateEngine, "templates", "ext");
    templateHandler.setIndexTemplate(null);
    templateHandler.handle(routingContext);
    verify(templateEngine).render(any(), eq("templates"), eq("/"), any());
}
Also used : TemplateEngine(io.vertx.ext.web.templ.TemplateEngine) TemplateHandlerImpl(io.vertx.ext.web.handler.impl.TemplateHandlerImpl) RoutingContext(io.vertx.ext.web.RoutingContext) TemplateHandler(io.vertx.ext.web.handler.TemplateHandler) Route(io.vertx.ext.web.Route) Test(org.junit.Test)

Example 2 with TemplateHandlerImpl

use of io.vertx.ext.web.handler.impl.TemplateHandlerImpl in project vertx-web by vert-x3.

the class TemplateHandlerImplTest method testSimpleTemplate.

@Test
public void testSimpleTemplate() {
    TemplateEngine templateEngine = mock(TemplateEngine.class);
    RoutingContext routingContext = mock(RoutingContext.class);
    when(routingContext.normalisedPath()).thenReturn("/about");
    Route currentRoute = mock(Route.class);
    when(currentRoute.getPath()).thenReturn("/");
    when(routingContext.currentRoute()).thenReturn(currentRoute);
    TemplateHandler templateHandler = new TemplateHandlerImpl(templateEngine, "templates", "ext");
    templateHandler.handle(routingContext);
    verify(templateEngine).render(any(), eq("templates"), eq("/about"), any());
}
Also used : TemplateEngine(io.vertx.ext.web.templ.TemplateEngine) TemplateHandlerImpl(io.vertx.ext.web.handler.impl.TemplateHandlerImpl) RoutingContext(io.vertx.ext.web.RoutingContext) TemplateHandler(io.vertx.ext.web.handler.TemplateHandler) Route(io.vertx.ext.web.Route) Test(org.junit.Test)

Example 3 with TemplateHandlerImpl

use of io.vertx.ext.web.handler.impl.TemplateHandlerImpl in project vertx-web by vert-x3.

the class TemplateHandlerImplTest method testDefaultIndex.

@Test
public void testDefaultIndex() {
    TemplateEngine templateEngine = mock(TemplateEngine.class);
    RoutingContext routingContext = mock(RoutingContext.class);
    when(routingContext.normalisedPath()).thenReturn("/");
    Route currentRoute = mock(Route.class);
    when(currentRoute.getPath()).thenReturn("/");
    when(routingContext.currentRoute()).thenReturn(currentRoute);
    TemplateHandler templateHandler = new TemplateHandlerImpl(templateEngine, "templates", "ext");
    templateHandler.handle(routingContext);
    verify(templateEngine).render(any(), eq("templates"), eq("/index"), any());
}
Also used : TemplateEngine(io.vertx.ext.web.templ.TemplateEngine) TemplateHandlerImpl(io.vertx.ext.web.handler.impl.TemplateHandlerImpl) RoutingContext(io.vertx.ext.web.RoutingContext) TemplateHandler(io.vertx.ext.web.handler.TemplateHandler) Route(io.vertx.ext.web.Route) Test(org.junit.Test)

Example 4 with TemplateHandlerImpl

use of io.vertx.ext.web.handler.impl.TemplateHandlerImpl in project vertx-web by vert-x3.

the class TemplateHandlerImplTest method testSetIndex.

@Test
public void testSetIndex() {
    TemplateEngine templateEngine = mock(TemplateEngine.class);
    RoutingContext routingContext = mock(RoutingContext.class);
    when(routingContext.normalisedPath()).thenReturn("/");
    Route currentRoute = mock(Route.class);
    when(currentRoute.getPath()).thenReturn("/");
    when(routingContext.currentRoute()).thenReturn(currentRoute);
    TemplateHandler templateHandler = new TemplateHandlerImpl(templateEngine, "templates", "ext");
    templateHandler.setIndexTemplate("home");
    templateHandler.handle(routingContext);
    verify(templateEngine).render(any(), eq("templates"), eq("/home"), any());
}
Also used : TemplateEngine(io.vertx.ext.web.templ.TemplateEngine) TemplateHandlerImpl(io.vertx.ext.web.handler.impl.TemplateHandlerImpl) RoutingContext(io.vertx.ext.web.RoutingContext) TemplateHandler(io.vertx.ext.web.handler.TemplateHandler) Route(io.vertx.ext.web.Route) Test(org.junit.Test)

Aggregations

Route (io.vertx.ext.web.Route)4 RoutingContext (io.vertx.ext.web.RoutingContext)4 TemplateHandler (io.vertx.ext.web.handler.TemplateHandler)4 TemplateHandlerImpl (io.vertx.ext.web.handler.impl.TemplateHandlerImpl)4 TemplateEngine (io.vertx.ext.web.templ.TemplateEngine)4 Test (org.junit.Test)4