### Question:
AtmosphereWebSocketServletDestination extends ServletDestination implements
    WebSocketDestinationService { AtmosphereFramework getAtmosphereFramework() { return framework; } AtmosphereWebSocketServletDestination(Bus bus, DestinationRegistry registry, EndpointInfo ei,
                                                 String path); @Override void finalizeConfig(); @Override void onServletConfigAvailable(ServletConfig config); @Override void invoke(ServletConfig config, ServletContext context, HttpServletRequest req,
                       HttpServletResponse resp); @Override void invokeInternal(ServletConfig config, ServletContext context, HttpServletRequest req,
                               HttpServletResponse resp); @Override void shutdown();  }### Answer:
@Test public void testUseCXFDefaultAtmoosphereInterceptor() throws Exception { Bus bus = new ExtensionManagerBus(); DestinationRegistry registry = new HTTPTransportFactory().getRegistry(); EndpointInfo endpoint = new EndpointInfo(); endpoint.setAddress(ENDPOINT_ADDRESS); endpoint.setName(ENDPOINT_NAME); AtmosphereWebSocketServletDestination dest = new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS); List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors(); int added = 0; for (AtmosphereInterceptor a : ais) { if (DefaultProtocolInterceptor.class.equals(a.getClass())) { added++; break; } } assertEquals(1, added); }
@Test public void testUseCustomAtmoosphereInterceptor() throws Exception { Bus bus = new ExtensionManagerBus(); bus.setProperty("atmosphere.interceptors", new CustomInterceptor1()); DestinationRegistry registry = new HTTPTransportFactory().getRegistry(); EndpointInfo endpoint = new EndpointInfo(); endpoint.setAddress(ENDPOINT_ADDRESS); endpoint.setName(ENDPOINT_NAME); AtmosphereWebSocketServletDestination dest = new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS); List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors(); int added = 0; for (AtmosphereInterceptor a : ais) { if (CustomInterceptor1.class.equals(a.getClass())) { added++; break; } } assertEquals(1, added); }
@Test public void testUseCustomAtmoosphereInterceptors() throws Exception { Bus bus = new ExtensionManagerBus(); bus.setProperty("atmosphere.interceptors", Arrays.asList(new CustomInterceptor1(), new CustomInterceptor2())); DestinationRegistry registry = new HTTPTransportFactory().getRegistry(); EndpointInfo endpoint = new EndpointInfo(); endpoint.setAddress(ENDPOINT_ADDRESS); endpoint.setName(ENDPOINT_NAME); AtmosphereWebSocketServletDestination dest = new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS); List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors(); int added = 0; for (AtmosphereInterceptor a : ais) { if (CustomInterceptor1.class.equals(a.getClass())) { added++; } else if (CustomInterceptor2.class.equals(a.getClass())) { added++; break; } } assertEquals(2, added); }