Package org.apache.http

Examples of org.apache.http.HttpResponseFactory


    }
   
    public void testParsingInvalidStatusLine() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
        HttpResponseParser responseParser = new HttpResponseParser(inbuf, null, responseFactory, params);
       
        ReadableByteChannel channel = newChannel("HTTP 200 OK\r\n");
        responseParser.fillBuffer(channel);
        try {
View Full Code Here


    }
   
    public void testParsingInvalidHeader() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
        HttpResponseParser responseParser = new HttpResponseParser(inbuf, null, responseFactory, params);
       
        ReadableByteChannel channel = newChannel("HTTP/1.0 200 OK\r\nstuff\r\n\r\n");
        responseParser.fillBuffer(channel);
        try {
View Full Code Here

        cleanup();

        // Assemble new Axis HTTP service
        HttpProcessor httpProcessor;
        ConnectionReuseStrategy connStrategy;
        HttpResponseFactory responseFactory;

        if (httpFactory != null) {
            httpProcessor = httpFactory.newHttpProcessor();
            connStrategy = httpFactory.newConnStrategy();
            responseFactory = httpFactory.newResponseFactory();
View Full Code Here

    @Test
    public void testParsingInvalidStatusLine() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
        NHttpMessageParser<HttpResponse> responseParser = new DefaultHttpResponseParser(inbuf, null, responseFactory, params);

        ReadableByteChannel channel = newChannel("HTTP 200 OK\r\n");
        responseParser.fillBuffer(channel);
        try {
View Full Code Here

    @Test
    public void testParsingInvalidHeader() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
        NHttpMessageParser<HttpResponse> responseParser = new DefaultHttpResponseParser(inbuf, null, responseFactory, params);

        ReadableByteChannel channel = newChannel("HTTP/1.0 200 OK\r\nstuff\r\n\r\n");
        responseParser.fillBuffer(channel);
        try {
View Full Code Here

    @Test
    public void testInvalidInitialization() throws Exception {
        HttpProcessor httprocessor = Mockito.mock(HttpProcessor.class);
        ConnectionReuseStrategy connReuseStrategy = Mockito.mock(ConnectionReuseStrategy.class);
        HttpResponseFactory responseFactory = Mockito.mock(HttpResponseFactory.class);
        HttpRequestHandlerResolver handlerResolver = Mockito.mock(HttpRequestHandlerResolver.class);
        HttpParams params = new SyncBasicHttpParams();
        try {
            new HttpService(
                    null,
View Full Code Here

    @Test
    public void testBasicExecution() throws Exception {
        HttpProcessor httprocessor = Mockito.mock(HttpProcessor.class);
        ConnectionReuseStrategy connReuseStrategy = Mockito.mock(ConnectionReuseStrategy.class);
        HttpResponseFactory responseFactory = Mockito.mock(HttpResponseFactory.class);
        HttpRequestHandlerResolver handlerResolver = Mockito.mock(HttpRequestHandlerResolver.class);
        HttpParams params = new SyncBasicHttpParams();

        HttpService httpservice = new HttpService(
                httprocessor,
                connReuseStrategy,
                responseFactory,
                handlerResolver,
                params);
        HttpContext context = new BasicHttpContext();
        HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
        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(connReuseStrategy.keepAlive(response, context)).thenReturn(false);

        httpservice.handleRequest(conn, context);

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

    @Test
    public void testBasicExecutionHTTP10() throws Exception {
        HttpProcessor httprocessor = Mockito.mock(HttpProcessor.class);
        ConnectionReuseStrategy connReuseStrategy = Mockito.mock(ConnectionReuseStrategy.class);
        HttpResponseFactory responseFactory = Mockito.mock(HttpResponseFactory.class);
        HttpRequestHandlerResolver handlerResolver = Mockito.mock(HttpRequestHandlerResolver.class);
        HttpParams params = new SyncBasicHttpParams();

        HttpService httpservice = new HttpService(
                httprocessor,
                connReuseStrategy,
                responseFactory,
                handlerResolver,
                params);
        HttpContext context = new BasicHttpContext();
        HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
        HttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_0);
        Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 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);

        Mockito.verify(responseFactory).newHttpResponse(HttpVersion.HTTP_1_1, 200, context);
View Full Code Here

    @Test
    public void testBasicProtocolDowngrade() throws Exception {
        HttpProcessor httprocessor = Mockito.mock(HttpProcessor.class);
        ConnectionReuseStrategy connReuseStrategy = Mockito.mock(ConnectionReuseStrategy.class);
        HttpResponseFactory responseFactory = Mockito.mock(HttpResponseFactory.class);
        HttpRequestHandlerResolver handlerResolver = Mockito.mock(HttpRequestHandlerResolver.class);
        HttpParams params = new SyncBasicHttpParams();

        HttpService httpservice = new HttpService(
                httprocessor,
                connReuseStrategy,
                responseFactory,
                handlerResolver,
                params);
        HttpContext context = new BasicHttpContext();
        HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
        HttpRequest request = new BasicHttpRequest("GET", "/", new HttpVersion(20, 45));
        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(connReuseStrategy.keepAlive(response, context)).thenReturn(false);

        httpservice.handleRequest(conn, context);

        Mockito.verify(responseFactory).newHttpResponse(HttpVersion.HTTP_1_1, 200, context);
View Full Code Here

    @Test
    public void testExecutionEntityEclosingRequest() throws Exception {
        HttpProcessor httprocessor = Mockito.mock(HttpProcessor.class);
        ConnectionReuseStrategy connReuseStrategy = Mockito.mock(ConnectionReuseStrategy.class);
        HttpResponseFactory responseFactory = Mockito.mock(HttpResponseFactory.class);
        HttpRequestHandlerResolver handlerResolver = Mockito.mock(HttpRequestHandlerResolver.class);
        HttpParams params = new SyncBasicHttpParams();

        HttpService httpservice = new HttpService(
                httprocessor,
                connReuseStrategy,
                responseFactory,
                handlerResolver,
                params);
        HttpContext context = new BasicHttpContext();
        HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
        HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        InputStream instream = Mockito.mock(InputStream.class);
        InputStreamEntity entity = new InputStreamEntity(instream, -1);
        request.setEntity(entity);

        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(connReuseStrategy.keepAlive(response, context)).thenReturn(false);

        httpservice.handleRequest(conn, context);

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

TOP

Related Classes of org.apache.http.HttpResponseFactory

Copyright © 2018 www.massapicom. 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.