assertTrue(set.remove(ref1));
assertTrue(set.isEmpty());
}
public void testWithListener() throws Exception {
DelegatingServiceRegistry registry = new DelegatingServiceRegistry();
set.setServiceRegistry(registry);
set.setFilterExpression("(mapkey=*)");
List<String> service1 = Arrays.asList("1", "2");
List<String> service2 = Arrays.asList("2", "3");
List<String> service2a = Arrays.asList("2", "3");
List<String> service3 = Arrays.asList("3", "4");
ClassLoader classLoader = ClassUtils.getDefaultClassLoader();
registry.addService("bean1", "module1", new StaticServiceBeanReference(service1), null, Collections.singletonMap("mapkey", "bean1"), classLoader);
registry.addService("bean2", "module1", new StaticServiceBeanReference(service2), null, Collections.singletonMap("mapkey", "bean2"), classLoader);
registry.addService("bean2a", "module1", new StaticServiceBeanReference(service2a), null, Collections.singletonMap("mapkey", "bean2a"), classLoader);
assertTrue(set.isEmpty());
//now call init to add
set.init();
assertEquals(2, set.size());
//now add service and see it automatically reflect
registry.addService("bean3", "module1", new StaticServiceBeanReference(service3), null, Collections.singletonMap("mapkey", "bean3"), classLoader);
assertEquals(3, set.size());
set.destroy();
assertTrue(set.isEmpty());
//no need to remove listener as this was removed via destroy
assertFalse(registry.removeEventListener(set));
}