@Test public void noHostHeaderOn11Request() throws Exception { final AtomicReference<RequestHandler> requestHandlerRef = new AtomicReference<>(); when(mockHttpListenerConfig.addRequestHandler( any(ListenerRequestMatcher.class), any(RequestHandler.class))) .then( new Answer<RequestHandlerManager>() { @Override public RequestHandlerManager answer(InvocationOnMock invocation) throws Throwable { requestHandlerRef.set((RequestHandler) invocation.getArguments()[1]); return null; } }); usePath("/"); HttpRequest request = buildGetRootRequest(HTTP_1_1); HttpRequestContext requestContext = buildRequestContext(request); HttpResponseReadyCallback responseCallback = mock(HttpResponseReadyCallback.class); requestHandlerRef.get().handleRequest(requestContext, responseCallback); assertResponse( responseCallback, BAD_REQUEST.getStatusCode(), BAD_REQUEST.getReasonPhrase(), "Missing 'host' header"); }
@Test public void test400WithTextPlainIllegalArgumentException() { assertCodeMakes( GET, URI.create("https://amazonaws.com/foo"), BAD_REQUEST.getStatusCode(), BAD_REQUEST.getReasonPhrase(), TEXT_PLAIN, "Failure: 400 Bad Request\nFailed to bind the following fields\nMonitoring.Enabled = true\n\n\n", IllegalArgumentException.class); }
@Test public void test400WithInvalidKeyPairGroupDuplicateIllegalStateException() { assertCodeMakes( GET, URI.create("https://amazonaws.com/foo"), BAD_REQUEST.getStatusCode(), BAD_REQUEST.getReasonPhrase(), "application/unknown", "<Error><Code>InvalidKeyPair.Duplicate</Code></Error>", IllegalStateException.class); }