use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class MultipleExtraDependencyTest method testMultipleExtraDependencies.
public void testMultipleExtraDependencies() {
DependencyManager m = getDM();
Ensure e = new Ensure();
Component sp2 = component(m).impl(ServiceProvider2.class).provides(ServiceProvider2.class).withSvc(Runnable.class, srv -> srv.filter("(foo=bar)").required(false).autoConfig("m_runnable")).withSvc(Sequencer.class, srv -> srv.add("bind")).composition("getComposition").build();
Component sp = component(m).impl(ServiceProvider.class).provides(ServiceInterface.class, foo -> "bar").start("start").stop("stop").withSvc(Sequencer.class, srv -> srv.autoConfig("m_sequencer")).withSvc(ServiceProvider2.class, srv -> srv.add("bind").remove("unbind")).build();
Component sc = component(m).impl(ServiceConsumer.class).start("start").stop("stop").withSvc(Sequencer.class, srv -> srv.autoConfig("m_sequencer")).withSvc(ServiceInterface.class, srv -> srv.filter("(foo=bar)").autoConfig("m_service")).build();
Component sequencer = component(m).impl(new SequencerImpl(e)).provides(Sequencer.class.getName()).build();
m.add(sp2);
m.add(sp);
m.add(sc);
m.add(sequencer);
// Check if ServiceProvider component have been initialized orderly
e.waitForStep(7, 5000);
// Stop the test.annotation bundle
m.remove(sequencer);
m.remove(sp);
m.remove(sp2);
m.remove(sc);
// And check if ServiceProvider2 has been deactivated orderly
e.waitForStep(11, 5000);
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class MultipleServiceDependencyTest method testMultipleServiceRegistrationAndConsumption.
public void testMultipleServiceRegistrationAndConsumption() {
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 = component(m).impl(new ServiceProvider(e)).provides(ServiceInterface.class.getName()).build();
Component providerWithHighRank = component(m).impl(new ServiceProvider2(e)).provides(ServiceInterface.class.getName(), Constants.SERVICE_RANKING, Integer.valueOf(5)).build();
Component consumer = component(m).impl(new ServiceConsumer(e)).withSvc(ServiceInterface.class, true).build();
m.add(provider);
m.add(providerWithHighRank);
m.add(consumer);
e.waitForStep(3, 5000);
m.remove(providerWithHighRank);
e.step(4);
e.waitForStep(5, 5000);
m.remove(provider);
m.remove(consumer);
e.waitForStep(6, 5000);
}
use of org.apache.felix.dm.DependencyManager 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 = component(m).impl(new ServiceProvider(e)).provides(ServiceInterface.class.getName()).build();
Component provider2 = component(m).impl(new ServiceProvider2(e)).provides(ServiceInterface.class.getName()).build();
Component consumer = component(m).impl(new ServiceConsumer(e)).withSvc(ServiceInterface.class, srv -> srv.add("add").remove("remove")).build();
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.DependencyManager in project felix by apache.
the class DynamicCustomIndexTest method doTestUsingDynamicCustomIndex.
private void doTestUsingDynamicCustomIndex() throws Exception {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a provider
Provider provider = new Provider();
// activate it
Component p = m.createComponent().setInterface(Service.class.getName(), null).setImplementation(provider);
Client consumer = new Client(e);
Component c = m.createComponent().setImplementation(consumer).add(m.createServiceDependency().setService(Service.class).setRequired(true));
m.add(p);
m.add(c);
e.waitForStep(1, 5000);
m.remove(p);
e.waitForStep(2, 5000);
m.remove(c);
m.clear();
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class StaticCustomIndexTest method testUsingStaticCustomIndex.
public void testUsingStaticCustomIndex() throws Exception {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a provider
Provider provider = new Provider();
// activate it
Component p = m.createComponent().setInterface(Service.class.getName(), null).setImplementation(provider);
Client consumer = new Client(e);
Component c = m.createComponent().setImplementation(consumer).add(m.createServiceDependency().setService(Service.class).setRequired(true));
m.add(p);
m.add(c);
e.waitForStep(1, 5000);
m.remove(p);
e.waitForStep(2, 5000);
m.remove(c);
m.clear();
// Make sure our static custom index has been used
Assert.assertTrue(Boolean.getBoolean(OPENED));
}
Aggregations