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());
}
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);
}
}
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();
}
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());
}
Aggregations