Package org.apache.http.nio.reactor

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


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

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

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


        line.clear();
        final SessionInputBuffer inbuf2 = new SessionInputBufferImpl(32, 32,
                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

        final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16, null, this.allocator);
        final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, null, this.allocator);

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

        inbuf.fill(inChannel);

        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));

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

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

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

        outbuf.writeLine(line);

        inbuf.fill(inChannel);

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

        outbuf.flush(outChannel);

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

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, null, this.allocator);
        inbuf.fill(channel);

        for (final String teststr : teststrs) {
            Assert.assertEquals(teststr, inbuf.readLine(true));
        }
        Assert.assertNull(inbuf.readLine(true));
View Full Code Here

        outbuf.flush(outChannel);

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

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, null, this.allocator);
        inbuf.fill(channel);

        Assert.assertEquals("a", inbuf.readLine(true));
        Assert.assertEquals("", inbuf.readLine(true));
        Assert.assertEquals("\r", inbuf.readLine(true));
        Assert.assertEquals("", inbuf.readLine(true));
View Full Code Here

        for (int i = 0; i < out.length; i++) {
            out[i] = (byte)('0' + i);
        }
        final ReadableByteChannel channel = newChannel(out);
        final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, null, this.allocator);
        while (inbuf.fill(channel) > 0) {
        }

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

    @Test
    public void testReadByteBuffer() throws Exception {
        final byte[] pattern = "0123456789ABCDEF".getBytes(Consts.ASCII);
        final ReadableByteChannel channel = newChannel(pattern);
        final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
        while (inbuf.fill(channel) > 0) {
        }
        final ByteBuffer dst = ByteBuffer.allocate(10);
        Assert.assertEquals(10, inbuf.read(dst));
        dst.flip();
        Assert.assertEquals(dst, ByteBuffer.wrap(pattern, 0, 10));
View Full Code Here

    @Test
    public void testReadByteBufferWithMaxLen() throws Exception {
        final byte[] pattern = "0123456789ABCDEF".getBytes(Consts.ASCII);
        final ReadableByteChannel channel = newChannel(pattern);
        final SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, null, this.allocator);
        while (inbuf.fill(channel) > 0) {
        }
        final ByteBuffer dst = ByteBuffer.allocate(16);
        Assert.assertEquals(10, inbuf.read(dst, 10));
        dst.flip();
        Assert.assertEquals(dst, ByteBuffer.wrap(pattern, 0, 10));
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.