use of org.atmosphere.cpr.AsyncIOWriterAdapter 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!");
}
Aggregations