Search in sources :

Example 1 with ClusterNotificationMessage

use of org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage 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 ClusterNotificationMessage

use of org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage in project scout.rt by eclipse.

the class ClusterSynchronizationService method publishAll.

private void publishAll(Collection<Serializable> notifications) {
    if (isEnabled()) {
        List<IClusterNotificationMessage> internalMessages = new ArrayList<IClusterNotificationMessage>();
        for (Serializable n : notifications) {
            internalMessages.add(new ClusterNotificationMessage(n, getNotificationProperties()));
        }
        publishInternal(internalMessages);
    }
}
Also used : Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) ClusterNotificationMessage(org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage)

Example 3 with ClusterNotificationMessage

use of org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage in project scout.rt by eclipse.

the class ClusterSynchronizationServiceTest method before.

@Before
public void before() throws Exception {
    m_nullMomImplementorSpy = spy(NullMomImplementor.class);
    m_beans.add(TestingUtility.registerBean(new BeanMetaData(TestClusterMom.class)));
    m_beans.add(TestingUtility.registerBean(new BeanMetaData(NullMomImplementor.class).withProducer(new IBeanInstanceProducer<IMomImplementor>() {

        @Override
        public IMomImplementor produce(IBean<IMomImplementor> bean) {
            return m_nullMomImplementorSpy;
        }
    })));
    // verify that replacement works
    assertSame("NullMomImplementor-Spy expected", m_nullMomImplementorSpy, BEANS.get(NullMomImplementor.class));
    ClusterNotificationProperties testProps = new ClusterNotificationProperties(TEST_NODE, TEST_USER);
    m_message = new ClusterNotificationMessage("notification", testProps);
    m_svc = new ClusterSynchronizationService();
    m_svc.enable();
}
Also used : BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) ClusterNotificationMessage(org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage) IMomImplementor(org.eclipse.scout.rt.mom.api.IMomImplementor) ClusterNotificationProperties(org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationProperties) NullMomImplementor(org.eclipse.scout.rt.mom.api.NullMomImplementor) Before(org.junit.Before)

Example 4 with ClusterNotificationMessage

use of org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage in project scout.rt by eclipse.

the class ClusterSynchronizationServiceTest method testTransactionalWithCoalesce.

@Test
public void testTransactionalWithCoalesce() throws Exception {
    ArgumentCaptor<ClusterNotificationMessage> msgCaptor = ArgumentCaptor.forClass(ClusterNotificationMessage.class);
    doNothing().when(m_nullMomImplementorSpy).publish(eq(IClusterMomDestinations.CLUSTER_NOTIFICATION_TOPIC), msgCaptor.capture(), any(PublishInput.class));
    m_svc.publishTransactional(new BookmarkChangedClientNotification());
    m_svc.publishTransactional(new BookmarkChangedClientNotification());
    m_svc.publishTransactional(new InvalidateCacheNotification("TEST", new AllCacheEntryFilter<>()));
    ITransaction.CURRENT.get().commitPhase1();
    ITransaction.CURRENT.get().commitPhase2();
    // verify
    verify(m_nullMomImplementorSpy, times(2)).publish(eq(IClusterMomDestinations.CLUSTER_NOTIFICATION_TOPIC), any(IClusterNotificationMessage.class), any(PublishInput.class));
    assertEquals(2, m_svc.getStatusInfo().getSentMessageCount());
    List<ClusterNotificationMessage> messages = msgCaptor.getAllValues();
    assertEquals(BookmarkChangedClientNotification.class, messages.get(0).getNotification().getClass());
    assertEquals(InvalidateCacheNotification.class, messages.get(1).getNotification().getClass());
}
Also used : BookmarkChangedClientNotification(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkChangedClientNotification) AllCacheEntryFilter(org.eclipse.scout.rt.shared.cache.AllCacheEntryFilter) PublishInput(org.eclipse.scout.rt.mom.api.PublishInput) ClusterNotificationMessage(org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage) InvalidateCacheNotification(org.eclipse.scout.rt.shared.cache.InvalidateCacheNotification) Test(org.junit.Test)

Aggregations

ClusterNotificationMessage (org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationMessage)4 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Serializable (java.io.Serializable)1 IMomImplementor (org.eclipse.scout.rt.mom.api.IMomImplementor)1 NullMomImplementor (org.eclipse.scout.rt.mom.api.NullMomImplementor)1 PublishInput (org.eclipse.scout.rt.mom.api.PublishInput)1 BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)1 ClientNotificationClusterNotification (org.eclipse.scout.rt.server.clientnotification.ClientNotificationClusterNotification)1 ClusterNotificationProperties (org.eclipse.scout.rt.server.services.common.clustersync.internal.ClusterNotificationProperties)1 AllCacheEntryFilter (org.eclipse.scout.rt.shared.cache.AllCacheEntryFilter)1 InvalidateCacheNotification (org.eclipse.scout.rt.shared.cache.InvalidateCacheNotification)1 ClientNotificationAddress (org.eclipse.scout.rt.shared.clientnotification.ClientNotificationAddress)1 ClientNotificationMessage (org.eclipse.scout.rt.shared.clientnotification.ClientNotificationMessage)1 IClientNotificationService (org.eclipse.scout.rt.shared.clientnotification.IClientNotificationService)1 BookmarkChangedClientNotification (org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkChangedClientNotification)1 Before (org.junit.Before)1