use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class ManagedAtmosphereHandlerTest method create.
@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;
}
});
}
use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class ManagedAtmosphereHandlerTest method testOverrideBroadcaster.
@Test
public void testOverrideBroadcaster() throws IOException, ServletException {
framework.setDefaultBroadcasterClassName(SimpleBroadcaster.class.getName());
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/override").method("GET").build();
request.header(X_ATMOSPHERE_TRANSPORT, LONG_POLLING_TRANSPORT);
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
assertNotNull(r.get());
assertEquals(r.get().getBroadcaster().getClass().getName(), SimpleBroadcaster.class.getName());
}
use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class ManagedAtmosphereHandlerTest method testBroadcasterCache.
@Test
public void testBroadcasterCache() throws IOException, ServletException {
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/cache").method("GET").build();
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
assertEquals(framework.getBroadcasterFactory().lookup("/*", true).getBroadcasterConfig().getBroadcasterCache().getClass(), UUIDBroadcasterCache.class);
}
use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class CustomAnnotationTest method testGet.
@Test
public void testGet() throws IOException, ServletException {
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/z").method("GET").build();
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
r.get().resume();
assertNotNull(r.get());
}
use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class PathTest method testAtmosphereRequestInjection.
@Test(enabled = true)
public void testAtmosphereRequestInjection() throws IOException, ServletException {
instanceCount = 0;
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/request/b123").method("GET").build();
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
assertEquals(instanceCount, 1);
assertNotNull(r.get());
assertEquals(r.get(), "/request/b123");
}
Aggregations