Search in sources :

Example 1 with ITopic

use of com.hazelcast.topic.ITopic in project hazelcast by hazelcast.

the class ClientReliableTopicTest method testGetLocalTopicStats.

@Test(expected = UnsupportedOperationException.class)
public void testGetLocalTopicStats() throws Exception {
    ITopic topic = client.getReliableTopic(randomString());
    topic.getLocalTopicStats();
}
Also used : ITopic(com.hazelcast.topic.ITopic) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) DurableSubscriptionTest(com.hazelcast.topic.impl.reliable.DurableSubscriptionTest) Test(org.junit.Test)

Example 2 with ITopic

use of com.hazelcast.topic.ITopic in project hazelcast by hazelcast.

the class ClientReliableTopicTest method testRemoveListener.

@Test
public void testRemoveListener() {
    ITopic topic = client.getReliableTopic(randomString());
    MessageListener listener = new MessageListener() {

        public void onMessage(Message message) {
        }
    };
    UUID id = topic.addMessageListener(listener);
    assertTrue(topic.removeMessageListener(id));
}
Also used : ITopic(com.hazelcast.topic.ITopic) Message(com.hazelcast.topic.Message) MessageListener(com.hazelcast.topic.MessageListener) UUID(java.util.UUID) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) DurableSubscriptionTest(com.hazelcast.topic.impl.reliable.DurableSubscriptionTest) Test(org.junit.Test)

Example 3 with ITopic

use of com.hazelcast.topic.ITopic in project hazelcast by hazelcast.

the class ClientReliableTopicTest method publishMultiple.

@Test
public void publishMultiple() throws InterruptedException {
    ITopic topic = client.getReliableTopic(randomString());
    final ReliableMessageListenerMock listener = new ReliableMessageListenerMock();
    topic.addMessageListener(listener);
    final List<String> items = new ArrayList<String>();
    for (int k = 0; k < 5; k++) {
        items.add("" + k);
    }
    for (String item : items) {
        topic.publish(item);
    }
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(items, Arrays.asList(listener.objects.toArray()));
        }
    });
}
Also used : ITopic(com.hazelcast.topic.ITopic) ReliableMessageListenerMock(com.hazelcast.topic.impl.reliable.ReliableMessageListenerMock) ArrayList(java.util.ArrayList) AssertTask(com.hazelcast.test.AssertTask) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) DurableSubscriptionTest(com.hazelcast.topic.impl.reliable.DurableSubscriptionTest) Test(org.junit.Test)

Example 4 with ITopic

use of com.hazelcast.topic.ITopic in project hazelcast by hazelcast.

the class ClientReliableTopicTest method removeMessageListener_whenNonExisting.

@Test
public void removeMessageListener_whenNonExisting() {
    ITopic topic = client.getReliableTopic(randomString());
    boolean result = topic.removeMessageListener(UUID.randomUUID());
    assertFalse(result);
}
Also used : ITopic(com.hazelcast.topic.ITopic) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) DurableSubscriptionTest(com.hazelcast.topic.impl.reliable.DurableSubscriptionTest) Test(org.junit.Test)

Example 5 with ITopic

use of com.hazelcast.topic.ITopic in project hazelcast by hazelcast.

the class ClientReliableTopicTest method addMessageListener.

// ============== addMessageListener ==============================
@Test
public void addMessageListener() {
    ITopic topic = client.getReliableTopic(randomString());
    UUID id = topic.addMessageListener(new ReliableMessageListenerMock());
    assertNotNull(id);
}
Also used : ITopic(com.hazelcast.topic.ITopic) ReliableMessageListenerMock(com.hazelcast.topic.impl.reliable.ReliableMessageListenerMock) UUID(java.util.UUID) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) DurableSubscriptionTest(com.hazelcast.topic.impl.reliable.DurableSubscriptionTest) Test(org.junit.Test)

Aggregations

ITopic (com.hazelcast.topic.ITopic)20 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)19 QuickTest (com.hazelcast.test.annotation.QuickTest)19 Test (org.junit.Test)19 DurableSubscriptionTest (com.hazelcast.topic.impl.reliable.DurableSubscriptionTest)12 UUID (java.util.UUID)8 ReliableMessageListenerMock (com.hazelcast.topic.impl.reliable.ReliableMessageListenerMock)7 AssertTask (com.hazelcast.test.AssertTask)6 Message (com.hazelcast.topic.Message)6 Config (com.hazelcast.config.Config)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 MessageListener (com.hazelcast.topic.MessageListener)5 ClientConfig (com.hazelcast.client.config.ClientConfig)3 ClientProperty (com.hazelcast.client.properties.ClientProperty)3 TestHazelcastFactory (com.hazelcast.client.test.TestHazelcastFactory)3 ListenerConfig (com.hazelcast.config.ListenerConfig)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ClientReliableTopicProxy (com.hazelcast.client.impl.proxy.ClientReliableTopicProxy)2 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)2 RingbufferConfig (com.hazelcast.config.RingbufferConfig)2