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

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


    {

        final String pid = "single_test_ManagedService_race_condition_test." + counter;

        final ConfigureThread ct = new ConfigureThread( getConfigurationAdmin(), pid, false );
        final ManagedServiceThread mt = new ManagedServiceThread( bundleContext, pid );

        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 ManagedService at all" );
            }
            else if ( configs.size() == 2 )
            {
                final Dictionary props0 = configs.get( 0 );
                final Dictionary props1 = configs.get( 1 );

                TestCase.assertNull( "Expected first (of two) updates without configuration", props0 );
                TestCase.assertNotNull( "Expected second (of two) updates with configuration", props1 );
            }
            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 pid = "single_test_ManagedService_race_condition_test." + counter;

        final ConfigureThread ct = new ConfigureThread( getConfigurationAdmin(), pid, false );
        final ManagedServiceThread mt = new ManagedServiceThread( bundleContext, pid );

        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 ManagedService at all" );
            }
            else if ( configs.size() == 2 )
            {
                final Dictionary props0 = configs.get( 0 );
                final Dictionary props1 = configs.get( 1 );

                TestCase.assertNull( "Expected first (of two) updates without configuration", props0 );
                TestCase.assertNotNull( "Expected second (of two) updates with configuration", props1 );
            }
            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.ManagedServiceThread

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.