Package org.apache.felix.cm.integration.helper

Examples of org.apache.felix.cm.integration.helper.ManagedServiceFactoryThread


    {

        final String factoryPid = "single_test_ManagedServiceFactory_race_condition_test." + counter;

        final ConfigureThread ct = new ConfigureThread( getConfigurationAdmin(), factoryPid, true );
        final ManagedServiceFactoryThread mt = new ManagedServiceFactoryThread( bundleContext, factoryPid );

        try
        {
            // start threads -- both are waiting to be triggered
            ct.start();
            mt.start();

            // trigger for action
            ct.trigger();
            mt.trigger();

            // wait for threads to terminate
            ct.join();
            mt.join();

            // wait for all tasks to terminate
            delay();

            final boolean isConfigured = mt.isConfigured();
            final ArrayList<Dictionary> configs = mt.getConfigs();

            // terminate mt to ensure no further config updates
            mt.cleanup();

            TestCase.assertTrue( "Last update call must have been with configuration",  isConfigured);

            if ( configs.size() == 0 )
            {
                TestCase.fail( "No configuration provided to ManagedServiceFactory at all" );
            }
            else if ( configs.size() == 1 )
            {
                final Dictionary props = configs.get( 0 );
                TestCase.assertNotNull( "Expected non-null configuration: " + props, props );
            }
            else
            {
                TestCase.fail( "Unexpectedly got " + configs.size() + " updated" );
            }
        }
        finally
        {
            mt.cleanup();
            ct.cleanup();
        }
    }
View Full Code Here


    {

        final String factoryPid = "single_test_ManagedServiceFactory_race_condition_test." + counter;

        final ConfigureThread ct = new ConfigureThread( getConfigurationAdmin(), factoryPid, true );
        final ManagedServiceFactoryThread mt = new ManagedServiceFactoryThread( bundleContext, factoryPid );

        try
        {
            // start threads -- both are waiting to be triggered
            ct.start();
            mt.start();

            // trigger for action
            ct.trigger();
            mt.trigger();

            // wait for threads to terminate
            ct.join();
            mt.join();

            // wait for all tasks to terminate
            delay();

            final ArrayList<Dictionary> configs = mt.getConfigs();

            // terminate mt to ensure no further config updates
            mt.cleanup();

            if ( configs.size() == 0 )
            {
                TestCase.fail( "No configuration provided to ManagedServiceFactory at all" );
            }
            else if ( configs.size() == 1 )
            {
                final Dictionary props = configs.get( 0 );
                TestCase.assertNotNull( "Expected non-null configuration: " + props, props );
            }
            else
            {
                TestCase.fail( "Unexpectedly got " + configs.size() + " updated" );
            }
        }
        finally
        {
            mt.cleanup();
            ct.cleanup();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.cm.integration.helper.ManagedServiceFactoryThread

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.