Search in sources :

Example 1 with PojoGenerics

use of org.apache.aries.blueprint.pojos.PojoGenerics in project aries by apache.

the class WiringTest method testGenerics.

public void testGenerics() throws Exception {
    ComponentDefinitionRegistryImpl registry = parse("/test-generics.xml");
    Repository repository = new TestBlueprintContainer(registry).getRepository();
    List<Integer> expectedList = new ArrayList<Integer>();
    expectedList.add(new Integer(10));
    expectedList.add(new Integer(20));
    expectedList.add(new Integer(50));
    Set<Long> expectedSet = new HashSet<Long>();
    expectedSet.add(new Long(1000));
    expectedSet.add(new Long(2000));
    expectedSet.add(new Long(5000));
    Map<Short, Boolean> expectedMap = new HashMap<Short, Boolean>();
    expectedMap.put(new Short((short) 1), Boolean.TRUE);
    expectedMap.put(new Short((short) 2), Boolean.FALSE);
    expectedMap.put(new Short((short) 5), Boolean.TRUE);
    Object obj;
    PojoGenerics pojo;
    obj = repository.create("method");
    assertTrue(obj instanceof PojoGenerics);
    pojo = (PojoGenerics) obj;
    assertEquals(expectedList, pojo.getList());
    assertEquals(expectedSet, pojo.getSet());
    assertEquals(expectedMap, pojo.getMap());
    obj = repository.create("constructorList");
    assertTrue(obj instanceof PojoGenerics);
    pojo = (PojoGenerics) obj;
    assertEquals(expectedList, pojo.getList());
    obj = repository.create("constructorSet");
    assertTrue(obj instanceof PojoGenerics);
    pojo = (PojoGenerics) obj;
    assertEquals(expectedSet, pojo.getSet());
    obj = repository.create("constructorMap");
    assertTrue(obj instanceof PojoGenerics);
    pojo = (PojoGenerics) obj;
    assertEquals(expectedMap, pojo.getMap());
    obj = repository.create("genericPojo");
    assertTrue(obj instanceof Primavera);
    assertEquals("string", ((Primavera) obj).prop);
    obj = repository.create("doubleGenericPojo");
    assertTrue(obj instanceof Primavera);
    assertEquals("stringToo", ((Primavera) obj).prop);
}
Also used : PojoGenerics(org.apache.aries.blueprint.pojos.PojoGenerics) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) Repository(org.apache.aries.blueprint.di.Repository) BlueprintRepository(org.apache.aries.blueprint.container.BlueprintRepository) MyObject(org.apache.aries.blueprint.pojos.PojoGenerics2.MyObject) Primavera(org.apache.aries.blueprint.pojos.Primavera) ComponentDefinitionRegistryImpl(org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl) HashSet(java.util.HashSet)

Aggregations

BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 BlueprintRepository (org.apache.aries.blueprint.container.BlueprintRepository)1 Repository (org.apache.aries.blueprint.di.Repository)1 ComponentDefinitionRegistryImpl (org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl)1 PojoGenerics (org.apache.aries.blueprint.pojos.PojoGenerics)1 MyObject (org.apache.aries.blueprint.pojos.PojoGenerics2.MyObject)1 Primavera (org.apache.aries.blueprint.pojos.Primavera)1