@Test
public void testConnectionKeepAlive() throws Exception {

    final HttpCoreContext context = HttpCoreContext.create();
    final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, "/");
    Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
    Mockito.when(responseFactory.newHttpResponse(200)).thenReturn(response);
    Mockito.when(handlerResolver.resolve(request, context)).thenReturn(requestHandler);
    Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.TRUE);
    httpservice.handleRequest(conn, context);
    Assert.assertEquals(HttpStatus.SC_OK, response.getCode());
    Assert.assertSame(request, context.getRequest());
    Assert.assertSame(response, context.getResponse());
    Mockito.verify(httprocessor).process(request, request.getEntity(), context);
    Mockito.verify(httprocessor).process(response, response.getEntity(), context);
    Mockito.verify(conn).sendResponseHeader(response);
    Mockito.verify(conn).sendResponseEntity(response);
    Mockito.verify(conn).flush();
    Mockito.verify(conn, Mockito.never()).close();
    Mockito.verify(response).close();
}