use of org.eclipse.scout.rt.platform.TypeParameterBeanRegistry in project scout.rt by eclipse.
the class TypeParameterBeanRegistryTest method testStringHandler.
@Test
public void testStringHandler() {
final TypeParameterBeanRegistry<ITestHandler> registry = new TypeParameterBeanRegistry<>(ITestHandler.class);
final List<ITestHandler> l = new ArrayList<>();
l.add(new String1Handler());
l.add(new LongHandler());
l.add(new String2Handler());
l.add(new CharSequenceHandler());
IRegistrationHandle registration = registry.registerBeans(l);
final List<ITestHandler> stringResult = registry.getBeans(String.class);
assertEquals(3, stringResult.size());
assertEquals(l.get(0), stringResult.get(0));
assertEquals(l.get(2), stringResult.get(1));
assertEquals(l.get(3), stringResult.get(2));
List<ITestHandler> charSequenceResult = registry.getBeans(CharSequence.class);
assertEquals(1, charSequenceResult.size());
assertEquals(l.get(3), charSequenceResult.get(0));
registration.dispose();
assertEquals(0, registry.getBeans(String.class).size());
assertEquals(0, registry.getBeans(CharSequence.class).size());
}
Aggregations