@AfterClass
  public static void teardown() throws Exception {
    if (server != null) {
      try {
        server.undeployConfig();
      } catch (Throwable t) {
        logger.error("Failed to undeploy application", t);
      }

      try {
        server.stop();
      } catch (Throwable t) {
        logger.error("Failed to stop server", t);
      }
    }
  }
  @BeforeClass
  public static void setup() throws Exception {

    // Since test classpath includes both embedded Tomcat and Jetty we need to
    // set a Spring profile explicitly to bypass WebSocket engine detection.
    // See {@link org.springframework.samples.portfolio.config.WebSocketConfig}

    // This test is not supported with Jetty because it doesn't seem to support
    // deployment withspecific ServletContainerInitializer's at for testing

    System.setProperty("spring.profiles.active", "test.tomcat");

    port = SocketUtils.findAvailableTcpPort();

    server = new TomcatWebSocketTestServer(port);
    server.deployConfig(DispatcherServletInitializer.class, WebSecurityInitializer.class);
    server.start();

    loginAndSaveJsessionIdCookie("fabrice", "fab123", headers);
  }