Package org.apache.http

Examples of org.apache.http.ConnectionReuseStrategy.keepAlive()


        Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
        HttpResponse resp100 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 100, context)).thenReturn(resp100);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(false);

        httpservice.handleRequest(conn, context);

        Assert.assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, response.getStatusLine().getStatusCode());
View Full Code Here


        request.setEntity(entity);

        Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 100, context)).thenReturn(response);
        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(false);

        httpservice.handleRequest(conn, context);

        Assert.assertSame(conn, context.getAttribute(ExecutionContext.HTTP_CONNECTION));
        Assert.assertSame(request, context.getAttribute(ExecutionContext.HTTP_REQUEST));
View Full Code Here

        HttpResponse resp100 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 100, context)).thenReturn(resp100);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 500, "Oppsie");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_0, 500, context)).thenReturn(response);
        Mockito.doThrow(new HttpException("Oopsie")).when(expectationVerifier).verify(request, resp100, context);
        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(false);

        httpservice.handleRequest(conn, context);

        Assert.assertSame(conn, context.getAttribute(ExecutionContext.HTTP_CONNECTION));
        Assert.assertSame(request, context.getAttribute(ExecutionContext.HTTP_REQUEST));
View Full Code Here

        HttpResponse error = new BasicHttpResponse(HttpVersion.HTTP_1_0, 500, "Oppsie");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_0, 500, context)).thenReturn(error);
        Mockito.when(handlerResolver.lookup("/")).thenReturn(requestHandler);
        Mockito.doThrow(new MethodNotSupportedException("whatever")).when(
                requestHandler).handle(request, response, context);
        Mockito.when(connReuseStrategy.keepAlive(error, context)).thenReturn(false);

        httpservice.handleRequest(conn, context);

        Assert.assertSame(conn, context.getAttribute(ExecutionContext.HTTP_CONNECTION));
        Assert.assertSame(request, context.getAttribute(ExecutionContext.HTTP_REQUEST));
View Full Code Here

        HttpResponse error = new BasicHttpResponse(HttpVersion.HTTP_1_0, 500, "Oppsie");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_0, 500, context)).thenReturn(error);
        Mockito.when(handlerResolver.lookup("/")).thenReturn(requestHandler);
        Mockito.doThrow(new UnsupportedHttpVersionException()).when(
                requestHandler).handle(request, response, context);
        Mockito.when(connReuseStrategy.keepAlive(error, context)).thenReturn(false);

        httpservice.handleRequest(conn, context);

        Assert.assertSame(conn, context.getAttribute(ExecutionContext.HTTP_CONNECTION));
        Assert.assertSame(request, context.getAttribute(ExecutionContext.HTTP_REQUEST));
View Full Code Here

        HttpResponse error = new BasicHttpResponse(HttpVersion.HTTP_1_0, 500, "Oppsie");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_0, 500, context)).thenReturn(error);
        Mockito.when(handlerResolver.lookup("/")).thenReturn(requestHandler);
        Mockito.doThrow(new ProtocolException("oh, this world is wrong")).when(
                requestHandler).handle(request, response, context);
        Mockito.when(connReuseStrategy.keepAlive(error, context)).thenReturn(false);

        httpservice.handleRequest(conn, context);

        Assert.assertSame(conn, context.getAttribute(ExecutionContext.HTTP_CONNECTION));
        Assert.assertSame(request, context.getAttribute(ExecutionContext.HTTP_REQUEST));
View Full Code Here

        HttpRequest request = new BasicHttpRequest("GET", "/");
        Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
        Mockito.when(handlerResolver.lookup("/")).thenReturn(requestHandler);
        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(true);

        httpservice.handleRequest(conn, context);

        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
View Full Code Here

                httpexecutor.postProcess(response, httpproc, context);
               
                System.out.println("<< Response: " + response.getStatusLine());
                System.out.println(EntityUtils.toString(response.getEntity()));
                System.out.println("==============");
                if (!connStrategy.keepAlive(response, context)) {
                    conn.close();
                } else {
                    System.out.println("Connection kept alive...");
                }
            }
View Full Code Here

                httpexecutor.postProcess(response, httpproc, context);
               
                System.out.println("<< Response: " + response.getStatusLine());
                System.out.println(EntityUtils.toString(response.getEntity()));
                System.out.println("==============");
                if (!connStrategy.keepAlive(response, context)) {
                    conn.close();
                } else {
                    System.out.println("Connection kept alive...");
                }
            }
View Full Code Here

                httpexecutor.postProcess(response, httpproc, context);
               
                System.out.println("<< Response: " + response.getStatusLine());
                System.out.println(EntityUtils.toString(response.getEntity()));
                System.out.println("==============");
                if (!connStrategy.keepAlive(response, context)) {
                    conn.close();
                } else {
                    System.out.println("Connection kept alive...");
                }
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.