Package io.netty.channel.embedded

Examples of io.netty.channel.embedded.EmbeddedChannel.finish()


        final FullHttpResponse response = channel.readOutbound();
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.OK));
        assertThat(response.content().toString(CharsetUtil.UTF_8), equalTo("o" + '\n'));
        assertThat(response.getProtocolVersion(), equalTo(HttpVersion.HTTP_1_1));
        SockJsTestUtil.verifyDefaultResponseHeaders(response, Transports.CONTENT_TYPE_JAVASCRIPT);
        channel.finish();
    }

    private static FullHttpRequest request(final String body, HttpVersion httpVersion) {
        final DefaultFullHttpRequest r = new DefaultFullHttpRequest(httpVersion, HttpMethod.GET, "/test");
        if (body != null) {
View Full Code Here


        final JsonpSendTransport transport = new JsonpSendTransport(SockJsConfig.withPrefix("/test")
                .cookiesNeeded().build());
        final EmbeddedChannel channel = new EmbeddedChannel(transport);
        channel.writeInbound(request);
        final FullHttpResponse response = channel.readOutbound();
        channel.finish();
        return response;
    }

    private static FullHttpRequest requestWithBody(final String body) {
        return requestWithBody(body, HttpVersion.HTTP_1_1);
View Full Code Here

        assertThat(prelude.content().readableBytes(), is(PRELUDE_SIZE));
        prelude.content().readBytes(Unpooled.buffer(PRELUDE_SIZE));

        final DefaultHttpContent openResponse = ch.readOutbound();
        assertThat(openResponse.content().toString(CharsetUtil.UTF_8), equalTo("o\n"));
        ch.finish();
    }

    private static EmbeddedChannel newStreamingChannel() {
        return newStreamingChannel(SockJsConfig.withPrefix("/test").cookiesNeeded().build());
    }
View Full Code Here

        final JsonpPollingTransport jsonpPollingOutbound = new JsonpPollingTransport(config, request);
        final EmbeddedChannel ch = new EmbeddedChannel(jsonpPollingOutbound);
        ch.writeInbound(request);
        ch.writeOutbound(frame);
        final FullHttpResponse response =  ch.readOutbound();
        ch.finish();
        return response;
    }

}
View Full Code Here

        final XhrSendTransport transport = new XhrSendTransport(SockJsConfig.withPrefix("/test")
                .cookiesNeeded().build());
        final EmbeddedChannel channel = new EmbeddedChannel(transport);
        channel.writeInbound(request);
        final FullHttpResponse response = channel.readOutbound();
        channel.finish();
        return response;
    }

    private static FullHttpRequest requestWithBody(final String body) {
        return requestWithBody(body, HttpVersion.HTTP_1_1);
View Full Code Here

        final FullHttpResponse validSend = xhrSendRequest(sessionUrl, "[\"x\"]", service);
        assertThat(validSend.getStatus(), is(HttpResponseStatus.NO_CONTENT));

        final DefaultHttpContent messageChunk = ch.readOutbound();
        assertThat(messageChunk.content().toString(UTF_8), equalTo("<script>\np(\"a[\\\"x\\\"]\");\n</script>\r\n"));
        ch.finish();
    }

    /*
     * Equivalent to HtmlFile.test_no_callback in sockjs-protocol-0.3.3.py.
     */
 
View Full Code Here

        // Discard Switching Protocols response
        ch.readOutbound();
        ch.writeInbound(new TextWebSocketFrame("Hello world!\uffff"));
        final TextWebSocketFrame textFrame = (TextWebSocketFrame) readOutboundDiscardEmpty(ch);
        assertThat(textFrame.text(), equalTo("Hello world!\uffff"));
        ch.finish();
    }

    /*
     * Equivalent to RawWebsocket.test_close in sockjs-protocol-0.3.3.py.
     */
 
View Full Code Here

    public void rawWebsocketTestClose() throws Exception {
        final SockJsServiceFactory closeFactory = closeService();
        final EmbeddedChannel ch = wsChannelForService(closeFactory);
        ch.writeInbound(webSocketUpgradeRequest(closeFactory.config().prefix() + "/websocket"));
        assertThat(ch.isActive(), is(false));
        ch.finish();
    }

    @Test
    public void webSocketCloseSession() throws Exception {
        final String serviceName = "/closesession";
View Full Code Here

        final FullHttpRequest request = httpRequest(url, GET);
        final EmbeddedChannel ch = jsonpChannelForService(service);
        removeLastInboundMessageHandlers(ch);
        ch.writeInbound(request);
        final FullHttpResponse response = ch.readOutbound();
        ch.finish();
        return response;
    }

    private static FullHttpResponse jsonpSend(final FullHttpRequest request, final SockJsServiceFactory service) {
        final EmbeddedChannel ch = jsonpChannelForService(service);
View Full Code Here

                if (out instanceof FullHttpResponse) {
                    return (FullHttpResponse) out;
                }
            }
        } finally {
            ch.finish();
        }
        throw new IllegalStateException("No outbound FullHttpResponse was written");
    }

    private static FullHttpResponse jsonpSend(final String url, final String content,
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.