use of com.hazelcast.config.ListenerConfig in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConfiguredListenerClassAndHazelcastInstanceAware.
@Test
public void testConfiguredListenerClassAndHazelcastInstanceAware() {
Config config = new Config();
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").addMessageListenerConfig(new ListenerConfig(InstanceAwareReliableMessageListenerMock.class.getName())));
HazelcastInstance hz = createHazelcastInstance(config);
ITopic topic = hz.getReliableTopic("foo");
ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
// check there is one listener.
assertEquals(1, proxy.runnersMap.size());
// check that the listener is of the right class.
ReliableMessageListenerRunner runner = (ReliableMessageListenerRunner) proxy.runnersMap.values().iterator().next();
InstanceAwareReliableMessageListenerMock mock = assertInstanceOf(InstanceAwareReliableMessageListenerMock.class, runner.listener);
assertNotNull(mock.hz);
}
use of com.hazelcast.config.ListenerConfig in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConfiguredListenerClassNotExist.
@Test(expected = HazelcastException.class)
public void testConfiguredListenerClassNotExist() {
Config config = new Config();
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").addMessageListenerConfig(new ListenerConfig("kfosajdajdksajdj")));
HazelcastInstance hz = createHazelcastInstance(config);
hz.getReliableTopic("foo");
fail();
}
use of com.hazelcast.config.ListenerConfig in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConfiguredListenerInstance.
@Test
public void testConfiguredListenerInstance() {
final ReliableMessageListenerMock messageListener = new ReliableMessageListenerMock();
Config config = new Config();
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").addMessageListenerConfig(new ListenerConfig(messageListener)));
HazelcastInstance hz = createHazelcastInstance(config);
ITopic<String> topic = hz.getReliableTopic("foo");
ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
assertEquals(1, proxy.runnersMap.size());
topic.publish("item");
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertContains(messageListener.objects, "item");
}
});
}
use of com.hazelcast.config.ListenerConfig in project hazelcast by hazelcast.
the class TopicTest method testConfigListenerRegistration.
@Test
public void testConfigListenerRegistration() throws InterruptedException {
String topicName = "default";
Config config = new Config();
final CountDownLatch latch = new CountDownLatch(1);
config.getTopicConfig(topicName).addMessageListenerConfig(new ListenerConfig().setImplementation(new MessageListener() {
public void onMessage(Message message) {
latch.countDown();
}
}));
HazelcastInstance instance = createHazelcastInstance(config);
instance.getTopic(topicName).publish(1);
assertTrue(latch.await(10, TimeUnit.SECONDS));
}
use of com.hazelcast.config.ListenerConfig in project hazelcast by hazelcast.
the class PartitionLostListenerRegistrationTest method test_partitionLostListener_whenListenerRegisteredViaConfiguration.
@Test
public void test_partitionLostListener_whenListenerRegisteredViaConfiguration() {
final Config config = new Config();
config.addListenerConfig(new ListenerConfig(mock(PartitionLostListener.class)));
final HazelcastInstance instance = createHazelcastInstance(config);
assertRegistrationsSizeEventually(instance, 1);
}
Aggregations