Examples of ContentLengthOutputStream


Examples of org.apache.http.impl.io.ContentLengthOutputStream

        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

Examples of org.apache.http.impl.io.ContentLengthOutputStream

    }

    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

Examples of org.apache.http.impl.io.ContentLengthOutputStream

    }

    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 {
          out.write(tmp);
            fail("IOException should have been thrown");
        } catch (IOException ex) {
            // expected
        }
        try {
            out.write(1);
            fail("IOException should have been thrown");
        } catch (IOException ex) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.http.impl.io.ContentLengthOutputStream

        if (len == ContentLengthStrategy.CHUNKED) {
            return new ChunkedOutputStream(outbuffer);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            return new IdentityOutputStream(outbuffer);
        } else {
            return new ContentLengthOutputStream(outbuffer, len);
        }
    }
View Full Code Here

Examples of org.apache.http.impl.io.ContentLengthOutputStream

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

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

Examples of org.apache.http.impl.io.ContentLengthOutputStream

    }

    public void testBasics() throws Exception {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      HttpDataTransmitterMockup datatransmitter = new HttpDataTransmitterMockup(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

Examples of org.apache.http.impl.io.ContentLengthOutputStream

    }

    public void testClose() throws Exception {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      HttpDataTransmitterMockup datatransmitter = new HttpDataTransmitterMockup(buffer);
      OutputStream out = new ContentLengthOutputStream(datatransmitter, 15L);
      out.close();
      out.close();
        byte[] tmp = new byte[10];
        try {
          out.write(tmp);
            fail("IOException should have been thrown");
        } catch (IOException ex) {
            // expected
        }
        try {
            out.write(1);
            fail("IOException should have been thrown");
        } catch (IOException ex) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.http.impl.io.ContentLengthOutputStream

        if (len == ContentLengthStrategy.CHUNKED) {
            return new ChunkedOutputStream(datatransmitter);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            return new IdentityOutputStream(datatransmitter);
        } else {
            return new ContentLengthOutputStream(datatransmitter, len);
        }
    }
View Full Code Here

Examples of org.apache.http.impl.io.ContentLengthOutputStream

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

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

Examples of org.apache.http.impl.io.ContentLengthOutputStream

    }

    public void testBasics() throws Exception {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      HttpDataTransmitterMockup datatransmitter = new HttpDataTransmitterMockup(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
TOP
Copyright © 2018 www.massapi.com. 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.