Package org.apache.http.mockup

Examples of org.apache.http.mockup.SessionOutputBufferMockup


        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

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

            // expected
        }
    }

    public void testEntityWithChunkTransferEncoding() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "Chunked");

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

        assertNotNull(outstream);
        assertTrue(outstream instanceof ChunkedOutputStream);
    }

    public void testEntityWithIdentityTransferEncoding() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "Identity");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
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.