Package org.jboss.aerogear.io.netty.handler.codec.sockjs

Examples of org.jboss.aerogear.io.netty.handler.codec.sockjs.SockJsConfig


    private static long getEntropy(final FullHttpResponse response) throws Exception {
        return contentAsJson(response).get("entropy").asLong();
    }

    private static void assertNotFoundResponse(final String service, final String path) {
        final SockJsConfig config = SockJsConfig.withPrefix(service).cookiesNeeded().build();
        final EmbeddedChannel ch = channelForMockService(config);
        ch.writeInbound(httpRequest('/' + service + path));
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.NOT_FOUND));
    }
View Full Code Here


     */
    @Test
    public void webSocketHixie76TestClose() throws Exception {
        final String serviceName = "/close";
        final String sessionUrl = serviceName + "/222/" + UUID.randomUUID().toString();
        final SockJsConfig config = SockJsConfig.withPrefix(serviceName).build();
        final SockJsServiceFactory service = closeService(config);
        final EmbeddedChannel ch = wsChannelForService(service);

        final FullHttpRequest request = webSocketUpgradeRequest(sessionUrl + "/websocket", WebSocketVersion.V00);
        ch.writeInbound(request);
View Full Code Here

        new XhrPollingTransport(SockJsConfig.withPrefix("/test").build(), null);
    }

    @Test
    public void flush() {
        final SockJsConfig config = SockJsConfig.withPrefix("/test").cookiesNeeded().build();
        final XhrPollingTransport transport = new XhrPollingTransport(config, request("", HttpVersion.HTTP_1_1));
        final EmbeddedChannel channel = new EmbeddedChannel(transport);
        channel.writeOutbound(new OpenFrame());
        final FullHttpResponse response = channel.readOutbound();
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.OK));
View Full Code Here

public class WebSocketTransportTest {

    @Test
    public void upgradeRequest() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        assertUpgradeRequest(ch);
    }
View Full Code Here

        assertUpgradeRequest(ch);
    }

    @Test
    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);
View Full Code Here

        assertThat(response.headers().get(ALLOW), is(GET.toString()));
    }

    @Test
    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);
View Full Code Here

        assertThat(response.content().toString(CharsetUtil.UTF_8), equalTo("Can \"Upgrade\" only to \"WebSocket\"."));
    }

    @Test
    public void invalidConnectionHeader() throws Exception {
        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);
View Full Code Here

        assertThat(response.content().toString(CharsetUtil.UTF_8), equalTo("\"Connection\" must be \"Upgrade\"."));
    }

    @Test
    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));
View Full Code Here

        assertThat(ch.isOpen(), is(false));
    }

    @Test
    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
View Full Code Here

        assertThat(y, equalTo("y"));
    }

    @Test
    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
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.io.netty.handler.codec.sockjs.SockJsConfig

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.