Package org.apache.http.nio

Examples of org.apache.http.nio.ContentDecoder


            this.buf = buf;
        }

        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final Object[] args = invocation.getArguments();
            final ContentDecoder decoder = (ContentDecoder) args[1];
            buf.consumeContent(decoder);
            return null;
        }
View Full Code Here


            this.buf = buf;
        }

        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final Object[] args = invocation.getArguments();
            final ContentDecoder decoder = (ContentDecoder) args[1];
            buf.consumeContent(decoder);
            return null;
        }
View Full Code Here

    public void testInputBufferOperations() throws IOException {
        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));
View Full Code Here

    public void testInputBufferOperations() throws IOException {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");
       
        ContentDecoder decoder = new MockupDecoder(channel);
       
        SimpleInputBuffer buffer = new SimpleInputBuffer(4, new DirectByteBufferAllocator());
        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));
View Full Code Here

    public void testInputBufferOperations() throws IOException {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");
       
        ContentDecoder decoder = new MockupDecoder(channel);
       
        SimpleInputBuffer buffer = new SimpleInputBuffer(4, new DirectByteBufferAllocator());
        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));
View Full Code Here

        }

        @Override
        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final Object[] args = invocation.getArguments();
            final ContentDecoder decoder = (ContentDecoder) args[1];
            buf.consumeContent(decoder);
            return null;
        }
View Full Code Here

        }

        @Override
        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final Object[] args = invocation.getArguments();
            final ContentDecoder decoder = (ContentDecoder) args[1];
            buf.consumeContent(decoder);
            return null;
        }
View Full Code Here

            this.buf = buf;
        }

        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final Object[] args = invocation.getArguments();
            final ContentDecoder decoder = (ContentDecoder) args[1];
            buf.consumeContent(decoder);
            return null;
        }
View Full Code Here

            this.buf = buf;
        }

        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final Object[] args = invocation.getArguments();
            final ContentDecoder decoder = (ContentDecoder) args[1];
            buf.consumeContent(decoder);
            return null;
        }
View Full Code Here

    @Test
    public void testInputBufferOperations() throws IOException {
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"stuff;", "more stuff"}, Consts.ASCII);

        final ContentDecoder decoder = new ContentDecoderMock(channel);

        final SimpleInputBuffer buffer = new SimpleInputBuffer(4, DirectByteBufferAllocator.INSTANCE);
        final int count = buffer.consumeContent(decoder);
        Assert.assertEquals(16, count);
        Assert.assertTrue(decoder.isCompleted());

        final byte[] b1 = new byte[5];

        int len = buffer.read(b1);
        Assert.assertEquals("stuff", EncodingUtils.getAsciiString(b1, 0, len));
View Full Code Here

TOP

Related Classes of org.apache.http.nio.ContentDecoder

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.