Package org.apache.http.impl.io

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


        return new TestSuite(TestIdentitynputStream.class);
    }

    public void testConstructor() throws Exception {
        SessionInputBuffer receiver = new SessionInputBufferMockup(new byte[] {});
        new IdentityInputStream(receiver);
        try {
            new IdentityInputStream(null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            //expected
        }
    }
View Full Code Here


    }
   
    public void testBasicRead() throws Exception {
        byte[] input = new byte[] {'a', 'b', 'c'};
        SessionInputBufferMockup receiver = new SessionInputBufferMockup(input);
        IdentityInputStream instream = new IdentityInputStream(receiver);
        byte[] tmp = new byte[2];
        assertEquals(2, instream.read(tmp, 0, tmp.length));
        assertEquals('a', tmp[0]);
        assertEquals('b', tmp[1]);
        assertEquals('c', instream.read());
        assertEquals(-1, instream.read(tmp, 0, tmp.length));
        assertEquals(-1, instream.read());
        assertEquals(-1, instream.read(tmp, 0, tmp.length));
        assertEquals(-1, instream.read());       
    }
View Full Code Here

    }
   
    public void testClosedCondition() throws Exception {
        byte[] input = new byte[] {'a', 'b', 'c'};
        SessionInputBufferMockup receiver = new SessionInputBufferMockup(input);
        IdentityInputStream instream = new IdentityInputStream(receiver);

        instream.close();
        instream.close();
       
        assertTrue(instream.available() == 0);
        byte[] tmp = new byte[2];
        assertEquals(-1, instream.read(tmp, 0, tmp.length));
        assertEquals(-1, instream.read());
        assertEquals(-1, instream.read(tmp, 0, tmp.length));
        assertEquals(-1, instream.read());       
    }
View Full Code Here

    }

    public void testAvailable() throws Exception {
        byte[] input = new byte[] {'a', 'b', 'c'};
        SessionInputBufferMockup receiver = new SessionInputBufferMockup(input);
        IdentityInputStream instream = new IdentityInputStream(receiver);
        assertTrue(instream.available() > 0);       
    }
View Full Code Here

        return new TestSuite(TestIdentitynputStream.class);
    }

    public void testConstructor() throws Exception {
        SessionInputBuffer receiver = new SessionInputBufferMockup(new byte[] {});
        new IdentityInputStream(receiver);
        try {
            new IdentityInputStream(null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            //expected
        }
    }
View Full Code Here

    }
   
    public void testBasicRead() throws Exception {
        byte[] input = new byte[] {'a', 'b', 'c'};
        SessionInputBufferMockup receiver = new SessionInputBufferMockup(input);
        IdentityInputStream instream = new IdentityInputStream(receiver);
        byte[] tmp = new byte[2];
        assertEquals(2, instream.read(tmp, 0, tmp.length));
        assertEquals('a', tmp[0]);
        assertEquals('b', tmp[1]);
        assertEquals('c', instream.read());
        assertEquals(-1, instream.read(tmp, 0, tmp.length));
        assertEquals(-1, instream.read());
        assertEquals(-1, instream.read(tmp, 0, tmp.length));
        assertEquals(-1, instream.read());       
    }
View Full Code Here

    }
   
    public void testClosedCondition() throws Exception {
        byte[] input = new byte[] {'a', 'b', 'c'};
        SessionInputBufferMockup receiver = new SessionInputBufferMockup(input);
        IdentityInputStream instream = new IdentityInputStream(receiver);

        instream.close();
        instream.close();
       
        assertTrue(instream.available() == 0);
        byte[] tmp = new byte[2];
        assertEquals(-1, instream.read(tmp, 0, tmp.length));
        assertEquals(-1, instream.read());
        assertEquals(-1, instream.read(tmp, 0, tmp.length));
        assertEquals(-1, instream.read());       
    }
View Full Code Here

    }

    public void testAvailable() throws Exception {
        byte[] input = new byte[] {'a', 'b', 'c'};
        SessionInputBufferMockup receiver = new SessionInputBufferMockup(input);
        IdentityInputStream instream = new IdentityInputStream(receiver);
        assertTrue(instream.available() > 0);       
    }
View Full Code Here

            final long len,
            final SessionInputBuffer inbuffer) {
        if (len == ContentLengthStrategy.CHUNKED) {
            return new ChunkedInputStream(inbuffer, this.messageConstraints);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            return new IdentityInputStream(inbuffer);
        } else {
            return new ContentLengthInputStream(inbuffer, len);
        }
    }
View Full Code Here

            final long len,
            final SessionInputBuffer inbuffer) {
        if (len == ContentLengthStrategy.CHUNKED) {
            return new ChunkedInputStream(inbuffer);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            return new IdentityInputStream(inbuffer);
        } else {
            return new ContentLengthInputStream(inbuffer, len);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.http.impl.io.IdentityInputStream

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.