use of org.apache.aries.blueprint.sample.Account in project aries by apache.
the class Helper method testBlueprintContainer.
public static void testBlueprintContainer(RichBundleContext context, Bundle bundle) throws Exception {
BlueprintContainer blueprintContainer = getBlueprintContainerForBundle(context, SAMPLE_SYM_NAME);
assertNotNull(blueprintContainer);
Bar bar = getInstance(blueprintContainer, "bar", Bar.class);
checkBar(bar);
Foo foo = getInstance(blueprintContainer, "foo", Foo.class);
checkFoo(bar, foo);
Foo fooService = context.getService(Foo.class);
assertNotNull(fooService);
checkFoo(bar, fooService);
// TODO Does not work
//assertEquals(obj, foo);
Account account = getInstance(blueprintContainer, "accountOne", Account.class);
assertEquals(1, account.getAccountNumber());
Account account2 = getInstance(blueprintContainer, "accountTwo", Account.class);
assertEquals(2, account2.getAccountNumber());
Account account3 = getInstance(blueprintContainer, "accountThree", Account.class);
assertEquals(3, account3.getAccountNumber());
AccountFactory accountFactory = getInstance(blueprintContainer, "accountFactory", AccountFactory.class);
assertEquals("account factory", accountFactory.getFactoryName());
bundle.stop();
Thread.sleep(1000);
try {
blueprintContainer = getBlueprintContainerForBundle(context, SAMPLE_SYM_NAME, 1);
fail("BlueprintContainer should have been unregistered");
} catch (Exception e) {
// Expected, as the module container should have been unregistered
}
assertTrue(foo.isInitialized());
assertTrue(foo.isDestroyed());
}
Aggregations