Package org.apache.felix.dm.test.components

Examples of org.apache.felix.dm.test.components.Ensure


        DependencyManager m = new DependencyManager(context);
        // create a service provider and consumer
        Consumer c = new Consumer();
       
        // 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=org.apache.felix.dependencymanager)")
                .setCallbacks("add", "remove")
                );
        // add a consumer with a filter
        m.add(consumerWithFilter);
        e.waitForStep(1, 10000);
        // remove the consumer again
        m.remove(consumerWithFilter);
        e.waitForStep(2, 10000);
    }
View Full Code Here


public class CompositionTest extends TestBase {
    @Test
    public void testComposition() {
        DependencyManager m = new DependencyManager(context);
        // 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();
    }
View Full Code Here

@RunWith(PaxExam.class)
public class ServiceDependencyInjectionTest extends TestBase {
    @Test
    public void testServiceInjection() {
        DependencyManager m = new DependencyManager(context);
        Ensure e = new Ensure();
        // create a service provider and consumer
        ServiceProvider provider = new ServiceProvider(e);
        Component sp = m.createComponent().setImplementation(provider).setInterface(ServiceInterface2.class.getName(), null);
        Component sc = m.createComponent().setImplementation(new ServiceConsumer()).add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(true));
        Component sc2 = m.createComponent()
            .setImplementation(new ServiceConsumerNamedInjection())
            .add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(false).setAutoConfig("m_service"))
            .add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(false).setAutoConfig("m_service2"))
            .add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(false).setAutoConfig("m_service3"))
            ;
        m.add(sp);
        m.add(sc);
        m.remove(sc);
        m.add(sc2);
        m.remove(sc2);
        m.remove(sp);
        e.waitForStep(5, 5000);
    }
View Full Code Here

public class SharingDependenciesWithMultipleServicesTest extends TestBase {
    @Test
    public void testShareServiceDependencyWithMultipleServices() {
        DependencyManager m = new DependencyManager(context);
        // 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()).setInterface(ServiceInterface.class.getName(), null);
        ServiceDependency dependency = m.createServiceDependency().setService(ServiceInterface.class).setRequired(true);
        Component consumer1 = m.createComponent().setImplementation(new ServiceConsumer(e, 1)).add(dependency);
        Component consumer2 = m.createComponent().setImplementation(new ServiceConsumer(e, 4)).add(dependency);
       
        m.add(provider);
        m.add(consumer1);
        e.waitForStep(3, 15000);
        m.add(consumer2);
        e.waitForStep(6, 15000);
        m.remove(provider);
        m.remove(consumer1);
        m.remove(consumer2);
    }
View Full Code Here

   
    @Test
    public void testShareConfigurationDependencyWithMultipleServices() {
        DependencyManager m = new DependencyManager(context);
        // 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 ConfigurationProvider(e)).add(m.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true));
        ConfigurationDependency dependency = m.createConfigurationDependency().setPid("test");
        Component consumer1 = m.createComponent().setImplementation(new ConfigurationConsumer(e, 2)).add(dependency);
        Component consumer2 = m.createComponent().setImplementation(new ConfigurationConsumer(e, 3)).add(dependency);
       
        // add the configuration provider that should publish the configuration as step 1
        m.add(provider);
        // add the first consumer, and wait until its updated() method is invoked
        m.add(consumer1);
        e.waitForStep(2, 15000);

        // add the second consumer, and wait until its updated() method is invoked
        m.add(consumer2);
        e.waitForStep(3, 15000);

        // break down the test again
        m.remove(consumer2);
        m.remove(consumer1);
        m.remove(provider);
View Full Code Here

   
    @Test
    public void testShareBundleDependencyWithMultipleServices() {
        DependencyManager m = new DependencyManager(context);
        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a service provider and consumer
        BundleDependency dependency = m.createBundleDependency().setFilter("(Bundle-SymbolicName=org.apache.felix.dependencymanager)").setRequired(true);
        Component consumer1 = m.createComponent().setImplementation(new BundleConsumer(e, 1)).add(dependency);
        Component consumer2 = m.createComponent().setImplementation(new BundleConsumer(e, 2)).add(dependency);
       
        m.add(consumer1);
        e.waitForStep(1, 15000);
        m.add(consumer2);
        e.waitForStep(2, 15000);
        m.remove(consumer2);
        m.remove(consumer1);
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.dm.test.components.Ensure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.