use of com.enonic.xp.web.handler.WebHandlerChain in project xp by enonic.
the class FilterScriptImplTest method testNoFilterFunction.
@Test
public void testNoFilterFunction() throws Exception {
WebHandlerChain webHandlerChain = Mockito.mock(WebHandlerChain.class);
Mockito.when(webHandlerChain.handle(Mockito.any(), Mockito.any())).thenReturn(this.portalResponse);
this.portalRequest.setMethod(HttpMethod.POST);
try {
execute("myapplication:/filter/nofilter.js", webHandlerChain);
fail("Expected exception");
} catch (WebException e) {
assertEquals("Missing exported function 'filter' in filter script: myapplication:/filter/nofilter.js", e.getMessage());
}
}
use of com.enonic.xp.web.handler.WebHandlerChain 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.web.handler.WebHandlerChain 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.web.handler.WebHandlerChain 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.web.handler.WebHandlerChain in project xp by enonic.
the class FilterScriptImplTest method testHandleException.
@Test
public void testHandleException() throws Exception {
WebHandlerChain webHandlerChain = Mockito.mock(WebHandlerChain.class);
Mockito.when(webHandlerChain.handle(Mockito.any(), Mockito.any())).thenThrow(Exception.class);
final ResourceProblemException exception = Assertions.assertThrows(ResourceProblemException.class, () -> execute("myapplication:/filter/callnext.js", webHandlerChain));
assertEquals("Error executing filter script: myapplication:/filter/callnext.js", exception.getMessage());
Mockito.verify(webHandlerChain, Mockito.times(1)).handle(Mockito.any(), Mockito.any());
}
Aggregations