Search in sources :

Example 1 with TraceManager

use of com.enonic.xp.trace.TraceManager 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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Trace(com.enonic.xp.trace.Trace) ResourceService(com.enonic.xp.resource.ResourceService) ExceptionMapperImpl(com.enonic.xp.web.impl.exception.ExceptionMapperImpl) WebHandlerChain(com.enonic.xp.web.handler.WebHandlerChain) ControllerScriptFactory(com.enonic.xp.portal.controller.ControllerScriptFactory) TraceManager(com.enonic.xp.trace.TraceManager) ExceptionRenderer(com.enonic.xp.web.exception.ExceptionRenderer) PortalRequest(com.enonic.xp.portal.PortalRequest) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PortalRequest (com.enonic.xp.portal.PortalRequest)1 ControllerScriptFactory (com.enonic.xp.portal.controller.ControllerScriptFactory)1 ResourceService (com.enonic.xp.resource.ResourceService)1 Trace (com.enonic.xp.trace.Trace)1 TraceManager (com.enonic.xp.trace.TraceManager)1 ExceptionRenderer (com.enonic.xp.web.exception.ExceptionRenderer)1 WebHandlerChain (com.enonic.xp.web.handler.WebHandlerChain)1 ExceptionMapperImpl (com.enonic.xp.web.impl.exception.ExceptionMapperImpl)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1