use of org.eclipse.scout.rt.shared.clientnotification.ClientNotificationAddress in project scout.rt by eclipse.
the class ClientNotificationClusterNotificationTest method testClientNotificationsReceived.
/**
* Tests that the client notifications are added to the queue when received
*/
@SuppressWarnings("unchecked")
@Test
public void testClientNotificationsReceived() {
IMessage<IClusterNotificationMessage> momMsg = mock(IMessage.class);
ClientNotificationAddress address = ClientNotificationAddress.createAllNodesAddress();
ClientNotificationMessage message = new ClientNotificationMessage(address, "test", true, "cid");
ArrayList<ClientNotificationMessage> messages = new ArrayList<ClientNotificationMessage>();
messages.add(message);
when(momMsg.getTransferObject()).thenReturn(new ClusterNotificationMessage(new ClientNotificationClusterNotification(messages), m_testProps));
m_svc.onMessage(momMsg);
IClientNotificationService c = BEANS.get(IClientNotificationService.class);
List<ClientNotificationMessage> notifications = c.getNotifications(TEST_NODE);
assertEquals(1, notifications.size());
}
use of org.eclipse.scout.rt.shared.clientnotification.ClientNotificationAddress in project scout.rt by eclipse.
the class ClientNotificationNodeQueueTest method testBlockingWait.
@Test
public void testBlockingWait() {
IFuture<List<ClientNotificationMessage>> res = Jobs.schedule(new Callable<List<ClientNotificationMessage>>() {
@Override
public List<ClientNotificationMessage> call() throws Exception {
return m_queue.getNotifications(10, 100, TimeUnit.MILLISECONDS);
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()));
ClientNotificationAddress allNodes = ClientNotificationAddress.createAllNodesAddress();
m_queue.put(new ClientNotificationMessage(allNodes, "test", true, "cid"));
m_queue.put(new ClientNotificationMessage(allNodes, "test2", true, "cid"));
List<ClientNotificationMessage> notifications = res.awaitDoneAndGet();
assertEquals(2, notifications.size());
assertEquals("test", notifications.get(0).getNotification());
assertEquals("test2", notifications.get(1).getNotification());
}
Aggregations