Package org.apache.http

Examples of org.apache.http.ReadableByteChannelMock


        Assert.assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(this.tmpfile));
    }

    @Test
    public void testDecodingFileWithBufferedSessionData() 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


        Assert.assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(this.tmpfile));
    }

    @Test
    public void testDecodingFileWithOffsetAndBufferedSessionData() 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

        Assert.assertEquals("beginning; stuff; more stuff; a lot more stuff!", readFromFile(this.tmpfile));
    }

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

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

        }
    }

    @Test
    public void testCodingBeyondContentLimitFile() 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

        }
    }

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

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

    }

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

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

        }
    }

    @Test
    public void testZeroLengthDecoding() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"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(0, metrics.getBytesTransferred());
    }

    @Test(expected=ConnectionClosedException.class)
    public void testTruncatedContent() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"1234567890"}, "US-ASCII");

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

        decoder.read(dst);
    }

    @Test(expected=ConnectionClosedException.class)
    public void testTruncatedContentWithFile() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"1234567890"}, "US-ASCII");

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

        }
    }

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

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