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

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


    /*
     * Equivalent to BaseUrlGreeting.test_greeting in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void baseUrlGreetingTestGreeting() throws Exception {
        final SockJsServiceFactory factory = echoService();
        final EmbeddedChannel ch = channelForMockService(factory.config());
        ch.writeInbound(httpRequest(factory.config().prefix()));
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus().code(), is(HttpResponseStatus.OK.code()));
        assertThat(response.headers().get(CONTENT_TYPE), equalTo("text/plain; charset=UTF-8"));
        assertThat(response.content().toString(UTF_8), equalTo("Welcome to SockJS!\n"));
        verifyNoSET_COOKIE(response);
View Full Code Here


    /*
     * Equivalent to IframePage.test_cacheability in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void iframeCachability() throws Exception {
        final SockJsServiceFactory factory = echoService();
        EmbeddedChannel ch = channelForMockService(factory.config());
        ch.writeInbound(httpRequest(factory.config().prefix() + "/iframe.html"));
        final String etag1 = getEtag((FullHttpResponse) ch.readOutbound());

        ch = channelForMockService(factory.config());
        ch.writeInbound(httpRequest(factory.config().prefix() + "/iframe.html"));
        final String etag2 = getEtag((FullHttpResponse) ch.readOutbound());
        assertThat(etag1, equalTo(etag2));

        final FullHttpRequest requestWithEtag = httpRequest(factory.config().prefix() + "/iframe.html");
        requestWithEtag.headers().set(IF_NONE_MATCH, etag1);
        ch = channelForMockService(factory.config());
        ch.writeInbound(requestWithEtag);
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), equalTo(HttpResponseStatus.NOT_MODIFIED));
        assertThat(response.headers().get(CONTENT_TYPE), is(nullValue()));
        assertThat(response.content().isReadable(), is(false));
View Full Code Here

    /*
     * Equivalent to InfoTest.test_basic in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void infoTestBasic() throws Exception {
        final SockJsServiceFactory factory = echoService();
        final FullHttpResponse response = infoForMockService(factory);
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        verifyContentType(response, "application/json; charset=UTF-8");
        verifyNoSET_COOKIE(response);
        verifyNotCached(response);
View Full Code Here

    /*
     * Equivalent to InfoTest.test_entropy in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void infoTestEntropy() throws Exception {
        final SockJsServiceFactory factory = echoService();
        final FullHttpResponse response1 = infoForMockService(factory);
        final FullHttpResponse response2 = infoForMockService(factory);
        assertThat(getEntropy(response1) != getEntropy(response2), is(true));
    }
View Full Code Here

    /*
     * Equivalent to InfoTest.test_options in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void infoTestOptions() throws Exception {
        final SockJsServiceFactory factory = echoService();
        final EmbeddedChannel ch = channelForMockService(factory.config());
        ch.writeInbound(httpRequest(factory.config().prefix(), OPTIONS));
        final HttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.NO_CONTENT));
        assertCORSPreflightResponseHeaders(response);
        SockJsTestUtil.assertCORSHeaders(response, "*");
    }
View Full Code Here

    /*
     * Equivalent to InfoTest.test_options_null_origin in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void infoTestOptionsNullOrigin() throws Exception {
        final SockJsServiceFactory factory = echoService();
        final EmbeddedChannel ch = channelForMockService(factory.config());
        final FullHttpRequest request = httpRequest(factory.config().prefix() + "/info", OPTIONS);
        request.headers().set(ORIGIN, "null");
        ch.writeInbound(request);
        final HttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.NO_CONTENT));
        assertCORSPreflightResponseHeaders(response);
View Full Code Here

    /*
     * Equivalent to InfoTest.test_disabled_websocket in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void infoTestDisabledWebsocket() throws Exception {
        final SockJsServiceFactory factory = echoService(SockJsConfig.withPrefix("echo").disableWebSocket().build());
        final EmbeddedChannel ch = channelForMockService(factory.config());
        ch.writeInbound(httpRequest(factory.config().prefix() + "/info"));
        final FullHttpResponse response = ch.readOutbound();
        assertThat(response.getStatus(), is(HttpResponseStatus.OK));
        assertThat(contentAsJson(response).get("websocket").asBoolean(), is(false));
    }
View Full Code Here

    /*
     * Equivalent to SessionURLs.test_ignoringServerId in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void sessionUrlsTestIgnoringServerId() throws Exception {
        final SockJsServiceFactory factory = echoService();
        final String sessionId = UUID.randomUUID().toString();
        final String sessionUrl = factory.config().prefix() + "/000/" + sessionId;

        final FullHttpResponse openSessionResponse = xhrRequest(sessionUrl, factory);
        assertOpenFrameResponse(openSessionResponse);

        final FullHttpResponse sendResponse = xhrSendRequest(sessionUrl, "[\"a\"]", factory);
        assertNoContent(sendResponse);

        final FullHttpResponse pollResponse = xhrRequest(factory.config().prefix() + "/999/" + sessionId, factory);
        assertMessageFrameContent(pollResponse, "a");
    }
View Full Code Here

    /*
     * Equivalent to Protocol.test_simpleSession in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void protocolTestSimpleSession() throws Exception {
        final SockJsServiceFactory factory = echoService();
        final String sessionUrl = factory.config().prefix() + "/111/" + UUID.randomUUID().toString();

        final FullHttpResponse openSessionResponse = xhrRequest(sessionUrl, factory);
        assertOpenFrameResponse(openSessionResponse);

        final FullHttpResponse sendResponse = xhrSendRequest(sessionUrl, "[\"a\"]", factory);
View Full Code Here

    /*
     * Equivalent to Protocol.test_closeSession in sockjs-protocol-0.3.3.py.
     */
    @Test
    public void protocolTestCloseSession() throws Exception {
        final SockJsServiceFactory closefactory = closeService();
        final String sessionUrl = closefactory.config().prefix() + "/222/" + UUID.randomUUID().toString();

        final FullHttpResponse openSessionResponse = xhrRequest(sessionUrl, closefactory);
        assertOpenFrameResponse(openSessionResponse);
        assertGoAwayResponse(xhrRequest(sessionUrl, closefactory));
        assertGoAwayResponse(xhrRequest(sessionUrl, closefactory));
View Full Code Here

TOP

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

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.