Package org.apache.http

Examples of org.apache.http.ReadableByteChannelMock


public class TestChunkDecoder {

    @Test
    public void testBasicDecoding() throws Exception {
        final String s = "5\r\n01234\r\n5\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n";
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, Consts.ASCII);
        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
View Full Code Here


    @Test
    public void testComplexDecoding() throws Exception {
        final String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
                "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\nFooter2: fghij\r\n\r\n";
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, Consts.ASCII);

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
View Full Code Here

    @Test
    public void testDecodingWithSmallBuffer() throws Exception {
        final String s1 = "5\r\n01234\r\n5\r\n5678";
        final String s2 = "9\r\n6\r\nabcdef\r\n0\r\n\r\n";
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s1, s2}, Consts.ASCII);

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
View Full Code Here

    @Test
    public void testMalformedChunk() throws Exception {
        final String s = "5\r\n01234----------------------------------------------------------" +
                "-----------------------------------------------------------------------------" +
                "-----------------------------------------------------------------------------";
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, Consts.ASCII);

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(32, 32, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
View Full Code Here

                "\nabcdef\r",
                "\n0\r\nFoot",
                "er1: abcde\r\nFooter2: f",
                "ghij\r\n\r\n"
        };
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                chunks, Consts.ASCII);

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ByteBuffer dst = ByteBuffer.allocate(1024);
View Full Code Here

    }

    @Test(expected=MalformedChunkCodingException.class)
    public void testMalformedChunkSizeDecoding() throws Exception {
        final String s = "5\r\n01234\r\n5zz\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n";
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, Consts.ASCII);

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
View Full Code Here

    }

    @Test(expected=MalformedChunkCodingException.class)
    public void testMalformedChunkEndingDecoding() throws Exception {
        final String s = "5\r\n01234\r\n5\r\n56789\r\r6\r\nabcdef\r\n0\r\n\r\n";
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, Consts.ASCII);

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
View Full Code Here

    }

    @Test(expected=TruncatedChunkException.class)
    public void testMalformedChunkTruncatedChunk() throws Exception {
        final String s = "3\r\n12";
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, Consts.ASCII);

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
View Full Code Here

    @Test
    public void testFoldedFooters() throws Exception {
        final String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
                "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\n   \r\n  fghij\r\n\r\n";
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, Consts.ASCII);

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
View Full Code Here

    @Test(expected=IOException.class)
    public void testMalformedFooters() throws Exception {
        final String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
                "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1 abcde\r\n\r\n";
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, Consts.ASCII);

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
View Full Code Here

TOP

Related Classes of org.apache.http.ReadableByteChannelMock

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.