use of com.hazelcast.core.DistributedObjectListener in project hazelcast by hazelcast.
the class DistributedObjectListenerTest method destroyedNotReceivedOnClient.
@Test
public void destroyedNotReceivedOnClient() throws Exception {
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient();
final CountDownLatch createdLatch = new CountDownLatch(1);
final CountDownLatch destroyedLatch = new CountDownLatch(1);
client.addDistributedObjectListener(new DistributedObjectListener() {
@Override
public void distributedObjectCreated(DistributedObjectEvent event) {
createdLatch.countDown();
}
@Override
public void distributedObjectDestroyed(DistributedObjectEvent event) {
destroyedLatch.countDown();
}
});
final String name = randomString();
final ITopic<Object> topic = instance.getTopic(name);
assertOpenEventually(createdLatch, 10);
assertEquals(1, client.getDistributedObjects().size());
topic.destroy();
assertOpenEventually(destroyedLatch, 10);
assertTrueAllTheTime(new AssertTask() {
@Override
public void run() throws Exception {
Collection<DistributedObject> distributedObjects = client.getDistributedObjects();
assertTrue(distributedObjects.isEmpty());
}
}, 5);
}
Aggregations