Search in sources :

Example 1 with SimpleNotificationService

use of org.apache.activemq.artemis.tests.integration.SimpleNotificationService in project activemq-artemis by apache.

the class DiscoveryTest method testBroadcastGroupNotifications.

@Test
public void testBroadcastGroupNotifications() throws Exception {
    SimpleNotificationService notifService = new SimpleNotificationService();
    SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
    notifService.addNotificationListener(notifListener);
    final InetAddress groupAddress = InetAddress.getByName(address1);
    final int groupPort = getUDPDiscoveryPort();
    bg = newBroadcast(RandomUtil.randomString(), RandomUtil.randomString(), null, -1, groupAddress, groupPort);
    bg.setNotificationService(notifService);
    Assert.assertEquals(0, notifListener.getNotifications().size());
    bg.start();
    Assert.assertEquals(1, notifListener.getNotifications().size());
    Notification notif = notifListener.getNotifications().get(0);
    Assert.assertEquals(CoreNotificationType.BROADCAST_GROUP_STARTED, notif.getType());
    Assert.assertEquals(bg.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
    bg.stop();
    Assert.assertEquals(2, notifListener.getNotifications().size());
    notif = notifListener.getNotifications().get(1);
    Assert.assertEquals(CoreNotificationType.BROADCAST_GROUP_STOPPED, notif.getType());
    Assert.assertEquals(bg.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
}
Also used : SimpleNotificationService(org.apache.activemq.artemis.tests.integration.SimpleNotificationService) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) InetAddress(java.net.InetAddress) BroadcastEndpoint(org.apache.activemq.artemis.api.core.BroadcastEndpoint) Notification(org.apache.activemq.artemis.core.server.management.Notification) Test(org.junit.Test)

Example 2 with SimpleNotificationService

use of org.apache.activemq.artemis.tests.integration.SimpleNotificationService in project activemq-artemis by apache.

the class DiscoveryTest method testDiscoveryGroupNotifications.

@Test
public void testDiscoveryGroupNotifications() throws Exception {
    SimpleNotificationService notifService = new SimpleNotificationService();
    SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
    notifService.addNotificationListener(notifListener);
    final InetAddress groupAddress = InetAddress.getByName(address1);
    final int groupPort = getUDPDiscoveryPort();
    final int timeout = 500;
    dg = newDiscoveryGroup(RandomUtil.randomString(), RandomUtil.randomString(), null, groupAddress, groupPort, timeout, notifService);
    Assert.assertEquals(0, notifListener.getNotifications().size());
    dg.start();
    Assert.assertEquals(1, notifListener.getNotifications().size());
    Notification notif = notifListener.getNotifications().get(0);
    Assert.assertEquals(CoreNotificationType.DISCOVERY_GROUP_STARTED, notif.getType());
    Assert.assertEquals(dg.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
    dg.stop();
    Assert.assertEquals(2, notifListener.getNotifications().size());
    notif = notifListener.getNotifications().get(1);
    Assert.assertEquals(CoreNotificationType.DISCOVERY_GROUP_STOPPED, notif.getType());
    Assert.assertEquals(dg.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
}
Also used : SimpleNotificationService(org.apache.activemq.artemis.tests.integration.SimpleNotificationService) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) InetAddress(java.net.InetAddress) BroadcastEndpoint(org.apache.activemq.artemis.api.core.BroadcastEndpoint) Notification(org.apache.activemq.artemis.core.server.management.Notification) Test(org.junit.Test)

Aggregations

InetAddress (java.net.InetAddress)2 BroadcastEndpoint (org.apache.activemq.artemis.api.core.BroadcastEndpoint)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 Notification (org.apache.activemq.artemis.core.server.management.Notification)2 SimpleNotificationService (org.apache.activemq.artemis.tests.integration.SimpleNotificationService)2 Test (org.junit.Test)2