@Override public void init(ServletConfig config) throws ServletException { super.init(config); try { String ip = config.getInitParameter("org.zincapi.server.init"); if (ip != null) global = Reflection.callStatic(ip, "initZinc", zinc); } catch (Exception ex) { throw new ServletException(ex); } try { /* AsyncProcessor support = new AsyncProcessor(framework.getAtmosphereConfig()); support.morphToTextMessages(); */ AsyncSupport<?> support = (AsyncSupport<?>) Reflection.create( this.getClass().getClassLoader(), "org.atmosphere.container.Tomcat7AsyncSupportWithWebSocket", framework.getAtmosphereConfig()); framework.setAsyncSupport(support); framework.addAtmosphereHandler("/*", new TomcatResponder(zinc)); framework.init(config); } catch (Exception ex) { throw new ServletException(ex); } }
@BeforeMethod public void create() throws Throwable { framework = new AtmosphereFramework(); framework.setDefaultBroadcasterClassName(SimpleBroadcaster.class.getName()); framework.addAnnotationPackage(ManagedGet.class); framework .setAsyncSupport( new AsynchronousProcessor(framework.getAtmosphereConfig()) { @Override public Action service(AtmosphereRequest req, AtmosphereResponse res) throws IOException, ServletException { return suspended(req, res); } public void action(AtmosphereResourceImpl r) { try { resumed(r.getRequest(), r.getResponse()); } catch (IOException e) { e.printStackTrace(); } catch (ServletException e) { e.printStackTrace(); } } }) .init( new ServletConfig() { @Override public String getServletName() { return "void"; } @Override public ServletContext getServletContext() { return mock(ServletContext.class); } @Override public String getInitParameter(String name) { return ApplicationConfig.CLIENT_HEARTBEAT_INTERVAL_IN_SECONDS.equals(name) ? "10" : null; } @Override public Enumeration<String> getInitParameterNames() { return null; } }); }