Package org.osgi.service.cm

Examples of org.osgi.service.cm.Configuration


    @Test
    public void test_configuration_delete_after_config_admin_stop() throws BundleException
    {
        final String pid = "test_configuration_after_config_admin_stop";
        final Configuration config = configure( pid, null, true );

        final Bundle cfgAdminBundle = configAdminTracker.getServiceReference().getBundle();
        cfgAdminBundle.stop();
        try
        {
            config.delete();
            TestCase.fail( "Expected IllegalStateException for config.delete" );
        }
        catch ( IllegalStateException ise )
        {
            // expected
View Full Code Here


    @Test
    public void test_configuration_getBundleLocation_after_config_admin_stop() throws BundleException
    {
        final String pid = "test_configuration_after_config_admin_stop";
        final Configuration config = configure( pid, null, true );

        final Bundle cfgAdminBundle = configAdminTracker.getServiceReference().getBundle();
        cfgAdminBundle.stop();
        try
        {
            config.getBundleLocation();
            TestCase.fail( "Expected IllegalStateException for config.getBundleLocation" );
        }
        catch ( IllegalStateException ise )
        {
            // expected
View Full Code Here

    @Test
    public void test_configuration_setBundleLocation_after_config_admin_stop() throws BundleException
    {
        final String pid = "test_configuration_after_config_admin_stop";
        final Configuration config = configure( pid, null, true );

        final Bundle cfgAdminBundle = configAdminTracker.getServiceReference().getBundle();
        cfgAdminBundle.stop();
        try
        {
            config.setBundleLocation( "?*" );
            TestCase.fail( "Expected IllegalStateException for config.setBundleLocation" );
        }
        catch ( IllegalStateException ise )
        {
            // expected
View Full Code Here

    @Test
    public void test_configuration_update_after_config_admin_stop() throws BundleException
    {
        final String pid = "test_configuration_after_config_admin_stop";
        final Configuration config = configure( pid, null, true );

        final Bundle cfgAdminBundle = configAdminTracker.getServiceReference().getBundle();
        cfgAdminBundle.stop();
        try
        {
            config.update();
            TestCase.fail( "Expected IllegalStateException for config.update" );
        }
        catch ( IllegalStateException ise )
        {
            // expected
View Full Code Here

    public ConfigureThread( final ConfigurationAdmin configAdmin, final String pid, final boolean isFactory )
        throws IOException
    {
        // ensure configuration and disown it
        final Configuration config;
        if ( isFactory )
        {
            config = configAdmin.createFactoryConfiguration( pid );
        }
        else
        {
            config = configAdmin.getConfiguration( pid );
        }
        config.setBundleLocation( null );

        Hashtable<String, Object> props = new Hashtable<String, Object>();
        props.put( "prop1", "aValue" );
        props.put( "prop2", 4711 );
View Full Code Here

    @SuppressWarnings("serial")
    @Test
    public void test_configuration_update_with_Dictionary_after_config_admin_stop() throws BundleException
    {
        final String pid = "test_configuration_after_config_admin_stop";
        final Configuration config = configure( pid, null, true );

        final Bundle cfgAdminBundle = configAdminTracker.getServiceReference().getBundle();
        cfgAdminBundle.stop();
        try
        {
            config.update( new Hashtable<String, Object>()
            {
                {
                    put( "sample", "sample" );
                }
            } );
View Full Code Here

    public void test_configuration_change_counter() throws IOException
    {
        // 1. create config with pid and locationA
        // 2. update config with properties
        final String pid = "test_configuration_change_counter";
        final Configuration config = configure( pid, null, false );

        TestCase.assertEquals("Expect first version to be 1", 1, config.getChangeCount());

        config.update(new Hashtable(){{put("x", "x");}});
        TestCase.assertEquals("Expect second version to be 2", 2, config.getChangeCount());

        // delete
        config.delete();
    }
View Full Code Here

    public void test_basic_configuration_configure_then_start() throws BundleException, IOException
    {
        // 1. create config with pid and locationA
        // 2. update config with properties
        final String pid = "test_basic_configuration_configure_then_start";
        final Configuration config = configure( pid, null, true );

        // 3. register ManagedService ms1 with pid from said locationA
        bundle = installBundle( pid, ManagedServiceTestActivator.class );
        bundle.start();
        delay();

        // ==> configuration supplied to the service ms1
        final ManagedServiceTestActivator tester = ManagedServiceTestActivator.INSTANCE;
        TestCase.assertNotNull( tester.props );
        TestCase.assertEquals( pid, tester.props.get( Constants.SERVICE_PID ) );
        TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_FACTORYPID ) );
        TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_BUNDLELOCATION ) );
        TestCase.assertEquals( PROP_NAME, tester.props.get( PROP_NAME ) );
        TestCase.assertEquals( 1, tester.numManagedServiceUpdatedCalls );

        // delete
        config.delete();
        delay();

        // ==> update with null
        TestCase.assertNull( tester.props );
        TestCase.assertEquals( 2, tester.numManagedServiceUpdatedCalls );
View Full Code Here

    {
        // 1. create config with pid and locationA
        // 2. update config with properties
        final String pid = "pid with blanks and stuff %\"'";
        theConfig.put( pid, pid );
        final Configuration config = configure( pid, null, true );
        theConfig.remove( pid );

        // 3. register ManagedService ms1 with pid from said locationA
        bundle = installBundle( pid, ManagedServiceTestActivator.class );
        bundle.start();
        delay();

        // ==> configuration supplied to the service ms1
        final ManagedServiceTestActivator tester = ManagedServiceTestActivator.INSTANCE;
        TestCase.assertNotNull( tester.props );
        TestCase.assertEquals( pid, tester.props.get( Constants.SERVICE_PID ) );
        TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_FACTORYPID ) );
        TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_BUNDLELOCATION ) );
        TestCase.assertEquals( PROP_NAME, tester.props.get( PROP_NAME ) );
        TestCase.assertEquals( pid, tester.props.get( pid ) );
        TestCase.assertEquals( 1, tester.numManagedServiceUpdatedCalls );

        // delete
        config.delete();
        delay();

        // ==> update with null
        TestCase.assertNull( tester.props );
        TestCase.assertEquals( 2, tester.numManagedServiceUpdatedCalls );
View Full Code Here

        bundle.start();
        delay();

        // 1. create config with pid and locationA
        // 2. update config with properties
        final Configuration config = configure( pid, null, true );
        delay();

        // ==> configuration supplied to the service ms1
        final ManagedServiceTestActivator tester = ManagedServiceTestActivator.INSTANCE;
        TestCase.assertNotNull( tester.props );
        TestCase.assertEquals( pid, tester.props.get( Constants.SERVICE_PID ) );
        TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_FACTORYPID ) );
        TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_BUNDLELOCATION ) );
        TestCase.assertEquals( PROP_NAME, tester.props.get( PROP_NAME ) );
        TestCase.assertEquals( 2, tester.numManagedServiceUpdatedCalls );

        // delete
        config.delete();
        delay();

        // ==> update with null
        TestCase.assertNull( tester.props );
        TestCase.assertEquals( 3, tester.numManagedServiceUpdatedCalls );
View Full Code Here

TOP

Related Classes of org.osgi.service.cm.Configuration

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.