use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class ExceptionRendererImplTest method render_with_tip.
@Test
void render_with_tip() {
this.renderer = new ExceptionRendererImpl(resourceService, errorHandlerScriptFactory, contentService, null, postProcessor);
this.request.getHeaders().put(HttpHeaders.ACCEPT, "text/html,text/*");
this.request.setBaseUri("/site");
this.request.setBranch(Branch.from("master"));
final PortalResponse res = this.renderer.render(this.request, new WebException(HttpStatus.NOT_FOUND, "Custom message"));
assertEquals(HttpStatus.NOT_FOUND, res.getStatus());
assertEquals(MediaType.HTML_UTF_8.withoutParameters(), res.getContentType());
final String body = res.getBody().toString();
assertThat(body).contains("404 - Not Found");
assertThat(body).doesNotContain("Custom message");
assertThat(body).contains("Tip: Did you remember to publish the site?");
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class MappingHandlerTest method testNoMatch_no_site_based.
@Test
public void testNoMatch_no_site_based() throws Exception {
final WebHandlerChain chain = mock(WebHandlerChain.class);
final PortalResponse response = PortalResponse.create().build();
this.request.setContentPath(ContentPath.from("/site/content"));
this.request.setBaseUri("/something");
this.handler.handle(this.request, response, chain);
verify(chain).handle(this.request, response);
verifyNoInteractions(rendererDelegate);
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class MappingHandlerTest method testNoMatch_endpointPath.
@Test
public void testNoMatch_endpointPath() throws Exception {
this.request.setEndpointPath("something");
final WebHandlerChain chain = mock(WebHandlerChain.class);
final PortalResponse response = PortalResponse.create().build();
this.handler.handle(this.request, response, chain);
verify(chain).handle(this.request, response);
verifyNoInteractions(rendererDelegate);
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class MappingHandlerTest method executeNothing.
@Test
public void executeNothing() throws Exception {
final ResourceKey controller = ResourceKey.from("demo:/services/test");
final ControllerMappingDescriptor mapping = ControllerMappingDescriptor.create().controller(controller).pattern("/nomatch").build();
setupContentAndSite(mapping);
final WebHandlerChain chain = mock(WebHandlerChain.class);
final PortalResponse response = PortalResponse.create().build();
this.request.setBaseUri("/site");
this.request.setContentPath(ContentPath.from("/site/somesite/content"));
this.handler.handle(this.request, response, chain);
verify(chain).handle(this.request, response);
verifyNoInteractions(rendererDelegate);
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class MacroProcessorScriptTest method testMissingMacro.
@Test
public void testMissingMacro() {
final PortalResponse response = execute("myapplication:/macro/missing-macro.js");
assertNull(response);
}
Aggregations