use of com.hazelcast.topic.impl.reliable.ReliableMessageListenerMock in project hazelcast by hazelcast.
the class ClientReliableTopicTest method testAlwaysStartAfterTail.
// makes sure that when a listener is register, we don't see any messages being published before
// it got registered. We'll only see the messages after it got registered.
@Test
public void testAlwaysStartAfterTail() {
final ITopic topic = client.getReliableTopic(randomString());
topic.publish("1");
topic.publish("2");
topic.publish("3");
spawn(new Runnable() {
@Override
public void run() {
sleepSeconds(5);
topic.publish("4");
topic.publish("5");
topic.publish("6");
}
});
final ReliableMessageListenerMock listener = new ReliableMessageListenerMock();
topic.addMessageListener(listener);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(asList("4", "5", "6"), Arrays.asList(listener.objects.toArray()));
}
});
}
use of com.hazelcast.topic.impl.reliable.ReliableMessageListenerMock in project hazelcast by hazelcast.
the class ClientReliableTopicTest method publishNull.
@Test
public void publishNull() throws InterruptedException {
ITopic topic = client.getReliableTopic(randomString());
final ReliableMessageListenerMock listener = new ReliableMessageListenerMock();
topic.addMessageListener(listener);
topic.publish(null);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertContains(listener.objects, null);
}
});
}
use of com.hazelcast.topic.impl.reliable.ReliableMessageListenerMock in project hazelcast by hazelcast.
the class ClientReliableTopicTest method removeMessageListener_whenExisting.
@Test
public void removeMessageListener_whenExisting() {
ITopic topic = client.getReliableTopic(randomString());
final ReliableMessageListenerMock listener = new ReliableMessageListenerMock();
String id = topic.addMessageListener(listener);
boolean removed = topic.removeMessageListener(id);
assertTrue(removed);
topic.publish("1");
// it should not receive any events.
assertTrueDelayed5sec(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(0, listener.objects.size());
}
});
}
Aggregations