}));
}
@Test
public void testResponseFailedExpectation() throws Exception {
State state = new HttpAsyncService.State();
HttpContext exchangeContext = state.getContext();
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/",
HttpVersion.HTTP_1_1);
state.setRequest(request);
state.setRequestState(MessageState.ACK_EXPECTED);
state.setResponseProducer(this.responseProducer);
this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 417, "Expectation failed");
response.setEntity(new NStringEntity("stuff"));
Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
this.protocolHandler.responseReady(this.conn);
Assert.assertEquals(MessageState.COMPLETED, state.getRequestState());
Assert.assertEquals(MessageState.BODY_STREAM, state.getResponseState());
Mockito.verify(this.conn).resetInput();
Mockito.verify(this.httpProcessor).process(response, exchangeContext);
Mockito.verify(this.conn).submitResponse(response);
Mockito.verify(this.responseProducer, Mockito.never()).responseCompleted(exchangeContext);