event.getResource().resume();
latch.countDown();
}
}, new RecyclableBroadcaster("suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
c.prepareGet(urlTarget).execute(new AsyncCompletionHandler<String>() {
@Override
public String onCompleted(Response response) throws Exception {
try {
assertEquals(response.getResponseBody(),
AtmosphereResourceImpl.createCompatibleStringJunk());
} finally {
latch.countDown();
}
return null;
}
});
suspended.await(20, TimeUnit.SECONDS);
c.prepareGet(urlTarget).execute().get();
c.prepareGet(urlTarget).execute().get();
Response r = c.prepareGet(urlTarget).execute().get();
try {
latch.await(20, TimeUnit.SECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
}
assertNotNull(r);
assertEquals(r.getStatusCode(), 200);
} catch (Exception e) {
logger.error("test failed", e);
fail(e.getMessage());
}
c.close();
}