Package java.nio.channels

Examples of java.nio.channels.ReadableByteChannel


       
        HttpParams params = new BasicHttpParams();
        SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16, params);
        SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
       
        ReadableByteChannel inChannel = newChannel("One\r\nTwo\r\nThree");
       
        inbuf.fill(inChannel);
       
        CharArrayBuffer line = new CharArrayBuffer(64);
       
View Full Code Here


       
        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
        WritableByteChannel outChannel = newChannel(outstream);
        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++) {
View Full Code Here

       
        ByteArrayOutputStream outstream = new ByteArrayOutputStream();
        WritableByteChannel outChannel = newChannel(outstream);
        outbuf.flush(outChannel);

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

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

        // make the buffer larger than that of transmitter
        byte[] out = new byte[40];
        for (int i = 0; i < out.length; i++) {
            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) {
        }
View Full Code Here

        WritableByteChannel outChannel = newChannel(outstream);
        outbuf.flush(outChannel);

        byte[] tmp = outstream.toByteArray();
       
        ReadableByteChannel channel = newChannel(tmp);       
        SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, params);
       
        while (inbuf.fill(channel) > 0) {
        }
       
View Full Code Here

        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, null, requestFactory, params);
       
        ReadableByteChannel channel = newChannel("GET /whatever HTTP/1.0");
        requestParser.fillBuffer(channel);
        requestParser.fillBuffer(channel);
        HttpRequest request = (HttpRequest) requestParser.parse();
        assertNotNull(request);
        assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getProtocolVersion());
View Full Code Here

        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, null, requestFactory, params);
       
        ReadableByteChannel channel = newChannel("GET /whatever HTTP/1.0\r\nHeader: whatever");
        requestParser.fillBuffer(channel);
        requestParser.fillBuffer(channel);
        HttpRequest request = (HttpRequest) requestParser.parse();
        assertNotNull(request);
        assertEquals(1, request.getAllHeaders().length);
View Full Code Here

        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, null, requestFactory, params);
       
        ReadableByteChannel channel = newChannel("GET garbage\r\n");
        requestParser.fillBuffer(channel);
        try {
            requestParser.parse();
            fail("HttpException should have been thrown");
        } catch (HttpException ex) {
View Full Code Here

        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
        HttpResponseParser responseParser = new HttpResponseParser(inbuf, null, responseFactory, params);
       
        ReadableByteChannel channel = newChannel("HTTP 200 OK\r\n");
        responseParser.fillBuffer(channel);
        try {
            responseParser.parse();
            fail("HttpException should have been thrown");
        } catch (HttpException ex) {
View Full Code Here

        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpResponseFactory responseFactory = new DefaultHttpResponseFactory();
        HttpResponseParser responseParser = new HttpResponseParser(inbuf, null, responseFactory, params);
       
        ReadableByteChannel channel = newChannel("HTTP/1.0 200 OK\r\nstuff\r\n\r\n");
        responseParser.fillBuffer(channel);
        try {
            responseParser.parse();
            fail("HttpException should have been thrown");
        } catch (HttpException ex) {
View Full Code Here

TOP

Related Classes of java.nio.channels.ReadableByteChannel

Copyright © 2018 www.massapicom. 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.