@Test public void rawWebSocketUpgradeRequest() throws Exception { final SimplePushServerConfig simplePushConfig = DefaultSimplePushConfig.create().password("test").build(); final SockJsConfig sockjsConf = SockJsConfig.withPrefix("/simplepush").webSocketProtocols("push-notification").build(); final byte[] privateKey = CryptoUtil.secretKey(simplePushConfig.password(), "someSaltForTesting".getBytes()); final SimplePushServer pushServer = new DefaultSimplePushServer(new InMemoryDataStore(), simplePushConfig, privateKey); final SimplePushServiceFactory factory = new SimplePushServiceFactory(sockjsConf, pushServer); final EmbeddedChannel channel = createChannel(factory); final FullHttpRequest request = websocketUpgradeRequest(factory.config().prefix() + Transports.Type.WEBSOCKET.path()); request.headers().set(Names.SEC_WEBSOCKET_PROTOCOL, "push-notification"); channel.writeInbound(request); final FullHttpResponse response = decodeFullHttpResponse(channel); assertThat(response.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS)); assertThat(response.headers().get(HttpHeaders.Names.UPGRADE), equalTo("websocket")); assertThat(response.headers().get(HttpHeaders.Names.CONNECTION), equalTo("Upgrade")); assertThat(response.headers().get(Names.SEC_WEBSOCKET_PROTOCOL), equalTo("push-notification")); assertThat(response.headers().get(Names.SEC_WEBSOCKET_ACCEPT), equalTo("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=")); channel.close(); }
@Override public SockJsConfig config() { return sockjsConfig; }
SimplePushSockJSService implements SockJsService { @Override public SockJsConfig config() { return sockjsConfig; } }
SimplePushSockJSService implements SockJsService { @Override public SockJsConfig config() { return sockjsConfig; } SimplePushSockJSService(final SockJsConfig sockjsConfig, final SimplePushServer simplePushServer); }
SimplePushSockJSService implements SockJsService { @Override public SockJsConfig config() { return sockjsConfig; } SimplePushSockJSService(final SockJsConfig sockjsConfig, final SimplePushServer simplePushServer); @Override SockJsConfig config(); @Override void onOpen(final SockJsSessionContext session); @Override @SuppressWarnings("incomplete-switch") void onMessage(final String message); @Override void onClose(); }
SimplePushSockJSService implements SockJsService { @Override public SockJsConfig config() { return sockjsConfig; } SimplePushSockJSService(final SockJsConfig sockjsConfig, final SimplePushServer simplePushServer); @Override SockJsConfig config(); @Override void onOpen(final SockJsSessionContext session); @Override @SuppressWarnings("incomplete-switch") void onMessage(final String message); @Override void onClose();  }