Package org.apache.http.nio.reactor

Examples of org.apache.http.nio.reactor.SessionInputBuffer.fill()


        outbuf.flush(outChannel);

        ReadableByteChannel channel = newChannel(outstream.toByteArray());
       
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, params);
        inbuf.fill(channel);
       
        for (int i = 0; i < teststrs.length; i++) {
            assertEquals(teststrs[i], inbuf.readLine(true));
        }
        assertNull(inbuf.readLine(true));
View Full Code Here


        outbuf.flush(outChannel);

        ReadableByteChannel channel = newChannel(outstream.toByteArray());

        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, params);
        inbuf.fill(channel);
       
        assertEquals("a", inbuf.readLine(true));
        assertEquals("", inbuf.readLine(true));
        assertEquals("\r", inbuf.readLine(true));
        assertEquals("", inbuf.readLine(true));
View Full Code Here

            out[i] = (byte)('0' + i);
        }
        ReadableByteChannel channel = newChannel(out);       
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
        while (inbuf.fill(channel) > 0) {
        }

        byte[] in = new byte[40];
        for (int i = 0; i < in.length; i++) {
            in[i] = (byte)inbuf.read();
View Full Code Here

        byte[] tmp = outstream.toByteArray();
       
        ReadableByteChannel channel = newChannel(tmp);       
        SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
       
        while (inbuf.fill(channel) > 0) {
        }
       
        for (int i = 0; i < 10; i++) {
            assertEquals(s1, inbuf.readLine(true));
            assertEquals(s2, inbuf.readLine(true));
View Full Code Here

        }
       
        byte[] tmp = s1.getBytes("ISO-8859-1");       
        ReadableByteChannel channel = newChannel(tmp);       
        SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
        while (inbuf.fill(channel) > 0) {
        }
       
        try {
            String s = inbuf.readLine(true);
            fail("Expected CharacterCodingException, got '" + s + "'");
View Full Code Here

    public void testReadLineChunks() throws Exception {
        final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, null, this.allocator);

        ReadableByteChannel channel = newChannel("One\r\nTwo\r\nThree");

        inbuf.fill(channel);

        final CharArrayBuffer line = new CharArrayBuffer(64);

        line.clear();
        Assert.assertTrue(inbuf.readLine(line, false));
View Full Code Here

        line.clear();
        Assert.assertFalse(inbuf.readLine(line, false));

        channel = newChannel("\r\nFour");
        inbuf.fill(channel);

        line.clear();
        Assert.assertTrue(inbuf.readLine(line, false));
        Assert.assertEquals("Three", line.toString());
View Full Code Here

        line.clear();
        Assert.assertTrue(inbuf.readLine(line, false));
        Assert.assertEquals("Three", line.toString());

        inbuf.fill(channel);

        line.clear();
        Assert.assertTrue(inbuf.readLine(line, true));
        Assert.assertEquals("Four", line.toString());
View Full Code Here

        final String s = "LoooooooooooooooooooooooooOOOOOOOOOOOOOOOOOOoooooooooooooooooooooong line\r\n";
        final CharArrayBuffer line = new CharArrayBuffer(64);
        final SessionInputBuffer inbuf1 = new SessionInputBufferImpl(128, 128,
                MessageConstraints.DEFAULT, null, this.allocator);
        final ReadableByteChannel channel1 = newChannel(s);
        inbuf1.fill(channel1);

        Assert.assertTrue(inbuf1.readLine(line, false));

        line.clear();
        final SessionInputBuffer inbuf2 = new SessionInputBufferImpl(128, 128,
View Full Code Here

        line.clear();
        final SessionInputBuffer inbuf2 = new SessionInputBufferImpl(128, 128,
                MessageConstraints.lineLen(10), null, this.allocator);
        final ReadableByteChannel channel2 = newChannel(s);
        inbuf2.fill(channel2);
        try {
            inbuf2.readLine(line, false);
            Assert.fail("MessageConstraintException expected");
        } catch (MessageConstraintException ex) {
        }
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.