Package org.apache.http.nio.reactor

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


            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


    public void testReadByteBuffer() throws Exception {
        byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
        ReadableByteChannel channel = newChannel(pattern);
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, params);
        while (inbuf.fill(channel) > 0) {
        }
        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

    public void testReadByteBufferWithMaxLen() throws Exception {
        byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
        ReadableByteChannel channel = newChannel(pattern);
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, params);
        while (inbuf.fill(channel) > 0) {
        }
        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

    public void testReadToChannel() throws Exception {
        byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
        ReadableByteChannel channel = newChannel(pattern);
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, params);
        while (inbuf.fill(channel) > 0) {
        }

        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
        WritableByteChannel dst = newChannel(outstream);
View Full Code Here

    public void testReadToChannelWithMaxLen() throws Exception {
        byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
        ReadableByteChannel channel = newChannel(pattern);
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(4096, 1024, params);
        while (inbuf.fill(channel) > 0) {
        }

        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
        WritableByteChannel dst = newChannel(outstream);
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++) {
            Assert.assertEquals(s1, inbuf.readLine(true));
            Assert.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);
            Assert.fail("Expected CharacterCodingException, got '" + s + "'");
View Full Code Here

        HttpParams params = new BasicHttpParams();
       
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        inbuf.fill(channel);
       
        assertEquals(6, inbuf.length());
       
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
                channel, inbuf, metrics, 16);
View Full Code Here

        HttpParams params = new BasicHttpParams();
       
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        inbuf.fill(channel);
        inbuf.fill(channel);
       
        assertEquals(38, inbuf.length());
       
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
View Full Code Here

       
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        inbuf.fill(channel);
        inbuf.fill(channel);
       
        assertEquals(38, inbuf.length());
       
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
                channel, inbuf, metrics, 16);
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.