public void testAggregateFilter() {
logger.info("{}: running test: testAggregateFilter", getClass().getSimpleName());
final CountDownLatch latch = new CountDownLatch(1);
long t1 = System.currentTimeMillis();
AsyncHttpClient c = new AsyncHttpClient();
try {
final AtomicReference<Response> response = new AtomicReference<Response>();
c.prepareGet(urlTarget + "/foreverWithoutComments").execute(new AsyncCompletionHandler<Response>() {
@Override
public Response onCompleted(Response r) throws Exception {
try {
response.set(r);
return r;
} finally {
latch.countDown();
}
}
});
// Let Atmosphere suspend the connections.
Thread.sleep(2500);
for (int i = 0; i < 10; i++) {
c.preparePost(urlTarget + "/aggregate").addParameter("message",
"==================================================").execute().get(5, TimeUnit.SECONDS);
}
try {
latch.await(20, TimeUnit.SECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
}
Response r = response.get();
assertNotNull(r);
assertEquals(r.getStatusCode(), 200);
assertEquals(r.getResponseBody(), "==================================================\n" +
"==================================================\n" +
"==================================================\n" +
"==================================================\n" +
"==================================================\n" +
"==================================================\n");
} catch (Exception e) {
logger.error("test failed", e);
fail(e.getMessage());
}
c.close();
}