Examples of SimpleInputBuffer


Examples of org.apache.http.nio.util.SimpleInputBuffer

        final LinkedList<HttpResponse> responses = new LinkedList<HttpResponse>();

        Mockito.doAnswer(new ResponseCapturingAnswer(responses)).when(
            handler).responseReceived(Mockito.<NHttpClientConnection>any());
        Mockito.doAnswer(new ConsumeContentAnswer(new SimpleInputBuffer(64))).when(
            handler).inputReady(Mockito.<NHttpClientConnection>any(), Mockito.<ContentDecoder>any());

        conn.consumeInput(handler);

        Assert.assertNull(conn.getHttpResponse());
View Full Code Here

Examples of org.apache.http.nio.util.SimpleInputBuffer

        final LinkedList<HttpResponse> responses = new LinkedList<HttpResponse>();

        Mockito.doAnswer(new ResponseCapturingAnswer(responses)).when(
            handler).responseReceived(Mockito.<NHttpClientConnection>any());
        Mockito.doAnswer(new ConsumeContentAnswer(new SimpleInputBuffer(64))).when(
            handler).inputReady(Mockito.<NHttpClientConnection>any(), Mockito.<ContentDecoder>any());

        Assert.assertEquals(0, conn.getMetrics().getResponseCount());

        conn.consumeInput(handler);
View Full Code Here

Examples of org.apache.http.nio.util.SimpleInputBuffer

        private final SimpleInputBuffer buffer;
        private volatile HttpResponse response;

        public LenientAsyncResponseConsumer() {
            super();
            this.buffer = new SimpleInputBuffer(2048, new HeapByteBufferAllocator());
        }
View Full Code Here

Examples of org.apache.http.nio.util.SimpleInputBuffer

            super();
        }

        public ContentInputBuffer getInbuffer() {
            if (this.inbuffer == null) {
                this.inbuffer = new SimpleInputBuffer(2048);
            }
            return this.inbuffer;
        }
View Full Code Here

Examples of org.apache.http.nio.util.SimpleInputBuffer

            this.outputState = READY;
        }

        public ContentInputBuffer getInbuffer() {
            if (this.inbuffer == null) {
                this.inbuffer = new SimpleInputBuffer(2048);
            }
            return this.inbuffer;
        }
View Full Code Here

Examples of org.apache.http.nio.util.SimpleInputBuffer

        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");
       
        ContentDecoder decoder = new MockupDecoder(channel);
       
        SimpleInputBuffer buffer = new SimpleInputBuffer(4);
        int count = buffer.consumeContent(decoder);
        assertEquals(16, count);
        assertTrue(decoder.isCompleted());
       
        byte[] b1 = new byte[5];
       
        int len = buffer.read(b1);
        assertEquals("stuff", EncodingUtils.getAsciiString(b1, 0, len));
       
        int c = buffer.read();
        assertEquals(';', c);
       
        byte[] b2 = new byte[1024];

        len = buffer.read(b2);
        assertEquals("more stuff", EncodingUtils.getAsciiString(b2, 0, len));

        assertEquals(-1, buffer.read());
        assertEquals(-1, buffer.read(b2));
        assertEquals(-1, buffer.read(b2, 0, b2.length));
        assertTrue(buffer.isEndOfStream());
       
        buffer.reset();
        assertFalse(buffer.isEndOfStream());
    }
View Full Code Here

Examples of org.apache.http.nio.util.SimpleInputBuffer

        byte[] content = outstream.toByteArray();
        assertEquals("stuff;more stuff", EncodingUtils.getAsciiString(content));
    }

    public void testInputBufferNullInput() throws IOException {
        SimpleInputBuffer buffer = new SimpleInputBuffer(4);
        assertEquals(0, buffer.read(null));
        assertEquals(0, buffer.read(null, 0, 0));
    }
View Full Code Here

Examples of org.apache.http.nio.util.SimpleInputBuffer

            this.allocator = allocator;
        }

        public ContentInputBuffer getInbuffer() {
            if (this.inbuffer == null) {
                this.inbuffer = new SimpleInputBuffer(2048, allocator);
            }
            return this.inbuffer;
        }
View Full Code Here

Examples of org.apache.http.nio.util.SimpleInputBuffer

            this.allocator = allocator;
        }

        public ContentInputBuffer getInbuffer() {
            if (this.inbuffer == null) {
                this.inbuffer = new SimpleInputBuffer(2048, allocator);
            }
            return this.inbuffer;
        }
View Full Code Here

Examples of org.apache.http.nio.util.SimpleInputBuffer

        public LenientNHttpEntity(
                final HttpEntity httpEntity,
                final ByteBufferAllocator allocator) {
            super(httpEntity);
            this.buffer = new SimpleInputBuffer(BUFFER_SIZE, allocator);
        }
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.