Package org.apache.http.impl

Examples of org.apache.http.impl.SessionOutputBufferMock


            Assert.fail("IllegalArgumentException should have been thrown");
        } catch (final IllegalArgumentException ex) {
            // expected
        }
        try {
            entitywriter.serialize(new SessionOutputBufferMock() , null, null);
            Assert.fail("IllegalArgumentException should have been thrown");
        } catch (final IllegalArgumentException ex) {
            // expected
        }
        try {
            entitywriter.serialize(new SessionOutputBufferMock() , new DummyHttpMessage(), null);
            Assert.fail("IllegalArgumentException should have been thrown");
        } catch (final IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here


        }
    }

    @Test
    public void testEntityWithChunkTransferEncoding() throws Exception {
        final SessionOutputBuffer outbuffer = new SessionOutputBufferMock();
        final HttpMessage message = new DummyHttpMessage();
        message.addHeader("Transfer-Encoding", "Chunked");

        final EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
View Full Code Here

        Assert.assertTrue(outstream instanceof ChunkedOutputStream);
    }

    @Test
    public void testEntityWithIdentityTransferEncoding() throws Exception {
        final SessionOutputBuffer outbuffer = new SessionOutputBufferMock();
        final HttpMessage message = new DummyHttpMessage();
        message.addHeader("Transfer-Encoding", "Identity");

        final EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
View Full Code Here

        Assert.assertTrue(outstream instanceof IdentityOutputStream);
    }

    @Test
    public void testEntityWithInvalidTransferEncoding() throws Exception {
        final SessionOutputBuffer outbuffer = new SessionOutputBufferMock();
        final HttpMessage message = new DummyHttpMessage();
        message.addHeader("Transfer-Encoding", "whatever");

        final EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
View Full Code Here

        }
    }

    @Test
    public void testEntityWithInvalidChunkEncodingAndHTTP10() throws Exception {
        final SessionOutputBuffer outbuffer = new SessionOutputBufferMock();
        final HttpMessage message = new DummyHttpMessage(HttpVersion.HTTP_1_0);
        message.addHeader("Transfer-Encoding", "chunked");

        final EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
View Full Code Here

        }
    }

    @Test
    public void testEntityWithContentLength() throws Exception {
        final SessionOutputBuffer outbuffer = new SessionOutputBufferMock();
        final HttpMessage message = new DummyHttpMessage();
        message.addHeader("Content-Length", "100");
        final EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        final OutputStream outstream = entitywriter.doSerialize(outbuffer, message);
View Full Code Here

        Assert.assertTrue(outstream instanceof ContentLengthOutputStream);
    }

    @Test
    public void testEntityWithInvalidContentLength() throws Exception {
        final SessionOutputBuffer outbuffer = new SessionOutputBufferMock();
        final HttpMessage message = new DummyHttpMessage();
        message.addHeader("Content-Length", "whatever");

        final EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
View Full Code Here

        }
    }

    @Test
    public void testEntityNoContentDelimiter() throws Exception {
        final SessionOutputBuffer outbuffer = new SessionOutputBufferMock();
        final HttpMessage message = new DummyHttpMessage();
        final EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        final OutputStream outstream = entitywriter.doSerialize(outbuffer, message);
        Assert.assertNotNull(outstream);
View Full Code Here

    @Test
    public void testEntitySerialization() throws Exception {
        final byte[] content = new byte[] {1, 2, 3, 4, 5};
        final ByteArrayEntity entity = new ByteArrayEntity(content);

        final SessionOutputBufferMock outbuffer = new SessionOutputBufferMock();
        final HttpMessage message = new DummyHttpMessage();
        message.addHeader("Content-Length", Integer.toString(content.length));

        final EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        entitywriter.serialize(outbuffer, message, entity);

        final byte[] data = outbuffer.getData();
        Assert.assertNotNull(data);
        Assert.assertEquals(content.length, data.length);
    }
View Full Code Here

public class TestContentLengthOutputStream {

    @Test
    public void testConstructors() throws Exception {
        new ContentLengthOutputStream(new SessionOutputBufferMock(), 10L);
        try {
            new ContentLengthOutputStream(null, 10L);
            Assert.fail("IllegalArgumentException should have been thrown");
        } catch (final IllegalArgumentException ex) {
            // expected
        }
        try {
            new ContentLengthOutputStream(new SessionOutputBufferMock(), -10);
            Assert.fail("IllegalArgumentException should have been thrown");
        } catch (final IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

TOP

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

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.