Package org.apache.http

Examples of org.apache.http.ReadableByteChannelMock


    }

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


    @Test
    public void testComplexDecoding() throws Exception {
        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";
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, "US-ASCII");

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

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

        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        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"
        };
        ReadableByteChannel channel = new ReadableByteChannelMock(
                chunks, "US-ASCII");

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

    }

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

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

    }

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

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

    }

    @Test
    public void testMalformedChunkTruncatedChunk() throws Exception {
        String s = "3\r\n12";
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, "US-ASCII");

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

    @Test
    public void testFoldedFooters() throws Exception {
        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";
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, "US-ASCII");

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

    @Test
    public void testMalformedFooters() throws Exception {
        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";
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, "US-ASCII");

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

    @Test
    public void testEndOfStreamConditionReadingLastChunk() throws Exception {
        String s = "10\r\n1234567890123456\r\n" +
                "5\r\n12345\r\n5\r\n12345";
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {s}, "US-ASCII");

        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        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.