@Test
public void overhearUpdate() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
Client client = new Client();
client.addReceiver(new Recipient() {
@Override
public void receive(Request request) {
latch.countDown();
}
});
client.connect();
FakeServer server = new FakeServer();
server.send("{" +
"\"type\": \"update\", " +
"\"address\": \"192.168.0.1\", " +
"\"family\": \"ipv4\", " +
"\"name\": \"foo\"," +
"\"moniker\": \"bar\" }");
Assert.assertEquals(1, latch.getCount());
Assert.assertFalse(latch.await(200, TimeUnit.MILLISECONDS));
client.disconnect();
server.shutdown();
}