Package org.apache.felix.scr.integration.components

Examples of org.apache.felix.scr.integration.components.SimpleServiceImpl


    }

    @Test
    public void test_multi_service_bind_unbind_order() throws Exception
    {
        final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
        final SimpleService2Impl srv2 = SimpleService2Impl.create( bundleContext, "srv2" );

        String name ="test_multi_service_bind_unbind_order";
        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);

        final SimpleComponent2 comp10 = SimpleComponent2.INSTANCE;
        TestCase.assertNotNull( comp10 );
        TestCase.assertEquals( 2, comp10.getBindings().size() );
        TestCase.assertEquals( "bindSimpleService", comp10.getBindings().get( 0 ) );
        TestCase.assertEquals( "bindSimpleService2", comp10.getBindings().get( 1 ) );

        disableAndCheck(cc);
        delay();

        TestCase.assertEquals( 4, comp10.getBindings().size() );
        TestCase.assertEquals( "bindSimpleService", comp10.getBindings().get( 0 ) );
        TestCase.assertEquals( "bindSimpleService2", comp10.getBindings().get( 1 ) );
        TestCase.assertEquals( "unbindSimpleService2", comp10.getBindings().get( 2 ) );
        TestCase.assertEquals( "unbindSimpleService", comp10.getBindings().get( 3 ) );

        srv1.drop();
        srv2.drop();
    }
View Full Code Here


        getConfigurationsDisabledThenEnable(componentname, 0, -1);
        TestCase.assertNull( SimpleComponent.INSTANCE );

        // register a service : filterprop=match
        SimpleServiceImpl match = SimpleServiceImpl.create( bundleContext, "required" ).setFilterProperty( "required" );
        delay();

        TestCase.assertNull( SimpleComponent.INSTANCE );

        final ComponentInstance instance = createFactoryComponentInstance(componentfactory);
        TestCase.assertEquals( 1, SimpleComponent.INSTANCE.m_multiRef.size() );
        TestCase.assertTrue( SimpleComponent.INSTANCE.m_multiRef.contains( match ) );

        // check registered components
        checkConfigurationCount(componentname, 1, ComponentConfigurationDTO.ACTIVE);

        instance.dispose();
        TestCase.assertNull( SimpleComponent.INSTANCE );
        TestCase.assertNull( instance.getInstance() ); // SCR 112.12.6.2
        checkConfigurationCount(componentname, 0, ComponentConfigurationDTO.ACTIVE);


        // overwritten filterprop
        Hashtable<String, String> propsNonMatch = new Hashtable<String, String>();
        propsNonMatch.put( PROP_NAME_FACTORY, PROP_NAME_FACTORY );
        propsNonMatch.put( "ref.target", "(filterprop=nomatch)" );
        ComponentFactory factory = getComponentFactory(componentfactory);
        final ComponentInstance instanceNonMatch = factory.newInstance( propsNonMatch );//works even without required reference
        checkConfigurationCount(componentname, 1, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);

        final SimpleServiceImpl noMatch = SimpleServiceImpl.create( bundleContext, "nomatch" ).setFilterProperty(
            "nomatch" );
        delay();


        TestCase.assertNotNull( instanceNonMatch.getInstance() );
        TestCase.assertEquals( SimpleComponent.INSTANCE, instanceNonMatch.getInstance() );
        TestCase.assertEquals( PROP_NAME_FACTORY, SimpleComponent.INSTANCE.getProperty( PROP_NAME_FACTORY ) );

        TestCase.assertEquals( 1, SimpleComponent.INSTANCE.m_multiRef.size() );
        TestCase.assertTrue( SimpleComponent.INSTANCE.m_multiRef.contains( noMatch ) );

        // check registered components
        checkConfigurationCount(componentname, 1, ComponentConfigurationDTO.ACTIVE);

        match.getRegistration().unregister();
        delay();

        // check registered components (ComponentFactory is still present)
        checkConfigurationCount(componentname, 1, ComponentConfigurationDTO.ACTIVE);

        //it has already been deactivated.... this should cause an exception?
        noMatch.getRegistration().unregister();
        delay();

        // check registered components (ComponentFactory is still present)
        checkConfigurationCount(componentname, 1, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
View Full Code Here

    public void test_component_factory_with_target_filters() throws Exception
    {
        final String componentfactory = "factory.component.reference.targetfilter";
        getConfigurationsDisabledThenEnable(componentfactory, 0, -1);

        SimpleServiceImpl s1 = SimpleServiceImpl.create(bundleContext, "service1");
        SimpleServiceImpl s2 = SimpleServiceImpl.create(bundleContext, "service2");

        // supply configuration now and ensure active
        configure( componentfactory );
        delay();       

        TestCase.assertNull( SimpleComponent.INSTANCE );
       
        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put( PROP_NAME_FACTORY, PROP_NAME_FACTORY );
        props.put("ref.target", "(value=service2)");
        final ComponentInstance instance = createFactoryComponentInstance(componentfactory, props);

        log.log(LogService.LOG_WARNING, "Bound Services: " +  SimpleComponent.INSTANCE.m_multiRef);
        TestCase.assertFalse( SimpleComponent.INSTANCE.m_multiRef.contains( s1 ) );
        TestCase.assertTrue( SimpleComponent.INSTANCE.m_multiRef.contains( s2 ) );

        instance.dispose();
        TestCase.assertNull( SimpleComponent.INSTANCE );
        TestCase.assertNull( instance.getInstance() ); // SCR 112.12.6.2
       
        s2.drop();
        s1.drop();
    }
View Full Code Here

    @Test
    public void test_component_factory_set_bundle_location_null() throws Exception
    {
        final String componentfactory = "factory.component.reference.targetfilter";
        getConfigurationsDisabledThenEnable(componentfactory, 0, -1);
        SimpleServiceImpl s1 = SimpleServiceImpl.create(bundleContext, "service1");

        ConfigurationAdmin ca = getConfigurationAdmin();
        org.osgi.service.cm.Configuration config = ca.getConfiguration( componentfactory, null );
        config.setBundleLocation( null );
        delay();
        if ( isAtLeastR5() )
        {
            //check that ConfigurationSupport got a Location changed event and set the bundle location
            TestCase.assertNotNull( config.getBundleLocation() );
        }
        // supply configuration now and ensure active
        configure( componentfactory );
        delay();       

        TestCase.assertNull( SimpleComponent.INSTANCE );
       
        final ComponentFactory factory = getComponentFactory(componentfactory);
       
        s1.drop();
    }
View Full Code Here


    @Test
    public void test_optional_single_dynamic() throws Exception
    {
        final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
        String name = "test_optional_single_dynamic_target";
    getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);

        final SimpleComponent comp10 = SimpleComponent.INSTANCE;
        TestCase.assertNotNull( comp10 );
        TestCase.assertEquals( srv1, comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 0, comp10.m_singleRefUnbind);

        // update a service property
        srv1.update( "srv1-modified" );

        // no changes in bindings expected
        TestCase.assertEquals( srv1, comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 0, comp10.m_singleRefUnbind);

        // set target to not match any more
        srv1.setFilterProperty( "don't match" );

        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp11 = SimpleComponent.INSTANCE;
        TestCase.assertSame( comp10, comp11 );
        TestCase.assertNull( comp11.m_singleRef );
        TestCase.assertTrue( comp11.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 1, comp10.m_singleRefUnbind);

        final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
        delay(); // async binding

        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp12 = SimpleComponent.INSTANCE;
        TestCase.assertSame( comp10, comp12 );
        TestCase.assertEquals( srv2, comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
        TestCase.assertEquals( 2, comp10.m_singleRefBind );
        TestCase.assertEquals( 1, comp10.m_singleRefUnbind);

        // make srv1 match again, expect not changes in bindings
        srv1.setFilterProperty( "match" );
        TestCase.assertEquals( srv2, comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
        TestCase.assertEquals( 2, comp10.m_singleRefBind );
        TestCase.assertEquals( 1, comp10.m_singleRefUnbind);

        // make srv2 to not match, expect binding to srv1
        srv2.setFilterProperty( "don't match" );
        TestCase.assertEquals( srv1, comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
        TestCase.assertEquals( 3, comp10.m_singleRefBind );
        TestCase.assertEquals( 2, comp10.m_singleRefUnbind);
    }
View Full Code Here


    @Test
    public void test_required_single_dynamic() throws Exception
    {
        final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
        String name = "test_required_single_dynamic_target";
    getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
   
        final SimpleComponent comp10 = SimpleComponent.INSTANCE;
        TestCase.assertNotNull( comp10 );
        TestCase.assertEquals( srv1, comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 0, comp10.m_singleRefUnbind);

        // update a service property
        srv1.update( "srv1-modified" );

        // no changes in bindings expected
        TestCase.assertEquals( srv1, comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 0, comp10.m_singleRefUnbind);

        // set target to not match any more -> deactivate this component
        srv1.setFilterProperty( "don't match" );
        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
        TestCase.assertNull( SimpleComponent.INSTANCE );
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 1, comp10.m_singleRefUnbind);

        final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
        delay(); // async binding

        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp12 = SimpleComponent.INSTANCE;
        TestCase.assertNotSame( comp10, comp12 );
        TestCase.assertEquals( srv2, comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp12.m_singleRefBind );
        TestCase.assertEquals( 0, comp12.m_singleRefUnbind);

        // make srv1 match again, expect not changes in bindings
        srv1.setFilterProperty( "match" );
        TestCase.assertEquals( srv2, comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp12.m_singleRefBind );
        TestCase.assertEquals( 0, comp12.m_singleRefUnbind);

        // make srv2 to not match, expect binding to srv1
        srv2.setFilterProperty( "don't match" );
        TestCase.assertEquals( srv1, comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
        TestCase.assertEquals( 2, comp12.m_singleRefBind );
        TestCase.assertEquals( 1, comp12.m_singleRefUnbind);
    }
View Full Code Here


    @Test
    public void test_optional_multiple_dynamic() throws Exception
    {
        final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
        String name = "test_optional_multiple_dynamic_target";
    getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp10 = SimpleComponent.INSTANCE;
        TestCase.assertNotNull( comp10 );
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.contains( srv1 ) );
        TestCase.assertEquals( 1, comp10.m_multiRefBind );
        TestCase.assertEquals( 0, comp10.m_multiRefUnbind);

        // update a service property
        srv1.update( "srv1-modified" );

        // no changes in bindings expected
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.contains( srv1 ) );
        TestCase.assertEquals( 1, comp10.m_multiRefBind );
        TestCase.assertEquals( 0, comp10.m_multiRefUnbind);

        // set target to not match any more
        srv1.setFilterProperty( "don't match" );

        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp11 = SimpleComponent.INSTANCE;
        TestCase.assertSame( comp10, comp11 );
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertFalse( comp10.m_multiRef.contains( srv1 ) );
        TestCase.assertEquals( 1, comp10.m_multiRefBind );
        TestCase.assertEquals( 1, comp10.m_multiRefUnbind);

        final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
        delay(); // async binding

        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp12 = SimpleComponent.INSTANCE;
        TestCase.assertSame( comp10, comp12 );
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertFalse( comp10.m_multiRef.contains( srv1 ) );
        TestCase.assertTrue( comp10.m_multiRef.contains( srv2 ) );
        TestCase.assertEquals( 2, comp10.m_multiRefBind );
        TestCase.assertEquals( 1, comp10.m_multiRefUnbind);

        // make srv1 match again, expect not changes in bindings
        srv1.setFilterProperty( "match" );
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.contains( srv1 ) );
        TestCase.assertTrue( comp10.m_multiRef.contains( srv2 ) );
        TestCase.assertEquals( 3, comp10.m_multiRefBind );
        TestCase.assertEquals( 1, comp10.m_multiRefUnbind);

        // make srv2 to not match, expect binding to srv1
        srv2.setFilterProperty( "don't match" );
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.contains( srv1 ) );
        TestCase.assertFalse( comp10.m_multiRef.contains( srv2 ) );
        TestCase.assertEquals( 3, comp10.m_multiRefBind );
        TestCase.assertEquals( 2, comp10.m_multiRefUnbind);
View Full Code Here


    @Test
    public void test_required_multiple_dynamic() throws Exception
    {
        final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
        String name = "test_required_multiple_dynamic_target";
    getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp10 = SimpleComponent.INSTANCE;
        TestCase.assertNotNull( comp10 );
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.contains( srv1 ) );
        TestCase.assertEquals( 1, comp10.m_multiRefBind );
        TestCase.assertEquals( 0, comp10.m_multiRefUnbind);

        // update a service property
        srv1.update( "srv1-modified" );

        // no changes in bindings expected
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.contains( srv1 ) );
        TestCase.assertEquals( 1, comp10.m_multiRefBind );
        TestCase.assertEquals( 0, comp10.m_multiRefUnbind);

        // set target to not match any more
        srv1.setFilterProperty( "don't match" );

        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
        final SimpleComponent comp11 = SimpleComponent.INSTANCE;
        TestCase.assertNull( comp11 );
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertFalse( comp10.m_multiRef.contains( srv1 ) );
        TestCase.assertEquals( 1, comp10.m_multiRefBind );
        TestCase.assertEquals( 1, comp10.m_multiRefUnbind);

        final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
        delay(); // async binding

        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp12 = SimpleComponent.INSTANCE;
        TestCase.assertNotSame( comp10, comp12 );
        TestCase.assertNull( comp12.m_singleRef );
        TestCase.assertFalse( comp12.m_multiRef.contains( srv1 ) );
        TestCase.assertTrue( comp12.m_multiRef.contains( srv2 ) );
        TestCase.assertEquals( 1, comp12.m_multiRefBind );
        TestCase.assertEquals( 0, comp12.m_multiRefUnbind);

        // make srv1 match again, expect not changes in bindings
        srv1.setFilterProperty( "match" );
        TestCase.assertNull( comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.contains( srv1 ) );
        TestCase.assertTrue( comp12.m_multiRef.contains( srv2 ) );
        TestCase.assertEquals( 2, comp12.m_multiRefBind );
        TestCase.assertEquals( 0, comp12.m_multiRefUnbind);

        // make srv2 to not match, expect binding to srv1
        srv2.setFilterProperty( "don't match" );
        TestCase.assertNull( comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.contains( srv1 ) );
        TestCase.assertFalse( comp12.m_multiRef.contains( srv2 ) );
        TestCase.assertEquals( 2, comp12.m_multiRefBind );
        TestCase.assertEquals( 1, comp12.m_multiRefUnbind);
View Full Code Here


    @Test
    public void test_optional_single_static() throws Exception
    {
        final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
        String name = "test_optional_single_static_target";
    getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp10 = SimpleComponent.INSTANCE;
        TestCase.assertNotNull( comp10 );
        TestCase.assertEquals( srv1, comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 0, comp10.m_singleRefUnbind);

        // update a service property
        srv1.update( "srv1-modified" );

        // no changes in bindings expected
        TestCase.assertEquals( srv1, comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 0, comp10.m_singleRefUnbind);

        // set target to not match any more -> recreate !
        srv1.setFilterProperty( "don't match" );
        delay(); // async reactivation

        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp11 = SimpleComponent.INSTANCE;
        TestCase.assertNotSame( comp10, comp11 );
        TestCase.assertNull( comp11.m_singleRef );
        TestCase.assertTrue( comp11.m_multiRef.isEmpty() );
        TestCase.assertEquals( 0, comp11.m_singleRefBind );
        TestCase.assertEquals( 0, comp11.m_singleRefUnbind);

        final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
        delay(); // async binding

        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp12 = SimpleComponent.INSTANCE;
        TestCase.assertNotSame( comp10, comp12 );
        TestCase.assertSame( comp11, comp12 );
        TestCase.assertNull( comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
        TestCase.assertEquals( 0, comp12.m_singleRefBind );
        TestCase.assertEquals( 0, comp12.m_singleRefUnbind);

        // make srv1 match again, expect not changes in bindings
        srv1.setFilterProperty( "match" );
        final SimpleComponent comp13 = SimpleComponent.INSTANCE;
        TestCase.assertNotSame( comp10, comp13 );
        TestCase.assertSame( comp11, comp13 );
        TestCase.assertSame( comp12, comp13 );
        TestCase.assertNull( comp13.m_singleRef );
        TestCase.assertTrue( comp13.m_multiRef.isEmpty() );
        TestCase.assertEquals( 0, comp13.m_singleRefBind );
        TestCase.assertEquals( 0, comp13.m_singleRefUnbind);

        // make srv2 to not match, expect binding to srv1
        srv2.setFilterProperty( "don't match" );
        final SimpleComponent comp14 = SimpleComponent.INSTANCE;
        TestCase.assertNotSame( comp10, comp14 );
        TestCase.assertSame( comp11, comp14 );
        TestCase.assertSame( comp12, comp14 );
        TestCase.assertSame( comp13, comp14 );
View Full Code Here


    @Test
    public void test_required_single_static() throws Exception
    {
        final SimpleServiceImpl srv1 = SimpleServiceImpl.create( bundleContext, "srv1" );
        String name = "test_required_single_static_target";
    getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp10 = SimpleComponent.INSTANCE;
        TestCase.assertNotNull( comp10 );
        TestCase.assertEquals( srv1, comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 0, comp10.m_singleRefUnbind);

        // update a service property
        srv1.update( "srv1-modified" );

        // no changes in bindings expected
        TestCase.assertEquals( srv1, comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 0, comp10.m_singleRefUnbind);

        // set target to not match any more -> deactivate this component
        srv1.setFilterProperty( "don't match" );
        findComponentConfigurationByName(name, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
        TestCase.assertNull( SimpleComponent.INSTANCE );
        TestCase.assertNull( comp10.m_singleRef );
        TestCase.assertTrue( comp10.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp10.m_singleRefBind );
        TestCase.assertEquals( 1, comp10.m_singleRefUnbind);

        final SimpleServiceImpl srv2 = SimpleServiceImpl.create( bundleContext, "srv2" );
        delay(); // async binding

        findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
        final SimpleComponent comp12 = SimpleComponent.INSTANCE;
        TestCase.assertNotSame( comp10, comp12 );
        TestCase.assertEquals( srv2, comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp12.m_singleRefBind );
        TestCase.assertEquals( 0, comp12.m_singleRefUnbind);

        // make srv1 match again, expect not changes in bindings
        srv1.setFilterProperty( "match" );
        final SimpleComponent comp13 = SimpleComponent.INSTANCE;
        TestCase.assertNotSame( comp10, comp12 );
        TestCase.assertSame( comp12, comp13 );
        TestCase.assertEquals( srv2, comp12.m_singleRef );
        TestCase.assertTrue( comp12.m_multiRef.isEmpty() );
        TestCase.assertEquals( 1, comp12.m_singleRefBind );
        TestCase.assertEquals( 0, comp12.m_singleRefUnbind);

        // make srv2 to not match, expect binding to srv1
        srv2.setFilterProperty( "don't match" );
        delay(); // reactivation required
        final SimpleComponent comp14 = SimpleComponent.INSTANCE;
        TestCase.assertNotSame( comp10, comp14 );
        TestCase.assertNotSame( comp12, comp14 );
        TestCase.assertNotSame( comp13, comp14 );
View Full Code Here

TOP

Related Classes of org.apache.felix.scr.integration.components.SimpleServiceImpl

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.