use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class BundleAdapterWithCallbacksNotAutoConfiguredTest method testBundleAdapterWithCallbacksNotAutoConfigured.
public void testBundleAdapterWithCallbacksNotAutoConfigured() {
DependencyManager m = getDM();
// create a bundle adapter service (one is created for each bundle)
BundleAdapterWithCallback baWithCb = new BundleAdapterWithCallback();
String bsn = "org.apache.felix.dependencymanager";
String filter = "(Bundle-SymbolicName=" + bsn + ")";
Component adapter = m.createBundleAdapterService(Bundle.ACTIVE, filter, false, null, "add", null, null).setImplementation(baWithCb);
// add the bundle adapter
m.add(adapter);
// Check if adapter has not been auto configured (because it has callbacks defined).
m_e.waitForStep(1, 3000);
Assert.assertNull("bundle adapter must not be auto configured", baWithCb.getBundle());
// remove the bundle adapters
m.remove(adapter);
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class BundleDependencyTest method testRequiredBundleDependency.
public void testRequiredBundleDependency() {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
Component consumerWithFilter = m.createComponent().setImplementation(new FilteredConsumerRequired(e)).add(m.createBundleDependency().setRequired(true).setFilter("(Bundle-SymbolicName=" + BSN + ")").setCallbacks("add", "remove"));
// add a consumer with a filter
m.add(consumerWithFilter);
e.waitForStep(1, 5000);
// remove the consumer again
m.remove(consumerWithFilter);
e.waitForStep(2, 5000);
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class ComponentStateListenerTest method testDynamicComponentStateListingLifeCycle.
public void testDynamicComponentStateListingLifeCycle() {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a simple service component
Component s = m.createComponent().setInterface(MyInterface.class.getName(), null).setImplementation(new DynamicComponentStateListeningInstance(e));
// add it, and since it has no dependencies, it should be activated immediately
m.add(s);
// remove it so it gets destroyed
m.remove(s);
// ensure we executed all steps inside the component instance
e.step(10);
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class ComponentStateListenerTest method testCustomComponentLifeCycleCallbacks.
public void testCustomComponentLifeCycleCallbacks() {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a simple service component
Component s = m.createComponent().setImplementation(new CustomComponentInstance(e)).setCallbacks("a", "b", "c", "d");
// add it, and since it has no dependencies, it should be activated immediately
m.add(s);
// remove it so it gets destroyed
m.remove(s);
// ensure we executed all steps inside the component instance
e.step(6);
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class ComponentStateListenerTest method testComponentLifeCycleCallbacks.
public void testComponentLifeCycleCallbacks() {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a simple service component
Component s = m.createComponent().setImplementation(new ComponentInstance(e));
// add it, and since it has no dependencies, it should be activated immediately
m.add(s);
// remove it so it gets destroyed
m.remove(s);
// ensure we executed all steps inside the component instance
e.step(6);
}
Aggregations