Package org.apache.http.mockup

Examples of org.apache.http.mockup.SessionOutputBufferMockup


        }
    }

    public void testBasics() throws Exception {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        SessionOutputBufferMockup datatransmitter = new SessionOutputBufferMockup(buffer);
        OutputStream out = new IdentityOutputStream(datatransmitter);

        byte[] tmp = new byte[10];
        out.write(tmp, 0, 10);
        out.write(tmp);
        out.write(1);
        out.flush();
        out.close();
        byte[] data = datatransmitter.getData();
        assertEquals(21, data.length);
    }
View Full Code Here


        assertEquals(21, data.length);
    }

    public void testClose() throws Exception {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        SessionOutputBufferMockup datatransmitter = new SessionOutputBufferMockup(buffer);
        OutputStream out = new IdentityOutputStream(datatransmitter);
        out.close();
        out.close();
        byte[] tmp = new byte[10];
        try {
View Full Code Here

            // expected
        }
    }
   
    public void testConstructor() throws Exception {
        SessionOutputBufferMockup transmitter = new SessionOutputBufferMockup();
        new IdentityOutputStream(transmitter);
        try {
            new IdentityOutputStream(null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
View Full Code Here

            //expected
        }
    }
   
    public void testBasicWrite() throws Exception {
        SessionOutputBufferMockup transmitter = new SessionOutputBufferMockup();
        IdentityOutputStream outstream = new IdentityOutputStream(transmitter);
        outstream.write(new byte[] {'a', 'b'}, 0, 2);
        outstream.write('c');
        outstream.flush();
       
        byte[] input = transmitter.getData();
       
        assertNotNull(input);
        byte[] expected = new byte[] {'a', 'b', 'c'};
        assertEquals(expected.length, input.length);
        for (int i = 0; i < expected.length; i++) {
View Full Code Here

            assertEquals(expected[i], input[i]);
        }
    }
   
    public void testClosedCondition() throws Exception {
        SessionOutputBufferMockup transmitter = new SessionOutputBufferMockup();
        IdentityOutputStream outstream = new IdentityOutputStream(transmitter);
        outstream.close();
        outstream.close();
       
        try {
View Full Code Here

        String[] testCaseName = { TestContentLengthOutputStream.class.getName() };
        junit.textui.TestRunner.main(testCaseName);
    }

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

        }
    }

    public void testBasics() throws Exception {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        SessionOutputBufferMockup datatransmitter = new SessionOutputBufferMockup(buffer);
        OutputStream out = new ContentLengthOutputStream(datatransmitter, 15L);

        byte[] tmp = new byte[10];
        out.write(tmp, 0, 10);
        out.write(1);
        out.write(tmp, 0, 10);
        out.write(tmp, 0, 10);
        out.write(tmp);
        out.write(1);
        out.write(2);
        out.flush();
        out.close();
        byte[] data = datatransmitter.getData();
        assertEquals(15, data.length);
    }
View Full Code Here

        assertEquals(15, data.length);
    }

    public void testClose() throws Exception {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        SessionOutputBufferMockup datatransmitter = new SessionOutputBufferMockup(buffer);
        OutputStream out = new ContentLengthOutputStream(datatransmitter, 15L);
        out.close();
        out.close();
        byte[] tmp = new byte[10];
        try {
View Full Code Here

        }
    }

    public void testChunkedOutputStreamClose() throws IOException {
        ChunkedOutputStream out = new ChunkedOutputStream(
                new SessionOutputBufferMockup());
        out.close();
        out.close();
        try {
            out.write(new byte[] {1,2,3});
            fail("IOException should have been thrown");
View Full Code Here

    }
   
    public void testChunkedConsitance() throws IOException {
        String input = "76126;27823abcd;:q38a-\nkjc\rk%1ad\tkh/asdui\r\njkh+?\\suweb";
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        OutputStream out = new ChunkedOutputStream(new SessionOutputBufferMockup(buffer));
        out.write(EncodingUtils.getBytes(input, CONTENT_CHARSET));
        out.flush();
        out.close();
        out.close();
        buffer.close();
View Full Code Here

TOP

Related Classes of org.apache.http.mockup.SessionOutputBufferMockup

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.