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

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


public class AdapterWithInstanceBoundDependencyTest extends TestBase {
    @Test
    public void testInstanceBoundDependency() {
        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()
            .setInterface(ServiceInterface.class.getName(), null)
            .setImplementation(new ServiceProvider(e));
        Component sp2 = m.createComponent()
        .setInterface(ServiceInterface2.class.getName(), null)
            .setImplementation(new ServiceProvider2(e));
        Component sc = m.createComponent()
            .setImplementation(new ServiceConsumer())
            .add(m.createServiceDependency()
                .setService(ServiceInterface3.class)
                .setRequired(true));
        Component sa = m.createAdapterService(ServiceInterface.class, null)
            .setInterface(ServiceInterface3.class.getName(), null)
            .setImplementation(new ServiceAdapter(e));
        m.add(sc);
        m.add(sp);
        m.add(sp2);
        m.add(sa);
        e.waitForStep(5, 15000);
        m.remove(sa);
        m.remove(sp2);
        m.remove(sp);
        m.remove(sc);
    }
View Full Code Here


        super(true /* start test components bundle */);
    }

    @Test
    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();
    }
View Full Code Here

        super(true /* start test components bundle */);
    }

    @Test
    public void testTemporalServiceDependency() {
        Ensure ensure = new Ensure();
        ServiceRegistration ensureReg = register(ensure, TemporalAnnotations.ENSURE);
        Dictionary props = new Hashtable() {
            {
                put("test", "temporal");
            }
        };
        Runnable r = Ensure.createRunnableStep(ensure, 1);
        ServiceRegistration sr = context.registerService(Runnable.class.getName(), r, props);
        ensure.waitForStep(1, 15000);
        System.out.println("unregistering R");
        sr.unregister();
        ensure.step(2);
        sleep(500);
        r = Ensure.createRunnableStep(ensure, 3);
        sr = context.registerService(Runnable.class.getName(), r, props);
        ensure.waitForStep(3, 15000);
        sr.unregister();
        ensure.step(4);
        sleep(1500);
        ensure.waitForStep(5, 15000);
        ensureReg.unregister();
    }
View Full Code Here

        super(true /* start test components bundle */);
    }

    @Test
    public void testPropertiesWithTypes() {
        Ensure e = new Ensure();
        ServiceRegistration sr = register(e, Felix4357.ENSURE);
        // wait for S to be started
        e.waitForStep(30, 10000);
        // remove our sequencer: this will stop S
        sr.unregister();
    }
View Full Code Here

     * Check if an adapter gets injected with its adaptee using default auto config mode.
     * @throws Throwable
     */
    @Test
    public void testAnnotatedAdapterAutoConfig() throws Throwable {
        Ensure e = new Ensure();
        ServiceRegistration sr1 = register(e, S1ToS3AdapterAutoConfig.ENSURE);
        ServiceRegistration sr2 = register(e, S1Impl.ENSURE);
        ServiceRegistration sr3 = register(e, S2Impl.ENSURE);
        e.waitForStep(3, 10000);
        e.ensure();
        sr1.unregister();
        sr2.unregister();
        sr3.unregister();
    }
View Full Code Here

    /**
     * Check if an adapter gets injected with its adaptee in a named class field.
     */
    @Test
    public void testAnnotatedAdapterAutoConfigField() throws Throwable {
        Ensure e = new Ensure();
        ServiceRegistration sr1 = register(e, S1ToS3AdapterAutoConfigField.ENSURE);
        ServiceRegistration sr2 = register(e, S1Impl.ENSURE);
        ServiceRegistration sr3 = register(e, S2Impl.ENSURE);
        e.waitForStep(3, 10000);
        e.ensure();
        sr1.unregister();
        sr2.unregister();
        sr3.unregister();
    }
View Full Code Here

    /**
     * Check if an adapter gets injected with its adaptee in a callback method.
     */
    @Test
    public void testAnnotatedAdapterCallback() {
        Ensure e = new Ensure();
        ServiceRegistration sr1 = register(e, S1ToS3AdapterCallback.ENSURE);
        ServiceRegistration sr2 = register(e, S1Impl.ENSURE);
        ServiceRegistration sr3 = register(e, S2Impl.ENSURE);
        e.waitForStep(2, 10000);
        sr1.unregister();
        e.waitForStep(4, 10000);
        sr2.unregister();
        sr3.unregister();
    }
View Full Code Here

        super(true /* start test components bundle */);
    }

    @Test
    public void testFelix4050() {
        Ensure e = new Ensure();
        ServiceRegistration sr = register(e, Felix4050.ENSURE);
        // wait for S to be started
        e.waitForStep(3, 10000);
        // remove our sequencer: this will stop S
        sr.unregister();
        // ensure that S is stopped and destroyed
        e.waitForStep(5, 10000);
    }
View Full Code Here

    /**
     * A Service that just registers/unregisters its service, using the @ServiceLifecycle annotation.
     */
    @Test
    public void testServiceWithPublisher() {
        Ensure e = new Ensure();
        ServiceRegistration sr = register(e, ServiceTestWthPublisher.ENSURE);
        e.waitForStep(4, 10000);
        sr.unregister();
    }
View Full Code Here

     * A Service instantiated from a FactorySet, and which registers/unregisters its service,
     * using the @ServiceLifecycle annotation.
     */
    @Test
    public void testFactoryServiceWithPublisher() {
        Ensure e = new Ensure();
        ServiceRegistration sr = register(e, FactoryServiceTestWthPublisher.ENSURE);
        e.waitForStep(5, 10000);
        sr.unregister();
    }
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.