+ session.enableEvent(EVENT_NAME_A, null, false, null);
+ session.enableEvent(EVENT_NAME_B, null, false, null);
+
+ assertEquals(2, listener.getNbNotifications());
+ assertEquals(rules, listener.getCurrentRules());
+
+ assertEquals(0, listener2.getNbNotifications());
+ assertEquals(Collections.EMPTY_SET, listener2.getCurrentRules());
+
+ assertEquals(0, listener3.getNbNotifications());
+ assertEquals(Collections.EMPTY_SET, listener3.getCurrentRules());
+ }
+
+ /**
+ * Test that a newly-registered listener correctly receives the "statedump",
+ * which means all the rules currently active, upon registration.
+ */
+ @Test
+ public void testStatedump() {
+ FilterNotificationManager fnm = FilterNotificationManager.getInstance();
+ TestFilterListener listener2 = new TestFilterListener();
+
+ Set<EventRule> rules1 = Stream.of(
+ new EventRule(EVENT_NAME_A, LOG_LEVEL_UNSPECIFIED, null),
+ new EventRule(EVENT_NAME_B, LOG_LEVEL_UNSPECIFIED, null))
+ .collect(Collectors.toSet());
+ Set<EventRule> rules2 = Stream.of(
+ new EventRule(EVENT_NAME_A, LOG_LEVEL_UNSPECIFIED, null),
+ new EventRule(EVENT_NAME_C, LOG_LEVEL_UNSPECIFIED, null))
+ .collect(Collectors.toSet());