mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint").noStart())
);
}
public static void testBlueprintContainer(RichBundleContext context, Bundle bundle) throws Exception {
BlueprintContainer blueprintContainer = getBlueprintContainerForBundle(context, "org.apache.aries.blueprint.sample");
assertNotNull(blueprintContainer);
Object obj = blueprintContainer.getComponentInstance("bar");
assertNotNull(obj);
assertEquals(Bar.class, obj.getClass());
Bar bar = (Bar) obj;
assertNotNull(bar.getContext());
assertEquals("Hello FooBar", bar.getValue());
assertNotNull(bar.getList());
assertEquals(2, bar.getList().size());
assertEquals("a list element", bar.getList().get(0));
assertEquals(Integer.valueOf(5), bar.getList().get(1));
obj = blueprintContainer.getComponentInstance("foo");
assertNotNull(obj);
assertEquals(Foo.class, obj.getClass());
Foo foo = (Foo) obj;
assertEquals(5, foo.getA());
assertEquals(10, foo.getB());
assertSame(bar, foo.getBar());
assertEquals(Currency.getInstance("PLN"), foo.getCurrency());
assertEquals(new SimpleDateFormat("yyyy.MM.dd").parse("2009.04.17"),
foo.getDate());
assertTrue(foo.isInitialized());
assertFalse(foo.isDestroyed());
obj = context.getService(Foo.class);
assertNotNull(obj);
assertEquals(obj, foo);
obj = blueprintContainer.getComponentInstance("accountOne");
assertNotNull(obj);
Account account = (Account)obj;
assertEquals(1, account.getAccountNumber());
obj = blueprintContainer.getComponentInstance("accountTwo");
assertNotNull(obj);
account = (Account)obj;
assertEquals(2, account.getAccountNumber());
obj = blueprintContainer.getComponentInstance("accountThree");
assertNotNull(obj);
account = (Account)obj;
assertEquals(3, account.getAccountNumber());
obj = blueprintContainer.getComponentInstance("accountFactory");
assertNotNull(obj);
AccountFactory accountFactory = (AccountFactory)obj;
assertEquals("account factory", accountFactory.getFactoryName());
bundle.stop();