Search in sources :

Example 1 with DestroyTest

use of org.apache.aries.blueprint.sample.DestroyTest in project aries by apache.

the class TestReferences method testReferencesCallableInDestroy.

@Test
public void testReferencesCallableInDestroy() throws Exception {
    bundleContext.registerService(Runnable.class.getName(), new Thread(), null);
    BlueprintContainer blueprintContainer = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
    assertNotNull(blueprintContainer);
    DestroyTest dt = (DestroyTest) blueprintContainer.getComponentInstance("destroyCallingReference");
    Bundle b = findBundle("org.apache.aries.blueprint.sample");
    assertNotNull(b);
    b.stop();
    assertTrue("The destroy method was called", dt.waitForDestruction(1000));
    Exception e = dt.getDestroyFailure();
    if (e != null)
        throw e;
}
Also used : BlueprintContainer(org.osgi.service.blueprint.container.BlueprintContainer) Bundle(org.osgi.framework.Bundle) Helper.mvnBundle(org.apache.aries.blueprint.itests.Helper.mvnBundle) DefaultRunnable(org.apache.aries.blueprint.sample.DefaultRunnable) DestroyTest(org.apache.aries.blueprint.sample.DestroyTest) ServiceUnavailableException(org.osgi.service.blueprint.container.ServiceUnavailableException) DestroyTest(org.apache.aries.blueprint.sample.DestroyTest) Test(org.junit.Test)

Aggregations

Helper.mvnBundle (org.apache.aries.blueprint.itests.Helper.mvnBundle)1 DefaultRunnable (org.apache.aries.blueprint.sample.DefaultRunnable)1 DestroyTest (org.apache.aries.blueprint.sample.DestroyTest)1 Test (org.junit.Test)1 Bundle (org.osgi.framework.Bundle)1 BlueprintContainer (org.osgi.service.blueprint.container.BlueprintContainer)1 ServiceUnavailableException (org.osgi.service.blueprint.container.ServiceUnavailableException)1