use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class EncoderDecoderTest method testEncoder.
@Test
public void testEncoder() throws IOException, ServletException, InterruptedException {
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/h").method("GET").build();
AtmosphereResponse response = AtmosphereResponseImpl.newInstance();
final AtomicReference<String> ref = new AtomicReference();
response.asyncIOWriter(new AsyncIOWriterAdapter() {
@Override
public AsyncIOWriter write(AtmosphereResponse r, byte[] data) throws IOException {
ref.set(new String(data));
return this;
}
});
framework.doCometSupport(request, response);
assertNotNull(r.get());
latch.get().await(5, TimeUnit.SECONDS);
r.get().resume();
assertNotNull(message.get());
assertEquals(message.get(), "message");
assertEquals(ref.get(), "message-yo!");
}
use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class ManagedAtmosphereHandlerTest method testInjectAnnotation.
@Test
public void testInjectAnnotation() throws IOException, ServletException {
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/injectAnnotation").method("GET").build();
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
assertNotNull(r.get());
r.get().resume();
assertNotNull(message.get());
assertEquals(message.get(), framework.metaBroadcaster().toString());
}
use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class ManagedAtmosphereHandlerTest method testPost.
@Test
public void testPost() throws IOException, ServletException {
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/b").method("POST").body("test").build();
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
assertNotNull(r.get());
r.get().resume();
}
use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class ManagedAtmosphereHandlerTest method testSuspend.
@Test
public void testSuspend() throws IOException, ServletException {
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/j").method("GET").build();
request.header(X_ATMOSPHERE_TRANSPORT, LONG_POLLING_TRANSPORT);
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
assertNotNull(r.get());
}
use of org.atmosphere.runtime.AtmosphereRequest in project atmosphere by Atmosphere.
the class ManagedAtmosphereHandlerTest method testPut.
@Test
public void testPut() throws IOException, ServletException {
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/d").method("PUT").build();
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
assertNotNull(r.get());
r.get().resume();
}
Aggregations