use of com.enonic.xp.web.impl.exception.ExceptionMapperImpl in project xp by enonic.
the class WebAppHandlerTest method setup.
@BeforeEach
public void setup() {
this.resourceService = Mockito.mock(ResourceService.class);
this.controllerScriptFactory = Mockito.mock(ControllerScriptFactory.class);
this.exceptionRenderer = Mockito.mock(ExceptionRenderer.class);
this.handler = new WebAppHandler();
this.handler.setResourceService(this.resourceService);
this.handler.setControllerScriptFactory(this.controllerScriptFactory);
this.handler.setExceptionMapper(new ExceptionMapperImpl());
this.handler.setExceptionRenderer(this.exceptionRenderer);
this.request = new PortalRequest();
this.request.setRawRequest(Mockito.mock(HttpServletRequest.class));
this.chain = Mockito.mock(WebHandlerChain.class);
Mockito.when(this.resourceService.getResource(Mockito.any())).thenReturn(MockResource.missing(ResourceKey.from("myapp:/unknown.txt")));
Mockito.when(this.exceptionRenderer.render(Mockito.any(), Mockito.any())).thenReturn(WebResponse.create().status(HttpStatus.INTERNAL_SERVER_ERROR).build());
final TraceManager manager = Mockito.mock(TraceManager.class);
final Trace trace = Mockito.mock(Trace.class);
Mockito.when(manager.newTrace(Mockito.any(), Mockito.any())).thenReturn(trace);
Tracer.setManager(manager);
}
use of com.enonic.xp.web.impl.exception.ExceptionMapperImpl in project xp by enonic.
the class WebDispatcherServletTest method configure.
@Override
protected void configure() throws Exception {
this.handler = new TestWebHandler();
this.servlet = new WebDispatcherServlet(new WebDispatcherImpl());
this.servlet.addWebHandler(this.handler);
this.servlet.setExceptionMapper(new ExceptionMapperImpl());
this.servlet.setExceptionRenderer((req, cause) -> WebResponse.create().status(HttpStatus.NOT_FOUND).build());
this.servlet.setWebSocketContextFactory(Mockito.mock(WebSocketContextFactory.class));
this.servlet.setResponseSerializationService(new ResponseSerializationServiceImpl());
this.handler.response = WebResponse.create().status(HttpStatus.OK).build();
addServlet(this.servlet, "/site/*");
}
Aggregations