public void testSimple() throws Exception {
final Backchannel bc = new Backchannel();
bc.push("mic", new PushResponse("m", "b"));
bc.push("dave", new PushResponse("d", "b"));
List<PushResponse> r = bc.await("mic");
assertEquals(1, r.size());
assertEquals("m", r.get(0).messageType);
r = bc.await("dave");
assertEquals(1, r.size());
assertEquals("d", r.get(0).messageType);
final boolean[] check = new boolean[1];
Thread t = new Thread(new Runnable() {
public void run() {
try {
List<PushResponse> list = bc.await("mic");
/*
for (PushResponse resp: list) {
System.err.println(resp.messageType + "," + resp.message);
}
*/
check[0] = true;
} catch (InterruptedException e) {
fail("Should not interrupt");
}
}
});
t.setDaemon(true);
t.start();
Thread.sleep(400);
assertFalse(check[0]);
bc.push("dave", new PushResponse("x", "y"));
//bc.push("mic", new PushResponse("Q", "W"));
t.join();
check[0] = false;
bc.push("mic", new PushResponse("R", "T"));
bc.push("mic", new PushResponse("Q", "A"));
final List<List<PushResponse>> container = new ArrayList();
t = new Thread(new Runnable() {