/** * Matches the given notification type. * @see {@link NotificationFilterSupport#enableType(String)} */ public static NotificationFilter matchesType(String type) { return matchesTypes(type); }
@Test public void testJmxNotificationMultipleSubscriptionUsingListener() throws Exception { final String one = "notification.one"; final String two = "notification.two"; final StandardEmitterMBean mbean = jmxService.registerMBean(ImmutableList.of(one, two), objectName); final AtomicInteger sequence = new AtomicInteger(0); feed = JmxFeed.builder() .entity(entity) .subscribeToNotification(new JmxNotificationSubscriptionConfig<Integer>(intAttribute) .objectName(objectName) .notificationFilter(JmxNotificationFilters.matchesTypes(one, two))) .build(); // Notification updates the sensor // Note that subscription is done async, so can't just send notification immediately during test. Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT_MS), new Runnable() { @Override public void run() { sendNotification(mbean, one, sequence.getAndIncrement(), 123); assertEquals(entity.getAttribute(intAttribute), (Integer)123); }}); // And wildcard means other notifications also received sendNotification(mbean, two, sequence.getAndIncrement(), 456); assertSensorEventually(intAttribute, 456, TIMEOUT_MS); }