use of org.opennms.core.soa.Registration in project opennms by OpenNMS.
the class DefaultServiceRegistryTest method testRegisterUnregister.
@Test
public void testRegisterUnregister() {
MyProvider provider = new MyProvider();
Registration registration = m_registry.register(provider, Hello.class, Goodbye.class);
Hook hook = new Hook();
m_registry.addRegistrationHook(hook, true);
assertEquals(1, hook.getCount());
Collection<Hello> hellos = m_registry.findProviders(Hello.class);
Collection<Goodbye> goodbyes = m_registry.findProviders(Goodbye.class);
assertEquals(1, hellos.size());
assertEquals(1, goodbyes.size());
assertSame(provider, hellos.iterator().next());
assertSame(provider, goodbyes.iterator().next());
registration.unregister();
assertEquals(0, hook.getCount());
hellos = m_registry.findProviders(Hello.class);
goodbyes = m_registry.findProviders(Goodbye.class);
assertTrue(hellos.isEmpty());
assertTrue(goodbyes.isEmpty());
}
Aggregations