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();
}
Aggregations