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());
}
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());
}
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());
}
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());
}
Aggregations