Package org.apache.http

Examples of org.apache.http.ReadableByteChannelMock


    @Test
    public void testReadingWitSmallBuffer() throws Exception {
        String s = "10\r\n1234567890123456\r\n" +
                "40\r\n12345678901234561234567890123456" +
                "12345678901234561234567890123456\r\n0\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 testEndOfStreamConditionReadingFooters() throws Exception {
        String s = "10\r\n1234567890123456\r\n" +
                "5\r\n12345\r\n5\r\n12345\r\n0\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

        Assert.assertTrue(decoder.isCompleted());
    }

    @Test
    public void testInvalidConstructor() {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");

        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        try {
            new ChunkDecoder(null, null, null);
View Full Code Here

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

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

        Assert.assertEquals(16, metrics.getBytesTransferred());
    }

    @Test
    public void testCodingBeyondContentLimit() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {
                        "stuff;",
                        "more stuff; and a lot more stuff"}, "US-ASCII");

        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
View Full Code Here

        Assert.assertEquals(16, metrics.getBytesTransferred());
    }

    @Test
    public void testBasicDecodingSmallBuffer() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");

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

        Assert.assertEquals(16, metrics.getBytesTransferred());
    }

    @Test
    public void testDecodingFromSessionBuffer1() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");

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

        Assert.assertEquals(10, metrics.getBytesTransferred());
    }

    @Test
    public void testDecodingFromSessionBuffer2() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {
                        "stuff;",
                        "more stuff; and a lot more stuff"}, "US-ASCII");

        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
View Full Code Here

        Assert.assertEquals(0, metrics.getBytesTransferred());
    }

    @Test
    public void testBasicDecodingFile() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII");

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