Search in sources :

Example 1 with ClientNotificationAddress

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());
}
Also used : ClientNotificationClusterNotification(org.eclipse.scout.rt.server.clientnotification.ClientNotificationClusterNotification) ClientNotificationAddress(org.eclipse.scout.rt.shared.clientnotification.ClientNotificationAddress) ArrayList(java.util.ArrayList) ClusterNotificationMessage(org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage) IClientNotificationService(org.eclipse.scout.rt.shared.clientnotification.IClientNotificationService) ClientNotificationMessage(org.eclipse.scout.rt.shared.clientnotification.ClientNotificationMessage) Test(org.junit.Test)

Example 2 with ClientNotificationAddress

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());
}
Also used : ClientNotificationAddress(org.eclipse.scout.rt.shared.clientnotification.ClientNotificationAddress) List(java.util.List) ClientNotificationMessage(org.eclipse.scout.rt.shared.clientnotification.ClientNotificationMessage) Test(org.junit.Test)

Aggregations

ClientNotificationAddress (org.eclipse.scout.rt.shared.clientnotification.ClientNotificationAddress)2 ClientNotificationMessage (org.eclipse.scout.rt.shared.clientnotification.ClientNotificationMessage)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ClientNotificationClusterNotification (org.eclipse.scout.rt.server.clientnotification.ClientNotificationClusterNotification)1 ClusterNotificationMessage (org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage)1 IClientNotificationService (org.eclipse.scout.rt.shared.clientnotification.IClientNotificationService)1