Package org.apache.http.impl

Examples of org.apache.http.impl.SessionInputBufferMock


        Assert.assertTrue(instream instanceof IdentityInputStream);
    }

    @Test
    public void testEntityNeitherContentLengthNorTransferEncoding() throws Exception {
        final SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
        final HttpMessage message = new DummyHttpMessage();

        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        final EntityDeserializer entitygen = new EntityDeserializer(
View Full Code Here


        Assert.assertTrue(instream instanceof IdentityInputStream);
    }

    @Test
    public void testEntityContentType() throws Exception {
        final SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
        final HttpMessage message = new DummyHttpMessage();

        message.addHeader("Content-Type", "stuff");
        final EntityDeserializer entitygen = new EntityDeserializer(
                new LaxContentLengthStrategy());
View Full Code Here

        Assert.assertEquals("stuff", entity.getContentType().getValue());
    }

    @Test
    public void testEntityContentEncoding() throws Exception {
        final SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {'0'});
        final HttpMessage message = new DummyHttpMessage();

        message.addHeader("Content-Encoding", "what not");
        final EntityDeserializer entitygen = new EntityDeserializer(
                new LaxContentLengthStrategy());
View Full Code Here

    }

    @Test
    public void testAvailable() throws IOException {
        final InputStream in = new ContentLengthInputStream(
                new SessionInputBufferMock(new byte[] {1, 2, 3}), 10L);
        Assert.assertEquals(0, in.available());
        in.read();
        Assert.assertEquals(2, in.available());
    }
View Full Code Here

    }

    @Test
    public void testClose() throws IOException {
        final String correct = "1234567890123456-";
        final SessionInputBuffer inbuffer = new SessionInputBufferMock(EncodingUtils.getBytes(
                correct, CONTENT_CHARSET));
        final InputStream in = new ContentLengthInputStream(inbuffer, 16L);
        in.close();
        in.close();
        try {
            in.read();
            Assert.fail("IOException should have been thrown");
        } catch (final IOException ex) {
            // expected
        }
        final byte[] tmp = new byte[10];
        try {
            in.read(tmp);
            Assert.fail("IOException should have been thrown");
        } catch (final IOException ex) {
            // expected
        }
        try {
            in.read(tmp, 0, tmp.length);
            Assert.fail("IOException should have been thrown");
        } catch (final IOException ex) {
            // expected
        }
        Assert.assertEquals('-', inbuffer.read());
    }
View Full Code Here

    }

    @Test
    public void testTruncatedContent() throws IOException {
        final String correct = "1234567890123456";
        final SessionInputBuffer inbuffer = new SessionInputBufferMock(EncodingUtils.getBytes(
                correct, CONTENT_CHARSET));
        final InputStream in = new ContentLengthInputStream(inbuffer, 32L);
        final byte[] tmp = new byte[32];
        final int byteRead = in.read(tmp);
        Assert.assertEquals(16, byteRead);
View Full Code Here

            "HTTP/1.1 200 OK\r\n" +
            "Server: whatever\r\n" +
            "Date: some date\r\n" +
            "Set-Cookie: c1=stuff\r\n" +
            "\r\n";
        final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);

        final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);
        final HttpResponse httpresponse = parser.parse();

        final StatusLine statusline = httpresponse.getStatusLine();
View Full Code Here

        Assert.assertEquals(3, headers.length);
    }

    @Test
    public void testConnectionClosedException() throws Exception {
        final SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {});

        final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);
        try {
            parser.parse();
            Assert.fail("NoHttpResponseException should have been thrown");
View Full Code Here

            "HTTP\000/1.1 200\000 OK\r\n" +
            "Server: wha\000tever\r\n" +
            "Date: some date\r\n" +
            "Set-Coo\000kie: c1=stuff\r\n" +
            "\000\r\n";
        final SessionInputBuffer inbuffer = new SessionInputBufferMock(
                new TimeoutByteArrayInputStream(s.getBytes("US-ASCII")), 16);

        final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);

        int timeoutCount = 0;
View Full Code Here

*/
public class TestIdentityInputStream {

    @Test
    public void testConstructor() throws Exception {
        final SessionInputBuffer receiver = new SessionInputBufferMock(new byte[] {});
        new IdentityInputStream(receiver);
        try {
            new IdentityInputStream(null);
            Assert.fail("IllegalArgumentException should have been thrown");
        } catch (final IllegalArgumentException ex) {
View Full Code Here

TOP

Related Classes of org.apache.http.impl.SessionInputBufferMock

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.