final Queue<PipelineEntry> pipeline = state.getPipeline();
final HttpContext exchangeContext = new BasicHttpContext();
final HttpRequest pipelinedRequest = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
final PipelineEntry entry = new PipelineEntry(pipelinedRequest, pipelinedRequest,
null, requestHandler, exchangeContext);
pipeline.add(entry);
this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
final HttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
Mockito.when(this.conn.getHttpRequest()).thenReturn(request);
Mockito.when(this.requestHandler.processRequest(
Mockito.eq(request), Mockito.any(HttpContext.class))).thenReturn(this.requestConsumer);
Mockito.when(this.requestConsumer.getException()).thenReturn(null);
final Object data = new Object();
Mockito.when(this.requestConsumer.getResult()).thenReturn(data);
this.protocolHandler.requestReceived(this.conn);
Assert.assertEquals(MessageState.READY, state.getRequestState());
Assert.assertEquals(MessageState.READY, state.getResponseState());
final Incoming incoming = state.getIncoming();
Assert.assertNull(incoming);
Mockito.verify(this.requestConsumer).requestReceived(request);
Mockito.verify(this.requestConsumer).requestCompleted(Mockito.<HttpContext>any());
Mockito.verify(this.requestHandler, Mockito.never()).handle(
Mockito.any(),
Mockito.any(HttpAsyncExchange.class),
Mockito.any(HttpContext.class));
Assert.assertFalse(state.getPipeline().isEmpty());
final PipelineEntry entry1 = state.getPipeline().remove();
Assert.assertSame(entry, entry1);
final PipelineEntry entry2 = state.getPipeline().remove();
Assert.assertSame(request, entry2.getRequest());
Assert.assertSame(data, entry2.getResult());
}