@Override public void handle(Void aVoid) { // Resume the vert.x request if we haven't already read the body if (inputStream == null) { vertxRequest.resume(); } applicationHandlerDelegate.handle(jerseyRequest); } });
@Test public void testHandle() throws Exception { when(request.method()).thenReturn(HttpMethod.GET); when(request.headers()).thenReturn(mock(MultiMap.class)); jerseyHandler.handle(request); verify(applicationHandlerDelegate).handle(any(ContainerRequest.class)); }
@Test public void testHandle_RequestProcessors() throws Exception { when(request.headers()).thenReturn(mock(MultiMap.class)); when(request.method()).thenReturn(HttpMethod.GET); InputStream inputStream = null; VertxRequestProcessor rp1 = mock(VertxRequestProcessor.class); VertxRequestProcessor rp2 = mock(VertxRequestProcessor.class); requestProcessors.add(rp1); requestProcessors.add(rp2); jerseyHandler.handle(request, inputStream); verify(rp1).process(any(HttpServerRequest.class), any(ContainerRequest.class), endHandlerCaptor.capture()); endHandlerCaptor.getValue().handle(null); verify(rp2).process(any(HttpServerRequest.class), any(ContainerRequest.class), endHandlerCaptor.capture()); endHandlerCaptor.getValue().handle(null); verify(applicationHandlerDelegate).handle(any(ContainerRequest.class)); }
@Test public void testHandle_JSON_POST() throws Exception { DefaultHttpHeaders headers = new DefaultHttpHeaders(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); when(request.method()).thenReturn(HttpMethod.POST); when(request.headers()).thenReturn(new HeadersAdaptor(headers)); jerseyHandler.handle(request); verify(request).handler(dataHandlerCaptor.capture()); verify(request).endHandler(endHandlerCaptor.capture()); Buffer data = Buffer.buffer("{}"); dataHandlerCaptor.getValue().handle(data); endHandlerCaptor.getValue().handle(null); verify(applicationHandlerDelegate).handle(any(ContainerRequest.class)); }
applicationHandlerDelegate.handle(jerseyRequest);