Package org.apache.http.mockup

Examples of org.apache.http.mockup.HttpDataTransmitterMockup


        }
    }

    public void testChunkedOutputStreamClose() throws IOException {
        ChunkedOutputStream out = new ChunkedOutputStream(
                new HttpDataTransmitterMockup());
        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 HttpDataTransmitterMockup(buffer));
        out.write(EncodingUtils.getBytes(input, CONTENT_CHARSET));
        out.flush();
        out.close();
        out.close();
        buffer.close();
View Full Code Here

        String output = EncodingUtils.getString(result.toByteArray(), CONTENT_CHARSET);
        assertEquals(input, output);
    }

    public void testChunkedOutputStream() throws IOException {
      HttpDataTransmitterMockup buffer = new HttpDataTransmitterMockup();
        ChunkedOutputStream out = new ChunkedOutputStream(buffer, 2);
        out.write('1')
        out.write('2')
        out.write('3')
        out.write('4')
        out.finish();
        out.close();
       
        byte [] rawdata =  buffer.getData();
       
        assertEquals(19, rawdata.length);
        assertEquals('2', rawdata[0]);
        assertEquals('\r', rawdata[1]);
        assertEquals('\n', rawdata[2]);
View Full Code Here

        assertEquals('\r', rawdata[17]);
        assertEquals('\n', rawdata[18]);
    }

    public void testChunkedOutputStreamLargeChunk() throws IOException {
      HttpDataTransmitterMockup buffer = new HttpDataTransmitterMockup();
        ChunkedOutputStream out = new ChunkedOutputStream(buffer, 2);
        out.write(new byte[] {'1', '2', '3', '4'});
        out.finish();
        out.close();
       
        byte [] rawdata =  buffer.getData();
       
        assertEquals(14, rawdata.length);
        assertEquals('4', rawdata[0]);
        assertEquals('\r', rawdata[1]);
        assertEquals('\n', rawdata[2]);
View Full Code Here

    }

    public void testChunkedOutputStreamSmallChunk() throws IOException {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ChunkedOutputStream out = new ChunkedOutputStream(
            new HttpDataTransmitterMockup(buffer), 2);
        out.write('1')
        out.finish();
        out.close();
       
        byte [] rawdata =  buffer.toByteArray();
View Full Code Here

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

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

        }
    }

    public void testBasics() throws Exception {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      HttpDataTransmitterMockup datatransmitter = new HttpDataTransmitterMockup(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();
      HttpDataTransmitterMockup datatransmitter = new HttpDataTransmitterMockup(buffer);
      OutputStream out = new IdentityOutputStream(datatransmitter);
      out.close();
      out.close();
        byte[] tmp = new byte[10];
        try {
View Full Code Here

    public static Test suite() {
        return new TestSuite(TestHttpDataOutputStream.class);
    }

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

            //expected
        }
    }
   
    public void testBasicWrite() throws Exception {
      HttpDataTransmitterMockup transmitter = new HttpDataTransmitterMockup();
        HttpDataOutputStream outstream = new HttpDataOutputStream(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

TOP

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

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.