@Test
 public void iframeUppercase() throws Exception {
   final SockJsConfig config = config();
   final String path = config.prefix() + "/IFRAME";
   final FullHttpResponse response = Iframe.response(config, createHttpRequest(path));
   assertThat(response.getStatus().code(), is(HttpResponseStatus.NOT_FOUND.code()));
 }
 @Test
 public void ifNoneMatchHeader() throws Exception {
   final SockJsConfig config = config();
   final String path = config.prefix() + "/iframe.html";
   final HttpRequest httpRequest = createHttpRequest(path);
   httpRequest.headers().set(HttpHeaders.Names.IF_NONE_MATCH, "*");
   final FullHttpResponse response = Iframe.response(config, httpRequest);
   assertThat(
       response.headers().get(HttpHeaders.Names.SET_COOKIE), equalTo("JSESSIONID=dummy; path=/"));
   assertThat(response.getStatus().code(), is(HttpResponseStatus.NOT_MODIFIED.code()));
 }
 @Test
 public void iframeHtml() throws Exception {
   final SockJsConfig config = config();
   final String path = config.prefix() + "/iframe.html";
   final FullHttpResponse response = Iframe.response(config, createHttpRequest(path));
   assertThat(response.getStatus().code(), is(HttpResponseStatus.OK.code()));
   assertThat(
       response.headers().get(HttpHeaders.Names.CONTENT_TYPE),
       equalTo("text/html; charset=UTF-8"));
   assertThat(
       response.headers().get(HttpHeaders.Names.CACHE_CONTROL),
       equalTo("max-age=31536000, public"));
   assertThat(response.headers().get(HttpHeaders.Names.EXPIRES), is(notNullValue()));
   assertThat(response.headers().get(HttpHeaders.Names.SET_COOKIE), is(nullValue()));
   assertThat(response.headers().get(HttpHeaders.Names.ETAG), is(notNullValue()));
 }
  /**
   * Starts the server using the passed in configuration options. Options:
   *
   * <pre>
   * -host=localhost -port=8888 -tls=false -ack_interval=10000 -useragent_reaper_timeout=60000 -token_key=testing
   * </pre>
   *
   * @param args the command line arguments passed.
   * @throws Exception
   */
  public static void main(final String[] args) throws Exception {
    final Map<Args, Option<?>> options = Options.options(args);

    final String host = value(Args.HOST, options, "localhost");
    final int port = value(Args.PORT, options, 7777);
    final SimplePushServerConfig simplePushConfig =
        DefaultSimplePushConfig.create(host, port)
            .userAgentReaperTimeout(Options.<Long>value(Args.USERAGENT_REAPER_TIMEOUT, options))
            .ackInterval(Options.<Long>value(Args.ACK_INTERVAL, options))
            .tokenKey(Options.<String>value(Args.TOKEN_KEY, options))
            .build();

    final SockJsConfig sockJSConfig =
        SockJsConfig.withPrefix("/simplepush")
            .tls(Options.value(Args.TLS, options, false))
            .webSocketProtocols("push-notification")
            .cookiesNeeded()
            .sessionTimeout(60000)
            .build();
    new NettySockJSServer(options, simplePushConfig, sockJSConfig).run();
  }
 private SockJsConfig config() {
   return SockJsConfig.withPrefix("/simplepush")
       .sockJsUrl("http://cdn.sockjs.org/sockjs-0.3.4.min.js")
       .build();
 }
 @Test
 public void sockjsPrefix() {
   assertThat(sockJsConfig.prefix(), equalTo("/mysimplepush"));
 }
 @Test
 public void sockjsWebSocketProtocols() {
   assertThat(sockJsConfig.webSocketProtocol(), hasItems("push-notification", "myproto"));
 }
 @Test
 public void sockjsWebSocketHeartbeatInterval() {
   assertThat(sockJsConfig.webSocketHeartbeatInterval(), is(180000L));
 }
 @Test
 public void sockjsCookiesNeeded() {
   assertThat(sockJsConfig.areCookiesNeeded(), is(true));
 }
 @Test
 public void sockjsTls() {
   assertThat(sockJsConfig.isTls(), is(true));
 }
 @Test
 public void sockjsKeystorePassword() {
   assertThat(sockJsConfig.keyStorePassword(), equalTo("simplepush"));
 }
 @Test
 public void sockjsKeystore() {
   assertThat(sockJsConfig.keyStore(), equalTo("/simplepush-sample.keystore"));
 }
 @Test
 public void sockjsMaxStreamingBytesSize() {
   assertThat(sockJsConfig.maxStreamingBytesSize(), is(65356));
 }
 @Test
 public void sockjsHeartbeatInterval() {
   assertThat(sockJsConfig.heartbeatInterval(), is(40000L));
 }
 @Test
 public void sockjsSessionTimeout() {
   assertThat(sockJsConfig.sessionTimeout(), is(25000L));
 }
 @Test
 public void sockjsUrl() {
   assertThat(sockJsConfig.sockJsUrl(), equalTo("http://someurl/sockjs.js"));
 }
 private static SockJsConfig config() {
   return SockJsConfig.withPrefix("/simplepush")
       .sockJsUrl("http://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js")
       .build();
 }
 @Test
 public void sockjsWebSocketEnable() {
   assertThat(sockJsConfig.isWebSocketEnabled(), is(false));
 }