Package com.volantis.osgi.cm.util

Examples of com.volantis.osgi.cm.util.CaseInsensitiveDictionary


            ConfigurationStore store, String pid,
            String bundleLocation)
            throws IOException {

        // Store an object.
        CaseInsensitiveDictionary properties = new CaseInsensitiveDictionary();
        properties.put("a", "1");
        InternalConfiguration configuration = store.createConfiguration(
                pid, bundleLocation);
        configuration.replaceProperties(properties);

        store.update(configuration);
View Full Code Here


        // Check to see if the information has been correctly persisted.
        checkPersistedConfigurations(
                new InternalConfiguration[]{
                        new ConfigurationImpl(PREFIX + "a", FACTORY_PID1, null,
                                null, new CaseInsensitiveDictionary()),
                        new ConfigurationImpl(PREFIX + "b", FACTORY_PID1, null,
                                null, new CaseInsensitiveDictionary()),
                        new ConfigurationImpl(PREFIX + "c", FACTORY_PID1, null,
                                UNAUTHORIZED_BUNDLE_LOCATION,
                                new CaseInsensitiveDictionary()),
                });

        // Delete a factory configuration.
        fc1_2.delete();

        // The ManagedServiceFactory service has changed.
        factoryHandler.serviceModified(unauthorizedFactoryReferenceMock);

        // The ManagedServiceFactory service has unregistered.
        factoryHandler.serviceUnregistering(unauthorizedFactoryReferenceMock);

        // Make sure that the configurations that were created without any
        // specific bundle location and have not since been deleted have
        // reverted to null.
        checkLocationBinding(PREFIX + "a", null);

        // Reregister another ManagedServiceFactory with the same PID but from
        // a different bundle.
        factoryHandler.serviceRegistered(attackingFactoryReferenceMock);

        // Check to see if the information has been correctly persisted.
        checkPersistedConfigurations(
                new InternalConfiguration[]{
                        new ConfigurationImpl(PREFIX + "a", FACTORY_PID1, null,
                                null, new CaseInsensitiveDictionary()),
                        new ConfigurationImpl(PREFIX + "c", FACTORY_PID1, null,
                                UNAUTHORIZED_BUNDLE_LOCATION,
                                new CaseInsensitiveDictionary()),
                });

        asynchronousDispatcher.stop();
    }
View Full Code Here

        // Check to see if the information has been correctly persisted.
        checkPersistedConfigurations(
                new InternalConfiguration[]{
                        new ConfigurationImpl(SERVICE_PID1, null, null,
                                UNAUTHORIZED_BUNDLE_LOCATION,
                                new CaseInsensitiveDictionary()),
                });

        // Delete the configuration.
        c1.delete();

        // Create a free configuration.
        c1 = authorizedAdmin.getConfiguration(SERVICE_PID1, null);
        c1.update(new Hashtable());
        checkLocationBinding(SERVICE_PID1, UNAUTHORIZED_BUNDLE_LOCATION);

        // The ManagedService service has changed.
        serviceHandler.serviceModified(unauthorizedServiceReferenceMock);

        // The ManagedService service has unregistered.
        serviceHandler.serviceUnregistering(unauthorizedServiceReferenceMock);

        // Make sure that the configurations that were created without any
        // specific bundle location and have not since been deleted have
        // reverted to null.
        checkLocationBinding(SERVICE_PID1, null);

        // Reregister another ManagedServiceFactory with the same PID but from
        // a different bundle.
        serviceHandler.serviceRegistered(attackingServiceReferenceMock);

        // Check to see if the information has been correctly persisted.
        checkPersistedConfigurations(
                new InternalConfiguration[]{
                        new ConfigurationImpl(SERVICE_PID1, null, null,
                                null, new CaseInsensitiveDictionary()),
                });

        asynchronousDispatcher.stop();
    }
View Full Code Here

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        Dictionary dictionary = new CaseInsensitiveDictionary();
        dictionary.put("a", "b");

        InternalConfiguration internalConfiguration =
                new ConfigurationImpl("pid", null, null,
                        AUTHORIZED_BUNDLE_LOCATION, null);

        storeMock.expects.createConfiguration(
                "pid", AUTHORIZED_BUNDLE_LOCATION)
                .returns(internalConfiguration);

        storeMock.expects.update(internalConfiguration);

        dispatcherMock.expects
                .managedServiceConfigurationUpdated(EMPTY_REFERENCES,
                        new ConfigurationSnapshot("pid", dictionary));

        storeMock.expects.remove(internalConfiguration);

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        Configuration configuration = authorizedAdmin.getConfiguration("pid");

        // Make sure that the configuration can be retrieved before deletion.
        configuration.update(dictionary);

        Configuration[] configurations;
        configurations = authorizedAdmin.listConfigurations(null);
        assertCorrectConfigurations(new Configuration[]{
                configuration
        }, configurations);

        // Delete the configuration.
        configuration.delete();

        // Make sure that the configuration cannot be retrieved after
        // deletion.
        configurations = authorizedAdmin.listConfigurations(null);
        assertCorrectConfigurations(null, configurations);

        try {
            configuration.delete();
            fail("Failed to check delete state");
        } catch (IllegalStateException expected) {
            assertEquals("Configuration 'pid' has been deleted",
                    expected.getMessage());
        }

        try {
            configuration.getBundleLocation();
            fail("Failed to check delete state");
        } catch (IllegalStateException expected) {
            assertEquals("Configuration 'pid' has been deleted",
                    expected.getMessage());
        }

        try {
            configuration.getFactoryPid();
            fail("Failed to check delete state");
        } catch (IllegalStateException expected) {
            assertEquals("Configuration 'pid' has been deleted",
                    expected.getMessage());
        }

        try {
            configuration.getPid();
            fail("Failed to check delete state");
        } catch (IllegalStateException expected) {
            assertEquals("Configuration 'pid' has been deleted",
                    expected.getMessage());
        }

        try {
            configuration.getProperties();
            fail("Failed to check delete state");
        } catch (IllegalStateException expected) {
            assertEquals("Configuration 'pid' has been deleted",
                    expected.getMessage());
        }

        try {
            configuration.setBundleLocation("blah");
            fail("Failed to check delete state");
        } catch (IllegalStateException expected) {
            assertEquals("Configuration 'pid' has been deleted",
                    expected.getMessage());
        }

        try {
            configuration.update();
            fail("Failed to check delete state");
        } catch (IllegalStateException expected) {
            assertEquals("Configuration 'pid' has been deleted",
                    expected.getMessage());
        }

        try {
            configuration.update(new CaseInsensitiveDictionary());
            fail("Failed to check delete state");
        } catch (IllegalStateException expected) {
            assertEquals("Configuration 'pid' has been deleted",
                    expected.getMessage());
        }
View Full Code Here

        configurations = authorizedAdmin.listConfigurations(null);
        assertCorrectConfigurations(null, configurations);

        // Update the configurations so that they can be seen.
        Dictionary properties = new CaseInsensitiveDictionary();

        storeMock.expects.update(authorizedInternalConfiguration);

        dispatcherMock.expects
                .managedServiceConfigurationUpdated(EMPTY_REFERENCES,
                        new ConfigurationSnapshot("PID1", properties));

        properties.put("a", "b");
        authorizedConfiguration.update(properties);

        storeMock.expects.update(attackingInternalConfiguration);

        dispatcherMock.expects
                .managedServiceConfigurationUpdated(EMPTY_REFERENCES,
                        new ConfigurationSnapshot("PID2", properties));

        properties.put("a", "d");
        attackingConfiguration.update(properties);

        storeMock.expects.update(unassignedInternalConfiguration);

        dispatcherMock.expects
                .managedServiceConfigurationUpdated(EMPTY_REFERENCES,
                        new ConfigurationSnapshot("PID3", properties));

        properties.put("a", "e");
        unassignedConfiguration.update(properties);

        // The authorized admin can list all the configurations for all the
        // bundles.
        configurations = authorizedAdmin.listConfigurations(null);
View Full Code Here

        String bundleLocation = (String) properties.remove(BUNDLE_LOCATION);
        String pid = (String) properties.remove(FrameworkConstants.SERVICE_PID);
        String factoryPid = (String) properties
                .remove(FrameworkConstants.SERVICE_FACTORYPID);

        CaseInsensitiveDictionary dictionary =
                new CaseInsensitiveDictionary(properties);

        return new ConfigurationImpl(pid, factoryPid, file, bundleLocation,
                dictionary);
    }
View Full Code Here

                    String pid = (String) dictionary.get(
                            FrameworkConstants.SERVICE_PID);

                    try {
                        factory.updated(pid,
                                new CaseInsensitiveDictionary(dictionary));
                    } catch (ConfigurationException e) {
                        log.log(reference, LogService.LOG_ERROR,
                                "updated(" + pid + ", " + dictionary +
                                        ") method failed:",
                                e);
View Full Code Here

                    // Must have deregistered so nothing to do.
                    return;
                }

                try {
                    CaseInsensitiveDictionary temp;
                    if (dictionary == null) {
                        temp = null;
                    } else {
                        temp = new CaseInsensitiveDictionary(dictionary);
                    }
                    service.updated(temp);
                } catch (ConfigurationException e) {
                    log.log(reference, LogService.LOG_ERROR,
                            "updated(" + dictionary + ") method failed:",
View Full Code Here

        ensureNotDeleted();

        if (properties == null) {
            return null;
        } else {
            CaseInsensitiveDictionary dictionary =
                    new CaseInsensitiveDictionary(properties);

            // Ensure the required properties are set correctly.
            dictionary.put(FrameworkConstants.SERVICE_PID, pid);
            if (factoryPid == null) {
                dictionary.remove(FrameworkConstants.SERVICE_FACTORYPID);
            } else {
                dictionary
                        .put(FrameworkConstants.SERVICE_FACTORYPID, factoryPid);
            }

            return dictionary;
        }
View Full Code Here

    public void replaceProperties(Dictionary newProperties) {

        ensureNotDeleted();

        if (properties == null) {
            properties = new CaseInsensitiveDictionary();
        } else {
            properties.clear();
        }

        ValidationHelper.copyAndCheckProperties(newProperties, properties);
View Full Code Here

TOP

Related Classes of com.volantis.osgi.cm.util.CaseInsensitiveDictionary

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.