HttpAsyncExpectationVerifier expectationVerifier = Mockito.mock(HttpAsyncExpectationVerifier.class);
this.protocolHandler = new HttpAsyncService(
this.httpProcessor, this.reuseStrategy, this.responseFactory,
this.handlerResolver, expectationVerifier, this.params);
State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
Mockito.when(this.requestHandler.processRequest(
request, exchangeContext)).thenReturn(this.requestConsumer);
this.protocolHandler.requestReceived(this.conn);
Assert.assertEquals(MessageState.ACK_EXPECTED, state.getRequestState());
Assert.assertEquals(MessageState.READY, state.getResponseState());
Assert.assertSame(request, state.getRequest());
Assert.assertSame(this.requestHandler, state.getRequestHandler());
Assert.assertSame(this.requestConsumer, state.getRequestConsumer());
Assert.assertSame(request, exchangeContext.getAttribute(ExecutionContext.HTTP_REQUEST));
Assert.assertSame(this.conn, exchangeContext.getAttribute(ExecutionContext.HTTP_CONNECTION));
Mockito.verify(this.httpProcessor).process(request, exchangeContext);
Mockito.verify(this.requestConsumer).requestReceived(request);