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

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


        assertThat(lastChunk.content().toString(UTF_8), equalTo(""));
    }

    @Test
    public void prefixNotFound() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/simplepush").cookiesNeeded().build();
        final EmbeddedChannel ch = channelForMockService(config);
        ch.writeInbound(httpRequest("/missing"));
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus().code(), is(HttpResponseStatus.NOT_FOUND.code()));
    }
View Full Code Here


    }

    private static void assertSetCookie(final String transportPath) {
        final String serviceName = "/cookie_needed_echo";
        final String sessionUrl = serviceName + "/abc/" + UUID.randomUUID().toString();
        final SockJsConfig config = SockJsConfig.withPrefix(serviceName).cookiesNeeded().build();
        final EmbeddedChannel ch = channelForService(echoService(config));
        removeLastInboundMessageHandlers(ch);
        final FullHttpRequest request = httpRequest(sessionUrl + transportPath, GET);
        ch.writeInbound(request);
        final HttpResponse response = ch.readOutbound();
View Full Code Here

        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        assertThat(response.content().toString(UTF_8), equalTo("o\n"));
    }

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

        }
        return req;
    }

    private static SockJsServiceFactory closeService() {
        final SockJsConfig config = SockJsConfig.withPrefix("/close").build();
        return new AbstractSockJsServiceFactory(config) {
            @Override
            public SockJsService create() {
                return new CloseService(config);
            }
View Full Code Here

            }
        };
    }

    private static SockJsServiceFactory echoService() {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").cookiesNeeded().build();
        return new AbstractSockJsServiceFactory(config) {
            @Override
            public SockJsService create() {
                return new EchoService(config);
            }
View Full Code Here

    }

    private static void webSocketTestTransport(final WebSocketVersion version) {
        final String serviceName = "/echo";
        final String sessionUrl = serviceName + "/222/" + UUID.randomUUID().toString();
        final SockJsConfig config = SockJsConfig.withPrefix(serviceName).build();
        final SockJsServiceFactory service = echoService(config);
        final EmbeddedChannel ch = wsChannelForService(service);

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

    }

    private static void webSocketTestClose(final WebSocketVersion version) {
        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", version.toHttpHeaderValue());
        ch.writeInbound(request);
View Full Code Here

    }

    private static void webSocketTestBrokenJSON(final WebSocketVersion version) {
        final String serviceName = "/close";
        final String sessionUrl = serviceName + "/222/" + UUID.randomUUID().toString();
        final SockJsConfig config = SockJsConfig.withPrefix(serviceName).build();
        final EmbeddedChannel ch = wsChannelForService(echoService(config));

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

    private static void removeLastInboundMessageHandlers(final EmbeddedChannel ch) {
        ch.pipeline().remove("EmbeddedChannel$LastInboundHandler#0");
    }

    private static void assertOKResponse(final String sessionPart) {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").cookiesNeeded().build();
        final EmbeddedChannel ch = channelForMockService(config);
        removeLastInboundMessageHandlers(ch);
        ch.writeInbound(httpRequest("/echo" + sessionPart + Transports.Type.XHR.path()));
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
View Full Code Here

        assertThat(headers.get(EXPIRES), is(notNullValue()));
        assertThat(headers.get(SET_COOKIE), is("JSESSIONID=dummy;path=/"));
    }

    private static void verifyIframe(final String service, final String path) {
        final SockJsConfig config = SockJsConfig.withPrefix(service).cookiesNeeded().build();
        final EmbeddedChannel ch = channelForMockService(config);
        ch.writeInbound(httpRequest(config.prefix() + path));
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus().code(), is(HttpResponseStatus.OK.code()));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo("text/html; charset=UTF-8"));
        assertThat(response.headers().get(CACHE_CONTROL), equalTo("max-age=31536000, public"));
        assertThat(response.headers().get(EXPIRES), is(notNullValue()));
        verifyNoSET_COOKIE(response);
        assertThat(response.headers().get(ETAG), is(notNullValue()));
        assertThat(response.content().toString(UTF_8), equalTo(iframeHtml(config.sockJsUrl())));
    }
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.