Examples of IdentityInputStream


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

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

    }
   
    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

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

    }
   
    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

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

    }

    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

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

            entity.setContentLength(-1);
            entity.setContent(new ChunkedInputStream(inbuffer));
        } else if (len == ContentLengthStrategy.IDENTITY) {
            entity.setChunked(false);
            entity.setContentLength(-1);
            entity.setContent(new IdentityInputStream(inbuffer));                           
        } else {
            entity.setChunked(false);
            entity.setContentLength(len);
            entity.setContent(new ContentLengthInputStream(inbuffer, len));
        }
View Full Code Here

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

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

    }
   
    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

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

    }
   
    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

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

    }

    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

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

            entity.setContentLength(-1);
            entity.setContent(new ChunkedInputStream(inbuffer));
        } else if (len == ContentLengthStrategy.IDENTITY) {
            entity.setChunked(false);
            entity.setContentLength(-1);
            entity.setContent(new IdentityInputStream(inbuffer));                           
        } else {
            entity.setChunked(false);
            entity.setContentLength(len);
            entity.setContent(new ContentLengthInputStream(inbuffer, len));
        }
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.