Search in sources :

Example 1 with TypeParameterBeanRegistry

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());
}
Also used : TypeParameterBeanRegistry(org.eclipse.scout.rt.platform.TypeParameterBeanRegistry) ArrayList(java.util.ArrayList) IRegistrationHandle(org.eclipse.scout.rt.platform.util.IRegistrationHandle) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 TypeParameterBeanRegistry (org.eclipse.scout.rt.platform.TypeParameterBeanRegistry)1 IRegistrationHandle (org.eclipse.scout.rt.platform.util.IRegistrationHandle)1 Test (org.junit.Test)1