use of org.eclipse.scout.rt.server.services.common.clustersync.IClusterSynchronizationService in project scout.rt by eclipse.
the class ClientNotificationRegistryTest method testNotificationsWithoutDistributingOverCluster.
/**
* Empty collection of notifications must not trigger a cluster notification.
*/
@Test
public void testNotificationsWithoutDistributingOverCluster() {
final IClusterSynchronizationService mockClusterSyncService = Mockito.mock(IClusterSynchronizationService.class);
final IBean<?> bean = TestingUtility.registerBean(new BeanMetaData(IClusterSynchronizationService.class).withInitialInstance(mockClusterSyncService).withApplicationScoped(true));
try {
ClientNotificationRegistry reg = new ClientNotificationRegistry(TEST_QUEUE_EXPIRE_TIMEOUT);
reg.registerSession("testNodeId", "testSessionId", TEST_USER);
reg.registerSession("testNodeId2", "testSessionId", TEST_USER);
reg.putForAllNodes(TEST_NOTIFICATION, false);
List<ClientNotificationMessage> notificationsNode1 = consumeNoWait(reg, "testNodeId");
List<ClientNotificationMessage> notificationsNode2 = consumeNoWait(reg, "testNodeId2");
assertSingleTestNotification(notificationsNode1);
assertSingleTestNotification(notificationsNode2);
Mockito.verifyZeroInteractions(mockClusterSyncService);
} finally {
TestingUtility.unregisterBean(bean);
}
}
use of org.eclipse.scout.rt.server.services.common.clustersync.IClusterSynchronizationService in project scout.rt by eclipse.
the class ClientNotificationRegistryTest method testEmptyNotificationsAreNotDistributedOverCluster.
/**
* Empty collection of notifications must not trigger a cluster notification.
*/
@Test
public void testEmptyNotificationsAreNotDistributedOverCluster() {
final IClusterSynchronizationService mockClusterSyncService = Mockito.mock(IClusterSynchronizationService.class);
final IBean<?> bean = TestingUtility.registerBean(new BeanMetaData(IClusterSynchronizationService.class).withInitialInstance(mockClusterSyncService).withApplicationScoped(true));
try {
ClientNotificationRegistry reg = new ClientNotificationRegistry(TEST_QUEUE_EXPIRE_TIMEOUT);
reg.registerSession("testNodeId", "testSessionId", TEST_USER);
reg.publish(Collections.<ClientNotificationMessage>emptySet());
assertEquals(Collections.emptyList(), consumeNoWait(reg, "testNodeId"));
Mockito.verifyZeroInteractions(mockClusterSyncService);
} finally {
TestingUtility.unregisterBean(bean);
}
}
use of org.eclipse.scout.rt.server.services.common.clustersync.IClusterSynchronizationService in project scout.rt by eclipse.
the class ClientNotificationRegistry method publishClusterInternal.
/**
* Publish messages to other cluster nodes. Message not foreseen for cluster distributions are filtered.
*/
private void publishClusterInternal(Collection<? extends ClientNotificationMessage> messages) {
Collection<ClientNotificationMessage> filteredMessages = new LinkedList<ClientNotificationMessage>();
for (ClientNotificationMessage message : messages) {
if (message.isDistributeOverCluster()) {
filteredMessages.add(message);
}
}
// do not publish empty messages
if (filteredMessages.isEmpty()) {
return;
}
try {
IClusterSynchronizationService service = BEANS.get(IClusterSynchronizationService.class);
service.publish(new ClientNotificationClusterNotification(filteredMessages));
} catch (RuntimeException e) {
LOG.error("Failed to publish client notification", e);
}
}
Aggregations