use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class MultipleServiceDependencyTest method testReplacementCallbacks.
public void testReplacementCallbacks() {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a service provider and consumer
Component provider = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
Component provider2 = m.createComponent().setImplementation(new ServiceProvider2(e)).setInterface(ServiceInterface.class.getName(), null);
Component consumer = m.createComponent().setImplementation(new ServiceConsumer(e)).add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(true).setCallbacks("add", "remove"));
m.add(provider2);
m.add(consumer);
e.waitForStep(3, 15000);
m.add(provider);
m.remove(provider2);
e.step(4);
e.waitForStep(5, 15000);
m.remove(provider);
m.remove(consumer);
e.waitForStep(6, 15000);
}
use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class OptionalConfigurationDependencyTest method testOptionalConfigurationConsumer.
public void testOptionalConfigurationConsumer() {
DependencyManager m = getDM();
Ensure e = new Ensure();
Component c1 = m.createComponent().setImplementation(new ConfigurationCreator(e, PID, 3)).add(m.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true));
Component c2 = m.createComponent().setImplementation(new OptionalConfigurationConsumer(e)).add(m.createConfigurationDependency().setCallback("updated", MyConfig.class).setPid(PID).setPropagate(true).setRequired(false));
m.add(c2);
// c2 called in updated with testKey="default" config
e.waitForStep(1, 5000);
// c2 called in start()
e.waitForStep(2, 5000);
// c1 registers a "testKey=testvalue" configuration, using config admin.
m.add(c1);
// c1 created the conf.
e.waitForStep(3, 5000);
// c2 called in updated with testKey="testvalue"
e.waitForStep(4, 5000);
// remove configuration.
m.remove(c1);
// c2 called in updated with default "testkey=default" property (using the default method from the config interface.
e.waitForStep(5, 5000);
// stop the OptionalConfigurationConsumer component
m.remove(c2);
// c2 stopped
e.waitForStep(6, 5000);
}
use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class AspectAnnotationTest method testAspectChain.
public void testAspectChain() throws Throwable {
Ensure e = new Ensure();
// Activate service consumer
ServiceRegistration scSequencer = register(e, ServiceConsumer.ENSURE);
// Activate service provider
ServiceRegistration spSequencer = register(e, ServiceProvider.ENSURE);
// Activate service aspect 2
ServiceRegistration sa2Sequencer = register(e, ServiceAspect2.ENSURE);
// Activate service aspect 3
ServiceRegistration sa3Sequencer = register(e, ServiceAspect3.ENSURE);
// Activate service aspect 1
ServiceRegistration sa1Sequencer = register(e, ServiceAspect1.ENSURE);
e.step();
e.waitForStep(6, 10000);
// Deactivate service provider
spSequencer.unregister();
// Make sure that service aspect 1 has been called in ts removed and stop callbacks
e.waitForStep(8, 10000);
e.ensure();
scSequencer.unregister();
sa1Sequencer.unregister();
sa2Sequencer.unregister();
sa3Sequencer.unregister();
}
use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class AspectLifecycleAnnotationTest method testAnnotatedAspect.
public void testAnnotatedAspect() {
Ensure e = new Ensure();
// Provide the Sequencer server to the ServiceProvider service
ServiceRegistration sr1 = register(e, ServiceProvider.ENSURE);
// Check if the ServiceProvider has been injected in the AspectTest service.
e.waitForStep(1, 10000);
// Provide the Sequencer server to the ServiceProviderAspect service
ServiceRegistration sr2 = register(e, ServiceProviderAspect.ENSURE);
// Check if the AspectTest has been injected with the aspect
e.waitForStep(3, 10000);
// Stop the ServiceProviderAspect service.
sr2.unregister();
// And check if the aspect has been called in its stop/destroy methods.
e.waitForStep(7, 10000);
sr1.unregister();
}
use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.
the class AspectLifecycleWithDynamicProxyAnnotationTest method testAnnotatedAspect.
public void testAnnotatedAspect() {
Ensure e = new Ensure();
// Provide the Sequencer server to the ServiceProvider service
ServiceRegistration sr1 = register(e, ServiceProvider.ENSURE);
// Check if the ServiceProvider has been injected in the AspectTest service.
e.waitForStep(1, 10000);
// Provide the Sequencer server to the ServiceProviderAspect service
ServiceRegistration sr2 = register(e, ServiceProviderAspect.ENSURE);
// Check if the AspectTest has been injected with the aspect
e.waitForStep(3, 10000);
// Remove the ServiceProviderAspect service
sr2.unregister();
// And check if the aspect has been called in its stop/destroy methods.
e.waitForStep(7, 10000);
sr1.unregister();
}
Aggregations