use of com.enonic.xp.web.handler.WebHandlerChain in project xp by enonic.
the class FilterScriptImplTest method testNextFilter.
@Test
public void testNextFilter() throws Exception {
WebHandlerChain webHandlerChain = Mockito.mock(WebHandlerChain.class);
Mockito.when(webHandlerChain.handle(Mockito.any(), Mockito.any())).thenReturn(this.portalResponse);
this.portalRequest.setMethod(HttpMethod.POST);
execute("myapplication:/filter/callnext.js", webHandlerChain);
assertEquals(HttpStatus.OK, this.portalResponse.getStatus());
}
use of com.enonic.xp.web.handler.WebHandlerChain in project xp by enonic.
the class FilterScriptImplTest method testDuplicatedNextCall.
@Test
public void testDuplicatedNextCall() 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/duplicated_next_call.js", webHandlerChain);
fail("Expected exception");
} catch (ResourceProblemException e) {
assertEquals("myapplication:/filter/duplicated_next_call.js", e.getResource().toString());
assertEquals("Filter 'next' function was called multiple times", e.getMessage());
}
}
use of com.enonic.xp.web.handler.WebHandlerChain in project xp by enonic.
the class FilterScriptImplTest method testResourceException.
@Test
public void testResourceException() throws Exception {
WebHandlerChain webHandlerChain = Mockito.mock(WebHandlerChain.class);
Mockito.when(webHandlerChain.handle(Mockito.any(), Mockito.any())).thenThrow(ResourceProblemException.class);
Assertions.assertThrows(ResourceProblemException.class, () -> execute("myapplication:/filter/callnext.js", webHandlerChain));
Mockito.verify(webHandlerChain, Mockito.times(1)).handle(Mockito.any(), Mockito.any());
}
use of com.enonic.xp.web.handler.WebHandlerChain in project xp by enonic.
the class FilterScriptImplTest method testExecErrorHandling.
@Test
public void testExecErrorHandling() throws Exception {
WebHandlerChain webHandlerChain = Mockito.mock(WebHandlerChain.class);
Mockito.when(webHandlerChain.handle(Mockito.any(), Mockito.any())).thenReturn(this.portalResponse);
this.portalRequest.setMethod(HttpMethod.POST);
final ResourceProblemException e = assertThrows(ResourceProblemException.class, () -> execute("myapplication:/filter/filtererror.js", webHandlerChain));
assertEquals("myapplication:/filter/filtererror.js", e.getResource().toString());
assertEquals(3, e.getLineNumber());
assertNotNull(e.getMessage());
}
use of com.enonic.xp.web.handler.WebHandlerChain in project xp by enonic.
the class MappingHandlerTest method testNoMatch_no_site.
@Test
public void testNoMatch_no_site() throws Exception {
final WebHandlerChain chain = mock(WebHandlerChain.class);
final PortalResponse response = PortalResponse.create().build();
this.request.setBaseUri("/admin/site");
this.request.setContentPath(ContentPath.from("/site/content"));
this.handler.handle(this.request, response, chain);
verify(chain).handle(this.request, response);
verifyNoInteractions(rendererDelegate);
}
Aggregations