@Before public void before() throws Exception { MonitoringHelper.initMocks(); MockitoAnnotations.initMocks(this); contextFactory = new ServletSessionContextFactory(); servlet = new ZuulServlet(); servlet.contextFactory = contextFactory; servlet = spy(servlet); servlet.processor = processor; when(servletRequest.getHeaderNames()).thenReturn(Collections.<String>emptyEnumeration()); when(servletRequest.getAttributeNames()).thenReturn(Collections.<String>emptyEnumeration()); servletInputStream = new ServletInputStreamWrapper("{}".getBytes()); when(servletRequest.getInputStream()).thenReturn(servletInputStream); when(servletResponse.getOutputStream()).thenReturn(servletOutputStream); //when(contextFactory.create(context, servletRequest)).thenReturn(Observable.just(request)); response = new HttpResponseMessage(context, request, 299); response.setBody("blah".getBytes()); when(processor.applyInboundFilters(Matchers.any())).thenReturn(Observable.just(request)); when(processor.applyEndpointFilter(Matchers.any())).thenReturn(Observable.just(response)); when(processor.applyOutboundFilters(Matchers.any())).thenReturn(Observable.just(response)); }
public HttpResponseMessage handle(HttpRequestMessage request) { HttpResponseMessage response = new HttpResponseMessage(request.getContext(), request, 200); response.getHeaders().set("Content-Type", "text/plain"); response.setBody("OK".getBytes(CS_UTF8)); return response; } }