Package org.apache.felix.scr.impl.manager

Examples of org.apache.felix.scr.impl.manager.SingleComponentManager


        final ComponentMetadata cm = createComponentMetadata( name );
        final TestingConfiguredComponentHolder holder = new TestingConfiguredComponentHolder( cm );

        holder.enableComponents(false);
        // assert single component and no map
        final SingleComponentManager cmgr = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgr );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).size());
    }
View Full Code Here


        final ComponentMetadata cm = createComponentMetadata( name );
        final TestingConfiguredComponentHolder holder = new TestingConfiguredComponentHolder( cm );

        holder.enableComponents(false);
        // assert single component and no map
        final SingleComponentManager cmgr = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgr );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).size());

        // configure with the singleton configuration
        final Dictionary config = new Hashtable();
        config.put( "value", name );
        TargetedPID targetedPid = new TargetedPID(name);
    holder.configurationUpdated( targetedPid, null, config, 0 );

        // assert single component and no map
        final SingleComponentManager cmgrAfterConfig = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgrAfterConfig );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).size());

//        // assert configuration of single component
        final Map componentConfig = ( ( MockImmediateComponentManager ) cmgrAfterConfig ).getConfiguration();
        assertEquals( "Expect exact configuration set", config, componentConfig );

        // unconfigure singleton
        holder.configurationDeleted( targetedPid, null );

        // assert single component and no map
        final SingleComponentManager cmgrAfterUnconfig = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgrAfterUnconfig );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).size());

        // assert no configuration of single component
//TODO multipids fix, correct assertion        assertFalse( "Expect no configuration", cmgrAfterUnconfig.hasConfiguration() );
View Full Code Here

        final TestingConfiguredComponentHolder holder = new TestingConfiguredComponentHolder( cm );
       
        holder.enableComponents(false);

        // assert single component and no map
        final SingleComponentManager cmgr = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgr );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).size());

        // configure with configuration
        final String pid1 = "test.factory.0001";
        final Dictionary config1 = new Hashtable();
        config1.put( "value", pid1 );
        TargetedPID targetedFactoryPid = new TargetedPID(name);
    TargetedPID targetedPid1 = new TargetedPID(pid1);
    holder.configurationUpdated( targetedPid1, targetedFactoryPid, config1, 0 );

        // assert single component and single-entry map
        final SingleComponentManager cmgrAfterConfig = getSingleManager( holder );
        final List<SingleComponentManager> cmgrsAfterConfig = getComponentManagers( holder );
        assertNotNull( "Expect single component manager", cmgrAfterConfig );
        assertNotNull( "Expect component manager list", cmgrsAfterConfig );
        assertEquals( "Expect one component manager in list", 1, cmgrsAfterConfig.size() );
View Full Code Here

        final String name = "test.none";
        final ComponentMetadata cm = createComponentMetadata( name );
        final TestingConfiguredComponentHolder holder = new TestingConfiguredComponentHolder( cm );

        // assert single component and no map
        final SingleComponentManager cmgr = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgr );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).length);

        // assert no configuration of single component
        assertFalse( "Expect no configuration", cmgr.hasConfiguration() );
    }
View Full Code Here

        final String name = "test.singleton";
        final ComponentMetadata cm = createComponentMetadata( name );
        final TestingConfiguredComponentHolder holder = new TestingConfiguredComponentHolder( cm );

        // assert single component and no map
        final SingleComponentManager cmgr = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgr );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).length);

        // assert no configuration of single component
        assertFalse( "Expect no configuration", cmgr.hasConfiguration() );

        // configure with the singleton configuration
        final Dictionary config = new Hashtable();
        config.put( "value", name );
        holder.configurationUpdated( name, config, 0, new TargetedPID(name) );

        // assert single component and no map
        final SingleComponentManager cmgrAfterConfig = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgrAfterConfig );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).length);

        // assert configuration of single component
        assertTrue( "Expect configuration after updating it", cmgrAfterConfig.hasConfiguration() );
        final Dictionary componentConfig = ( ( MockImmediateComponentManager ) cmgrAfterConfig ).getConfiguration();
        assertEquals( "Expect exact configuration set", config, componentConfig );

        // unconfigure singleton
        holder.configurationDeleted( name );

        // assert single component and no map
        final SingleComponentManager cmgrAfterUnconfig = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgrAfterUnconfig );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).length);

        // assert no configuration of single component
        assertFalse( "Expect no configuration", cmgrAfterUnconfig.hasConfiguration() );
    }
View Full Code Here

        final String name = "test.factory";
        final ComponentMetadata cm = createComponentMetadata( name );
        final TestingConfiguredComponentHolder holder = new TestingConfiguredComponentHolder( cm );

        // assert single component and no map
        final SingleComponentManager cmgr = getSingleManager( holder );
        assertNotNull( "Expect single component manager", cmgr );
        assertEquals( "Expect no other component manager list", 1, getComponentManagers( holder ).length);

        // assert no configuration of single component
        assertFalse( "Expect no configuration", cmgr.hasConfiguration() );

        // configure with configuration
        final String pid1 = "test.factory.0001";
        final Dictionary config1 = new Hashtable();
        config1.put( "value", pid1 );
        holder.configurationUpdated( pid1, config1, 0, new TargetedPID(name) );

        // assert single component and single-entry map
        final SingleComponentManager cmgrAfterConfig = getSingleManager( holder );
        final SingleComponentManager[] cmgrsAfterConfig = getComponentManagers( holder );
        assertNotNull( "Expect single component manager", cmgrAfterConfig );
        assertNotNull( "Expect component manager list", cmgrsAfterConfig );
        assertEquals( "Expect one component manager in list", 1, cmgrsAfterConfig.length );

        // add another configuration
        final String pid2 = "test.factory.0002";
        final Dictionary config2 = new Hashtable();
        config1.put( "value", pid2 );
        holder.configurationUpdated( pid2, config2, 1, new TargetedPID(name) );

        // assert single component and single-entry map
        final SingleComponentManager cmgrAfterConfig2 = getSingleManager( holder );
        final SingleComponentManager[] cmgrsAfterConfig2 = getComponentManagers( holder );
        assertNotNull( "Expect single component manager", cmgrAfterConfig2 );
        assertNotNull( "Expect component manager list", cmgrsAfterConfig2 );
        assertEquals( "Expect two component manager in list", 2, cmgrsAfterConfig2.length );

        // remove second configuration
        holder.configurationDeleted( pid2 );

        // assert single component and single-entry map
        final SingleComponentManager cmgrAfterUnConfig2 = getSingleManager( holder );
        final SingleComponentManager[] cmgrsAfterUnConfig2 = getComponentManagers( holder );
        assertNotNull( "Expect single component manager", cmgrAfterUnConfig2 );
        assertNotNull( "Expect component manager list", cmgrsAfterUnConfig2 );
        assertEquals( "Expect one component manager in list", 1, cmgrsAfterUnConfig2.length );

        // add second config again and remove first config -> replace singleton component
        holder.configurationUpdated( pid2, config2, 2, new TargetedPID(name) );
        holder.configurationDeleted( pid1 );

        // assert single component and single-entry map
        final SingleComponentManager cmgrAfterConfigUnconfig = getSingleManager( holder );
        final SingleComponentManager[] cmgrsAfterConfigUnconfig = getComponentManagers( holder );
        assertNotNull( "Expect single component manager", cmgrAfterConfigUnconfig );
        assertNotNull( "Expect component manager list", cmgrsAfterConfigUnconfig );
        assertEquals( "Expect one component manager in list", 1, cmgrsAfterConfigUnconfig.length );

        // remove second configuration (leaving no configurations)
        holder.configurationDeleted( pid2 );

        // assert single component and single-entry map
        final SingleComponentManager cmgrAfterAllUnconfig = getSingleManager( holder );
        final SingleComponentManager[] cmgrsAfterAllUnconfig = getComponentManagers( holder );
        assertNotNull( "Expect single component manager", cmgrAfterAllUnconfig );
        assertEquals( "Expect no component manager list", 1, cmgrsAfterAllUnconfig.length );

    }
View Full Code Here

            public boolean isDS11()
            {
                return true;
            }
        };
        SingleComponentManager icm = new SingleComponentManager( null, null, metadata, new ComponentMethods() );
        ActivateMethod am = new ActivateMethod( methodName, methodName != null, obj.getClass(), true, false );
        am.invoke( obj, new ActivateMethod.ActivatorParameter( m_ctx, -1 ), null, icm );
        Method m = get(am, "m_method");
        assertNotNull( m );
        assertEquals( methodName, m.getName() );
View Full Code Here

            public boolean isDS11()
            {
                return true;
            }
        };
        SingleComponentManager icm = new SingleComponentManager( null, null, metadata, new ComponentMethods() );
        ActivateMethod am = new ActivateMethod( methodName, methodName != null, obj.getClass(), true, false );
        am.invoke( obj, new ActivateMethod.ActivatorParameter( m_ctx, -1 ), null, icm );
        assertNull( get( am, "m_method" ) );
        assertNull( obj.getCalledMethod() );
    }
View Full Code Here

        ComponentMetadata metadata = new ComponentMetadata( 0 ) {
            public boolean isDS11() {
                return isDS11;
            }
        };
        SingleComponentManager icm = new SingleComponentManager( null, null, metadata, new ComponentMethods() );
        BindMethod bm = new BindMethod( methodName, component.getClass(),
                FakeService.class.getName(), isDS11, false );
        RefPair refPair = new RefPair( m_serviceReference );
        assertTrue( bm.getServiceObject( refPair, m_context, icm ) );
        bm.invoke( component, refPair, null, icm );
View Full Code Here

     * @param version DSVersion tested
     */
    private void checkMethod( BaseObject obj, String methodName, String methodDesc, DSVersion version )
    {
        ComponentContainer<?> container = newContainer();
        SingleComponentManager<?> icm = new SingleComponentManager( container, new ComponentMethods() );
        ActivateMethod am = new ActivateMethod( methodName, methodName != null, obj.getClass(), version, false, false );
        am.invoke( obj, new ActivatorParameter( m_ctx, -1 ), null, icm );
        Method m = am.getMethod();
        assertNotNull( m );
        assertEquals( methodName, m.getName() );
View Full Code Here

TOP

Related Classes of org.apache.felix.scr.impl.manager.SingleComponentManager

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.