Search in sources :

Example 6 with ReflectorServletProcessor

use of org.atmosphere.handler.ReflectorServletProcessor in project atmosphere by Atmosphere.

the class AtmosphereResourceTest method testCompletionAwareForSyncButStartAsync.

@Test
public void testCompletionAwareForSyncButStartAsync() throws IOException, ServletException {
    Servlet s = mock(Servlet.class);
    framework.addInitParameter(ApplicationConfig.RESPONSE_COMPLETION_AWARE, "true");
    ReflectorServletProcessor handler = new ReflectorServletProcessor(s);
    handler.init(framework.getAtmosphereConfig());
    AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/a").build();
    AtmosphereResponseImpl response = mock(AtmosphereResponseImpl.class);
    AtmosphereResourceImpl res = new AtmosphereResourceImpl();
    res.initialize(framework.getAtmosphereConfig(), framework.getBroadcasterFactory().get(), request, response, null, null);
    res.transport(AtmosphereResource.TRANSPORT.WEBSOCKET);
    request.setAttribute(FrameworkConfig.ATMOSPHERE_RESOURCE, res);
    request.setAttribute(FrameworkConfig.INJECTED_ATMOSPHERE_RESOURCE, res);
    AsyncContext ac = request.startAsync();
    handler.onRequest(res);
    verify(response, times(0)).onComplete();
    ac.complete();
    verify(response, times(1)).onComplete();
}
Also used : Servlet(javax.servlet.Servlet) AsyncContext(javax.servlet.AsyncContext) ReflectorServletProcessor(org.atmosphere.handler.ReflectorServletProcessor) Test(org.testng.annotations.Test)

Aggregations

ReflectorServletProcessor (org.atmosphere.handler.ReflectorServletProcessor)6 Servlet (javax.servlet.Servlet)3 LinkedList (java.util.LinkedList)2 MeteorService (org.atmosphere.config.service.MeteorService)2 AtmosphereInterceptor (org.atmosphere.runtime.AtmosphereInterceptor)2 Named (javax.inject.Named)1 AsyncContext (javax.servlet.AsyncContext)1 MeteorServiceInterceptor (org.atmosphere.config.managed.MeteorServiceInterceptor)1 AtmosphereService (org.atmosphere.config.service.AtmosphereService)1 Singleton (org.atmosphere.config.service.Singleton)1 AtmosphereConfig (org.atmosphere.runtime.AtmosphereConfig)1 AtmosphereHandler (org.atmosphere.runtime.AtmosphereHandler)1 AtmosphereResource (org.atmosphere.runtime.AtmosphereResource)1 AtmosphereResourceEvent (org.atmosphere.runtime.AtmosphereResourceEvent)1 AtmosphereResourceImpl (org.atmosphere.runtime.AtmosphereResourceImpl)1 AtmosphereServletProcessor (org.atmosphere.runtime.AtmosphereServletProcessor)1 Test (org.testng.annotations.Test)1