use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class ComponentStateListenerTest method testComponentStateListingLifeCycle.
public void testComponentStateListingLifeCycle() {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a simple service component
ComponentStateListeningInstance implementation = new ComponentStateListeningInstance(e);
Component s = m.createComponent().setInterface(MyInterface.class.getName(), null).setImplementation(implementation);
// add the state listener
s.add(implementation);
// 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);
// remove the state listener
s.remove(implementation);
// ensure we executed all steps inside the component instance
e.step(10);
}
use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class CompositionTest method testComposition.
public void testComposition() {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a service provider and consumer
Component sp = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
Component sc = m.createComponent().setImplementation(new ServiceConsumer(e)).setComposition("getComposition").add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(true).setCallbacks("add", null));
m.add(sp);
m.add(sc);
// ensure we executed all steps inside the component instance
e.step(6);
m.clear();
}
use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class ConfigurationDependencyTest method testComponentWithRequiredConfigurationAndCallbackInstanceWithComponentArgAndServicePropertyPropagation.
public void testComponentWithRequiredConfigurationAndCallbackInstanceWithComponentArgAndServicePropertyPropagation() {
Ensure e = new Ensure();
ConfigurationConsumerCallbackInstanceWithComponentArg callbackInstance = new ConfigurationConsumerCallbackInstanceWithComponentArg(e);
testComponentWithRequiredConfigurationAndCallbackInstanceAndServicePropertyPropagation(callbackInstance, "updateConfiguration", e);
}
use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class ConfigurationDependencyTest method testComponentWithRequiredConfigurationAndCallbackInstanceAndServicePropertyPropagation.
public void testComponentWithRequiredConfigurationAndCallbackInstanceAndServicePropertyPropagation() {
Ensure e = new Ensure();
ConfigurationConsumerCallbackInstance callbackInstance = new ConfigurationConsumerCallbackInstance(e);
testComponentWithRequiredConfigurationAndCallbackInstanceAndServicePropertyPropagation(callbackInstance, "updateConfiguration", e);
}
use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class ConfigurationDependencyTest method testComponentWithRequiredConfigurationAndServicePropertyPropagation.
public void testComponentWithRequiredConfigurationAndServicePropertyPropagation() {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a service provider and consumer
Component s1 = m.createComponent().setImplementation(new ConfigurationConsumer(e)).setInterface(Runnable.class.getName(), null).add(m.createConfigurationDependency().setPid(PID).setPropagate(true));
Component s2 = m.createComponent().setImplementation(new ConfigurationCreator(e, PID)).add(m.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true));
Component s3 = m.createComponent().setImplementation(new ConfiguredServiceConsumer(e)).add(m.createServiceDependency().setService(Runnable.class, ("(testkey=testvalue)")).setRequired(true));
m.add(s1);
m.add(s2);
m.add(s3);
e.waitForStep(4, 5000);
m.remove(s1);
m.remove(s2);
m.remove(s3);
// ensure we executed all steps inside the component instance
e.step(6);
}
Aggregations