Package org.apache.http.impl

Examples of org.apache.http.impl.SessionOutputBufferMock


        Assert.assertEquals('\n', rawdata[18]);
    }

    @Test
    public void testChunkedOutputStreamLargeChunk() throws IOException {
        SessionOutputBufferMock buffer = new SessionOutputBufferMock();
        ChunkedOutputStream out = new ChunkedOutputStream(buffer, 2);
        out.write(new byte[] {'1', '2', '3', '4'});
        out.finish();
        out.close();

        byte [] rawdata =  buffer.getData();

        Assert.assertEquals(14, rawdata.length);
        Assert.assertEquals('4', rawdata[0]);
        Assert.assertEquals('\r', rawdata[1]);
        Assert.assertEquals('\n', rawdata[2]);
View Full Code Here


    @Test
    public void testChunkedOutputStreamSmallChunk() throws IOException {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ChunkedOutputStream out = new ChunkedOutputStream(
                new SessionOutputBufferMock(buffer), 2);
        out.write('1');
        out.finish();
        out.close();

        byte [] rawdata =  buffer.toByteArray();
View Full Code Here

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

        }
    }

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

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

        Assert.assertTrue(outstream instanceof ChunkedOutputStream);
    }

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

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

        Assert.assertTrue(outstream instanceof IdentityOutputStream);
    }

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

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

        }
    }

    @Test
    public void testEntityWithInvalidChunkEncodingAndHTTP10() throws Exception {
        SessionOutputBuffer outbuffer = new SessionOutputBufferMock();
        HttpMessage message = new DummyHttpMessage();
        message.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
                HttpVersion.HTTP_1_0);
        message.addHeader("Transfer-Encoding", "chunked");
View Full Code Here

        }
    }

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

        Assert.assertTrue(outstream instanceof ContentLengthOutputStream);
    }

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

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

        }
    }

    @Test
    public void testEntityNoContentDelimiter() throws Exception {
        SessionOutputBuffer outbuffer = new SessionOutputBufferMock();
        HttpMessage message = new DummyHttpMessage();
        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        OutputStream outstream = entitywriter.doSerialize(outbuffer, message);
        Assert.assertNotNull(outstream);
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.