Examples of SessionInputBufferMock


Examples of org.apache.http.impl.SessionInputBufferMock

            "GET / HTTP/1.1\r\n" +
            "Host: localhost\r\n" +
            "User-Agent: whatever\r\n" +
            "Cookie: c1=stuff\r\n" +
            "\r\n";
        SessionInputBuffer inbuffer = new SessionInputBufferMock(s, "US-ASCII");

        HttpRequestParser parser = new HttpRequestParser(
                inbuffer,
                BasicLineParser.DEFAULT,
                new DefaultHttpRequestFactory(),
View Full Code Here

Examples of org.apache.http.impl.SessionInputBufferMock

        Assert.assertEquals(3, headers.length);
    }

    @Test
    public void testConnectionClosedException() throws Exception {
        SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {});

        HttpRequestParser parser = new HttpRequestParser(
                inbuffer,
                BasicLineParser.DEFAULT,
                new DefaultHttpRequestFactory(),
View Full Code Here

Examples of org.apache.http.impl.SessionInputBufferMock

            "GET \000/ HTTP/1.1\r\000\n" +
            "Host: loca\000lhost\r\n" +
            "User-Agent: whatever\r\n" +
            "Coo\000kie: c1=stuff\r\n" +
            "\000\r\n";
        SessionInputBuffer inbuffer = new SessionInputBufferMock(
                new TimeoutByteArrayInputStream(s.getBytes("US-ASCII")), 16);

        HttpRequestParser parser = new HttpRequestParser(
                inbuffer,
                BasicLineParser.DEFAULT,
View Full Code Here

Examples of org.apache.http.impl.SessionInputBufferMock

    @Test
    public void testTooLongChunkHeader() throws IOException {
        final String input = "5; and some very looooong commend\r\n12345\r\n0\r\n";
        final InputStream in1 = new ChunkedInputStream(
                new SessionInputBufferMock(input, MessageConstraints.DEFAULT, Consts.ISO_8859_1));
        final byte[] buffer = new byte[300];
        Assert.assertEquals(5, in1.read(buffer));

        final InputStream in2 = new ChunkedInputStream(
                new SessionInputBufferMock(input, MessageConstraints.lineLen(10), Consts.ISO_8859_1));
        try {
            in2.read(buffer);
            Assert.fail("MessageConstraintException expected");
        } catch (MessageConstraintException ex) {
        }
View Full Code Here

Examples of org.apache.http.impl.SessionInputBufferMock

        out.write(input.getBytes(Consts.ISO_8859_1));
        out.flush();
        out.close();
        out.close();
        buffer.close();
        final InputStream in = new ChunkedInputStream(new SessionInputBufferMock(buffer.toByteArray()));

        final byte[] d = new byte[10];
        final ByteArrayOutputStream result = new ByteArrayOutputStream();
        int len = 0;
        while ((len = in.read(d)) > 0) {
View Full Code Here

Examples of org.apache.http.impl.SessionInputBufferMock

    }

    @Test
    public void testResumeOnSocketTimeoutInData() throws IOException {
        final String s = "5\r\n01234\r\n5\r\n5\0006789\r\na\r\n0123\000456789\r\n0\r\n";
        final SessionInputBuffer sessbuf = new SessionInputBufferMock(
                new TimeoutByteArrayInputStream(s.getBytes(Consts.ISO_8859_1)), 16);
        final InputStream in = new ChunkedInputStream(sessbuf);

        final byte[] tmp = new byte[3];
View Full Code Here

Examples of org.apache.http.impl.SessionInputBufferMock

}

    @Test
    public void testResumeOnSocketTimeoutInChunk() throws IOException {
        final String s = "5\000\r\000\n\00001234\r\n\0005\r\n56789\r\na\r\n0123456789\r\n\0000\r\n";
        final SessionInputBuffer sessbuf = new SessionInputBufferMock(
                new TimeoutByteArrayInputStream(s.getBytes(Consts.ISO_8859_1)), 16);
        final InputStream in = new ChunkedInputStream(sessbuf);

        final byte[] tmp = new byte[3];
View Full Code Here

Examples of org.apache.http.impl.SessionInputBufferMock

public class TestSessionInOutBuffers {

    @Test
    public void testBasicBufferProperties() throws Exception {
        final SessionInputBufferMock inbuffer = new SessionInputBufferMock(new byte[] { 1, 2 , 3});
        Assert.assertEquals(SessionInputBufferMock.BUFFER_SIZE, inbuffer.capacity());
        Assert.assertEquals(SessionInputBufferMock.BUFFER_SIZE, inbuffer.available());
        Assert.assertEquals(0, inbuffer.length());
        inbuffer.read();
        Assert.assertEquals(SessionInputBufferMock.BUFFER_SIZE - 2, inbuffer.available());
        Assert.assertEquals(2, inbuffer.length());

        final SessionOutputBufferMock outbuffer = new SessionOutputBufferMock();
        Assert.assertEquals(SessionOutputBufferMock.BUFFER_SIZE, outbuffer.capacity());
        Assert.assertEquals(SessionOutputBufferMock.BUFFER_SIZE, outbuffer.available());
        Assert.assertEquals(0, outbuffer.length());
View Full Code Here

Examples of org.apache.http.impl.SessionInputBufferMock

        for (final String teststr : teststrs) {
            expected += (teststr.length() + 2/*CRLF*/);
        }
        Assert.assertEquals(expected, bytesWritten);

        final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
                outbuffer.getData());

        for (final String teststr : teststrs) {
            Assert.assertEquals(teststr, inbuffer.readLine());
        }

        Assert.assertNull(inbuffer.readLine());
        Assert.assertNull(inbuffer.readLine());
        tmetrics = inbuffer.getMetrics();
        final long bytesRead = tmetrics.getBytesTransferred();
        Assert.assertEquals(expected, bytesRead);
    }
View Full Code Here

Examples of org.apache.http.impl.SessionInputBufferMock

        outbuffer.write(new byte[] {'a'});
        outbuffer.flush();
        bytesWritten = outbuffer.getMetrics().getBytesTransferred();
        Assert.assertEquals(8 + 14 + 2 + 15 + 2 + 16 + 2 + 1, bytesWritten);

        final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
                outbuffer.getData());

        Assert.assertEquals("a", inbuffer.readLine());
        Assert.assertEquals("", inbuffer.readLine());
        Assert.assertEquals("\r", inbuffer.readLine());
        Assert.assertEquals("", inbuffer.readLine());
        Assert.assertEquals(s1, inbuffer.readLine());
        Assert.assertEquals(s2, inbuffer.readLine());
        Assert.assertEquals(s3, inbuffer.readLine());
        Assert.assertEquals("a", inbuffer.readLine());
        Assert.assertNull(inbuffer.readLine());
        Assert.assertNull(inbuffer.readLine());
        final long bytesRead = inbuffer.getMetrics().getBytesTransferred();
        Assert.assertEquals(bytesWritten, bytesRead);
    }
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.