Examples of writeInbound()


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

    public void invalidHttpMethod() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, POST, "dummy");
        request.retain();
        ch.writeInbound(request);
        final HttpResponse response = decode(ch);
        assertThat(response.getStatus(), is(METHOD_NOT_ALLOWED));
        assertThat(response.headers().get(ALLOW), is(GET.toString()));
    }
View Full Code Here

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

    public void nonUpgradeRequest() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/websocket");
        request.retain();
        ch.writeInbound(request);
        final FullHttpResponse response = decodeFullHttpResponse(ch);
        assertThat(response.getStatus(), is(BAD_REQUEST));
        assertThat(response.headers().get(CONTENT_TYPE), is(Transports.CONTENT_TYPE_PLAIN));
        assertThat(response.content().toString(CharsetUtil.UTF_8), equalTo("Can \"Upgrade\" only to \"WebSocket\"."));
    }
View Full Code Here

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

        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        final FullHttpRequest request = webSocketUpgradeRequest("/websocket", WebSocketVersion.V13);
        request.headers().set(UPGRADE, "WebSocket");
        request.headers().set(CONNECTION, "close");
        ch.writeInbound(request);
        final FullHttpResponse response = decodeFullHttpResponse(ch);
        assertThat(response.getStatus(), is(BAD_REQUEST));
        assertThat(response.content().toString(CharsetUtil.UTF_8), equalTo("\"Connection\" must be \"Upgrade\"."));
    }
View Full Code Here

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

    public void invalidJsonInWebSocketFrame() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        assertUpgradeRequest(ch);

        ch.writeInbound(new TextWebSocketFrame("[invalidJson"));
        assertThat(ch.isOpen(), is(false));
    }

    @Test
    public void writeJsonArray() throws Exception {
View Full Code Here

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

    public void writeJsonArray() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        assertUpgradeRequest(ch);

        ch.writeInbound(new TextWebSocketFrame("[\"x\",\"y\"]"));
        // Discard of the HttpRequest
        ch.readInbound();
        final String x = ch.readInbound();
        assertThat(x, equalTo("x"));
        final String y = ch.readInbound();
View Full Code Here

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

    public void writeJsonString() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        assertUpgradeRequest(ch);

        ch.writeInbound(new TextWebSocketFrame("\"x\""));
        // Discard of the HttpRequest
        ch.readInbound();
        final String message = ch.readInbound();
        assertThat(message, equalTo("x"));
    }
View Full Code Here

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

    public void firefox602ConnectionHeader() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        final FullHttpRequest request = webSocketUpgradeRequest("/websocket", WebSocketVersion.V08);
        request.headers().set(CONNECTION, "keep-alive, Upgrade");
        ch.writeInbound(request);
        final HttpResponse response = decode(ch);
        assertThat(response.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS));
        assertThat(response.headers().get(CONNECTION), equalTo("Upgrade"));
        request.release();
    }
View Full Code Here

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

    private static void verifyHeaders(final WebSocketVersion version) throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        final FullHttpRequest request = webSocketUpgradeRequest("/websocket", version);
        ch.writeInbound(request);
        final HttpResponse response = decode(ch);
        assertThat(response.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS));
        assertThat(response.headers().get(CONNECTION), equalTo("Upgrade"));
        assertThat(response.headers().get(UPGRADE), equalTo("websocket"));
        assertThat(response.headers().get(CONTENT_LENGTH), is(nullValue()));
View Full Code Here

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

    @Test
    public void writeMissingCallback() {
        final String url = "/test/htmlfile?c=";
        final EmbeddedChannel ch = newHtmlFileChannel(url);
        ch.writeInbound(new DefaultHttpRequest(HTTP_1_1, GET, url));
        final HttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), equalTo(INTERNAL_SERVER_ERROR));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo(Transports.CONTENT_TYPE_PLAIN));
        verifyNoCacheHeaders(response);
    }
View Full Code Here

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

    @Test
    public void write() throws IOException {
        final String url = "/test/htmlfile?c=%63allback";
        final EmbeddedChannel ch = newHtmlFileChannel("/test/htmlfile?c=%63allback");
        ch.writeInbound(new DefaultHttpRequest(HTTP_1_1, GET, url));
        ch.writeOutbound(new OpenFrame());

        final HttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), equalTo(OK));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo(Transports.CONTENT_TYPE_HTML));
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.