Package org.rhq.core.domain.configuration

Examples of org.rhq.core.domain.configuration.Configuration$Builder$ListInList


        executeInTransaction(false, new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                Resource serverResource = getEntityManager().find(Resource.class, serverResourceId);
                CreateResourceHistory createResourceHistory = new CreateResourceHistory(serverResource, serviceType1,
                    subjectManager.getOverlord().getName(), new Configuration());
                createResourceHistory.setCreatedResourceName(userSuppliedResourceName);
                createResourceHistory.setNewResourceKey(newResourceKey);
                createResourceHistory.setStatus(SUCCESS);
                getEntityManager().persist(createResourceHistory);
                serverResource.addCreateChildResourceHistory(createResourceHistory);
View Full Code Here


    public void testPluginConfigurationUpdateCallbackFailure() throws Exception {
        Resource resource = newResource1;

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        Configuration configuration1 = new Configuration();
        configuration1.put(new PropertySimple("foo", "1"));
        configuration1.put(new PropertySimple("fail", "true"));

        Configuration current;

        current = configurationManager.getPluginConfiguration(overlord, resource.getId());
        assert current != null;
        assert current.getProperties().size() == 0 : current; // there is no plugin config settings yet

        PluginConfigurationUpdate update = configurationManager.updatePluginConfiguration(overlord, resource.getId(),
            configuration1);
        assert update.getErrorMessage() != null : "We should have simulated a failure, "
            + "but instead received no error.";

        // Even if a plugin container exception occurs, the plugin configuration should still be updated.
        current = configurationManager.getPluginConfiguration(overlord, resource.getId());
        assert current != null;
        assert current.getProperties().size() != 0 : current.toString();
    }
View Full Code Here

        //testGroupPluginConfigurationUpdateWorkflowHelper(true);
    }

    @Test(enabled = false)
    public void testGroupPluginConfigurationUpdateMergeAlgorithmPerformance() throws Exception {
        Configuration configuration = new Configuration();
        configuration.put(new PropertySimple("foo1", "1"));
        configuration.put(new PropertySimple("foo2", "2"));
        configuration.put(new PropertySimple("foo3", "3"));
        configuration.put(new PropertySimple("foo4", "4"));
        configuration.put(new PropertySimple("foo5", "5"));

        /*
         * for a configuration object that has 5 simple properties, baseline for groupSize of 100K was 165ms (Dec 6,
         * 2007);
         *
 
View Full Code Here

        Resource resource2 = newResource2;

        try {
            Subject overlord = LookupUtil.getSubjectManager().getOverlord();

            Configuration configuration1 = new Configuration();
            configuration1.put(new PropertySimple("foo", "1"));
            configuration1.put(new PropertySimple("fail", "false"));

            Configuration configuration2 = new Configuration();
            configuration2.put(new PropertySimple("foo", "2"));
            configuration2.put(new PropertySimple("fail", "false"));

            /* begin simple checks */
            PluginConfigurationUpdate update1 = configurationManager.updatePluginConfiguration(overlord,
                resource1.getId(), configuration1);
            assert update1.getErrorMessage() == null : "We weren't expecting a failure here";

            PluginConfigurationUpdate update2 = configurationManager.updatePluginConfiguration(overlord,
                resource2.getId(), configuration2);
            assert update2.getErrorMessage() == null : "We weren't expecting a failure here";

            Configuration updatedConfiguration1 = configurationManager.getPluginConfiguration(overlord,
                resource1.getId());
            Configuration updatedConfiguration2 = configurationManager.getPluginConfiguration(overlord,
                resource2.getId());

            assert updatedConfiguration1.equals(configuration1) : "configuration1 was: " + updatedConfiguration1 + ", "
                + "expected was: " + configuration1;

            assert updatedConfiguration2.equals(configuration2) : "configuration2 was: " + updatedConfiguration2 + ", "
                + "expected was: " + configuration2;
            /*  end simple checks */

            /* begin group configuration creation checks */
            Configuration expectedGroupConfiguration = new Configuration();
            expectedGroupConfiguration
                .put(new PropertySimple("foo", GroupPluginConfigurationUpdate.MIXED_VALUES_MARKER));
            expectedGroupConfiguration.put(new PropertySimple("fail", "false"));

            List<Configuration> updatedConfigurations = Arrays.asList(new Configuration[] { updatedConfiguration1,
                updatedConfiguration2 });

            Configuration groupConfiguration = null;
            /*
            Configuration groupConfiguration = GroupPluginConfigurationUpdate
                .getGroupConfiguration(updatedConfigurations);
             */

            assert groupConfiguration.equals(expectedGroupConfiguration) : "group configuration was: "
                + groupConfiguration + ", " + "expected was: " + expectedGroupConfiguration;
            /*  end group configuration creation checks */

            /* begin group modification */
            Configuration groupConfigurationOverride = new Configuration();
            PropertySimple propertySimple1 = new PropertySimple("foo", "3");
            PropertySimple propertySimple2 = new PropertySimple("fail", "true");
            groupConfigurationOverride.put(propertySimple1);
            groupConfigurationOverride.put(propertySimple2);

            // regardless of failures, semantics dictate that the new configuration should be persisted to the resource
            Configuration expectedGroupConfigurationResults = new Configuration();
            expectedGroupConfigurationResults.put(new PropertySimple("foo", "3")); // from groupConfigurationOverride
            propertySimple1.setOverride(Boolean.TRUE);

            if (failOnChildUpdates) {
                expectedGroupConfigurationResults.put(new PropertySimple("fail", "true")); // from groupConfigurationOverride
                propertySimple2.setOverride(Boolean.TRUE); // will make TestServices fail
            } else {
                expectedGroupConfigurationResults.put(new PropertySimple("fail", "false")); // from both resource's current configuration
                propertySimple2.setOverride(Boolean.FALSE); // false is default, but setting explicitly for test clarity
            }

            Map<Integer, Configuration> memberConfigs = new HashMap<Integer, Configuration>();
            memberConfigs.put(resource1.getId(), configuration1);
            memberConfigs.put(resource2.getId(), configuration2);
            int groupUpdateId = configurationManager.scheduleGroupPluginConfigurationUpdate(overlord,
                compatibleGroup.getId(), memberConfigs);

            // instead of sleeping, let's directly execute what would normally be scheduled
            //configurationManager.completeGroupPluginConfigurationUpdate(groupUpdateId);

            GroupPluginConfigurationUpdate update = configurationManager.getGroupPluginConfigurationById(groupUpdateId);

            assert update != null : "Group plugin configuration update should not have been null";

            int i = 0;
            for (PluginConfigurationUpdate childUpdate : update.getConfigurationUpdates()) {
                Configuration childUpdateConfiguration = childUpdate.getConfiguration();
                assert childUpdateConfiguration.equals(expectedGroupConfigurationResults) : "new updateChildConfig["
                    + i + "] was: " + childUpdateConfiguration + ", " + "expected was: "
                    + expectedGroupConfigurationResults;
                i++;
            }

            Configuration configurationAfterGroupUpdate1 = configurationManager.getPluginConfiguration(overlord,
                resource1.getId());
            Configuration configurationAfterGroupUpdate2 = configurationManager.getPluginConfiguration(overlord,
                resource2.getId());

            ConfigurationUpdateStatus expectedResultStatus = null;

            if (failOnChildUpdates) {
                expectedResultStatus = ConfigurationUpdateStatus.FAILURE;
            } else {
                expectedResultStatus = ConfigurationUpdateStatus.SUCCESS;
            }

            assert configurationAfterGroupUpdate1.equals(expectedGroupConfigurationResults) : "new config1 was: "
                + configurationAfterGroupUpdate1 + ", " + "expected was: " + expectedGroupConfigurationResults;

            assert configurationAfterGroupUpdate2.equals(expectedGroupConfigurationResults) : "new config2 was: "
                + configurationAfterGroupUpdate2 + ", " + "expected was: " + expectedGroupConfigurationResults;

            assert update.getStatus() == expectedResultStatus : "Group plugin configuration update "
                + "should have been marked as " + expectedResultStatus + ": " + update;

View Full Code Here

            loaded = contentSourceManager.getContentSource(overlord, contentSourceId);
            assert loaded.getDescription().equals("new updated description");

            // now give it a config
            assert loaded.getConfiguration() == null : "should not have a config yet";
            Configuration config = new Configuration();
            config.put(new PropertySimple("updateCSName", "updateCSValue"));
            loaded.setConfiguration(config);
            loaded = contentSourceManager.updateContentSource(overlord, loaded, false);
            assert loaded != null : "should have been updated";
            config = loaded.getConfiguration();
            assert config != null : "should have a config now";
            assert config.getSimple("updateCSName").getStringValue().equals("updateCSValue") : config;
            assert loaded.getDescription().equals("new updated description") : "desc should still be there";

            // delete the content source
            contentSourceManager.deleteContentSource(overlord, contentSourceId);
            assert null == contentSourceManager.getContentSource(overlord, contentSourceId) : "should have been deleted";
View Full Code Here

        try {
            Subject overlord = LookupUtil.getSubjectManager().getOverlord();

            // this is simulating what the UI would be doing, build the config and call the server-side API
            // we'll pretend the user is the overlord - another test will check a real user to see permission errors
            Configuration configuration = new Configuration();
            configuration.put(new PropertySimple("myboolean", "invalid-bool"));

            ResourceConfigurationUpdate history = new ResourceConfigurationUpdate(resource, configuration, "dummyuser");

            assert history.getStatus().equals(ConfigurationUpdateStatus.INPROGRESS);
View Full Code Here

            type = contentSourceManager.getContentSourceType(type.getName());
            assert type != null;
            assert type.getId() > 0;

            // create the content source - note it has a config that should be persisted
            Configuration config = new Configuration();
            config.put(new PropertySimple("updateCSName", "updateCSValue"));
            contentSource = new ContentSource("testUpdateContentSource2", type);
            contentSource.setConfiguration(config);
            contentSource = contentSourceManager.simpleCreateContentSource(overlord, contentSource);
            assert contentSource != null;
            int contentSourceId = contentSource.getId();
View Full Code Here

        Resource resource = newResource1;
        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        // this is simulating what the UI would be doing, build the config and call the server-side API
        // we'll pretend the user is the overlord - another test will check a real user to see permission errors
        Configuration configuration = new Configuration();
        configuration.put(new PropertySimple("myboolean", "true"));

        ResourceConfigurationUpdate request = new ResourceConfigurationUpdate(resource, configuration, "dummyuser");

        assert request.getStatus().equals(ConfigurationUpdateStatus.INPROGRESS);

        configurationManager.updateResourceConfiguration(overlord, resource.getId(), configuration);

        Thread.sleep(2000); // wait for the test agent to complete the request

        // at this point in time, the round trip messaging is done and we have the agent response
        ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
        criteria.addFilterResourceIds(resource.getId());
        criteria.fetchConfiguration(true);
        criteria.addSortCreatedTime(PageOrdering.ASC);

        List<ResourceConfigurationUpdate> requests;

        requests = configurationManager.findResourceConfigurationUpdatesByCriteria(overlord, criteria);

        assert requests.size() == 1;
        assert requests.get(0) != null;

        request = requests.get(0);

        assert request.getStatus().equals(ConfigurationUpdateStatus.SUCCESS);
        assert request.getErrorMessage() == null;
        assert request.getConfiguration() != null;
        PropertySimple mybool = request.getConfiguration().getSimple("myboolean");
        assert mybool != null;
        assert mybool.getStringValue().equals("true");
        assert mybool.getErrorMessage() == null;

        ResourceConfigurationUpdate current;
        current = configurationManager.getLatestResourceConfigurationUpdate(overlord, resource.getId());

        assert current != null;
        assert current.getId() == request.getId();
        assert current.getResource().equals(resource);
        assert current.getStatus().equals(request.getStatus());
        assert current.getSubjectName().equals(request.getSubjectName());
        assert current.getCreatedTime() == request.getCreatedTime();
        assert current.getModifiedTime() == request.getModifiedTime();
        assert current.getConfiguration().getId() == request.getConfiguration().getId();

        Configuration live = configurationManager.getLiveResourceConfiguration(overlord, resource.getId(), false);
        assert live != null;
        mybool = live.getSimple("myboolean");
        assert mybool != null;
        assert "true".equals(mybool.getStringValue());
        assert mybool.getErrorMessage() == null;

        // purging a non-existing request is a no-op
View Full Code Here

            PackageSyncReport report = new PackageSyncReport();
            ContentProviderPackageDetailsKey key = new ContentProviderPackageDetailsKey("testMergeWithRepofoo",
                "testMergeWithRepo-Version", packageType1.getName(), architecture1.getName(), resourceType1.getName(),
                resourceType1.getPlugin());
            ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
            details.setExtraProperties(new Configuration());
            details.getExtraProperties().put(new PropertySimple("hello", "world"));
            details.setLocation("dummy-location");
            details.setFileSize(0L); // under the covers this ends up allowing us to create a package bits of size 0
            report.addNewPackage(details);
            Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous;
View Full Code Here

        Resource resource = newResource1;

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        // create a few configs in history
        Configuration configuration1 = new Configuration();
        configuration1.put(new PropertySimple("myboolean", "true"));
        configurationManager.updateResourceConfiguration(overlord, resource.getId(), configuration1);
        Thread.sleep(3000); // wait for the test agent to complete the request

        Configuration configuration2 = new Configuration();
        configuration2.put(new PropertySimple("myboolean", "false"));
        configurationManager.updateResourceConfiguration(overlord, resource.getId(), configuration2);
        Thread.sleep(3000); // wait for the test agent to complete the request

        Configuration configuration3 = new Configuration();
        configuration3.put(new PropertySimple("myboolean", "TRUE"));
        configurationManager.updateResourceConfiguration(overlord, resource.getId(), configuration3);
        Thread.sleep(3000); // wait for the test agent to complete the request

        ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
        criteria.addFilterResourceIds(resource.getId());
        criteria.fetchConfiguration(true);
        criteria.addSortCreatedTime(PageOrdering.ASC);
        List<ResourceConfigurationUpdate> history = configurationManager.findResourceConfigurationUpdatesByCriteria(
            overlord, criteria);
        assert history != null;
        assert history.size() == 3;

        Configuration currentConfiguration = history.get(2).getConfiguration();
        PropertySimple mybool = currentConfiguration.getSimple("myboolean");
        assert mybool != null;
        assertEquals("TRUE", mybool.getStringValue());

        // now grab one of the earlier configurations and rollback to it
        Configuration rollbackToHere = history.get(1).getConfiguration(); // the "false" one
        mybool = rollbackToHere.getSimple("myboolean");
        assert mybool != null;
        assertEquals("false", mybool.getStringValue());

        configurationManager.updateResourceConfiguration(overlord, resource.getId(), rollbackToHere);
        Thread.sleep(3000); // wait for the test agent to complete the request

        criteria = new ResourceConfigurationUpdateCriteria();
        criteria.addFilterResourceIds(resource.getId());
        criteria.fetchConfiguration(true);
        criteria.addSortCreatedTime(PageOrdering.ASC);

        history = configurationManager.findResourceConfigurationUpdatesByCriteria(overlord, criteria);
        assert history != null;
        assert history.size() == 4;
        ResourceConfigurationUpdate newConfigUpdate = history.get(3); // the last one is the new one
        Configuration newConfiguration = newConfigUpdate.getConfiguration();
        assert newConfiguration.getId() != rollbackToHere.getId();
        mybool = newConfiguration.getSimple("myboolean");
        assert mybool != null;
        assertEquals("false", mybool.getStringValue());
        assert mybool.getErrorMessage() == null;

        ResourceConfigurationUpdate current = configurationManager.getLatestResourceConfigurationUpdate(overlord,
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.configuration.Configuration$Builder$ListInList

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.