CountDownLatch latch = new CountDownLatch(1);
TesterEndpoint tep =
(TesterEndpoint) wsSession.getUserProperties().get("endpoint");
tep.setLatch(latch);
AsyncHandler<?> handler = new AsyncText(latch);
wsSession.addMessageHandler(handler);
Writer w = wsSession.getBasicRemote().getSendWriter();
for (int i = 0; i < 8; i++) {
w.write(TEST_MESSAGE_5K);
}
w.close();
boolean latchResult = handler.getLatch().await(10, TimeUnit.SECONDS);
Assert.assertTrue(latchResult);
@SuppressWarnings("unchecked")
List<String> messages = (List<String>) handler.getMessages();
int offset = 0;
int i = 0;
for (String message : messages) {
// First may be a fragment