コード例 #1
0
 public void testNameAvailableThroughInterfaceLookup() {
   Collection<SyncBeanDef<CreditCard>> beans = IOC.getBeanManager().lookupBeans(CreditCard.class);
   for (SyncBeanDef<CreditCard> bean : beans) {
     if (bean.getBeanClass().getName().endsWith("Visa")) {
       assertEquals("visa", bean.getName());
     } else if (bean.getBeanClass().getName().endsWith("Amex")) {
       assertEquals("amex", bean.getName());
     } else {
       fail("Unexpected bean was returned from lookup: " + bean);
     }
   }
 }
コード例 #2
0
  public void testLookupByName() {
    final Collection<SyncBeanDef> beans = IOC.getBeanManager().lookupBeans("animal");

    assertEquals("wrong number of beans", 2, beans.size());
    assertTrue("should contain a pig", containsInstanceOf(beans, Pig.class));
    assertTrue("should contain a cow", containsInstanceOf(beans, Cow.class));

    for (SyncBeanDef<?> bean : beans) {
      assertEquals("animal", bean.getName());
    }
  }
コード例 #3
0
 public void testNameAvailableThroughConcreteTypeLookup() {
   Collection<SyncBeanDef<Visa>> beans = IOC.getBeanManager().lookupBeans(Visa.class);
   for (SyncBeanDef<Visa> bean : beans) {
     assertNotNull("Missing name on " + bean, bean.getName());
   }
 }