Package org.rhq.core.domain.drift

Examples of org.rhq.core.domain.drift.DriftDefinitionTemplate


        definition.setInterval(2400L);
        definition.setBasedir(new DriftDefinition.BaseDirectory(fileSystem, "/foo/bar/test"));

        templateMgr.createTemplate(getOverlord(), resourceType.getId(), true, definition);

        DriftDefinitionTemplate template = loadTemplate(definition.getName());
        assertNotNull("Failed to load template", template);
        //em.clear();
        //System.out.println("Created " + template.toString(false));
    }
View Full Code Here


        //System.out.println("Created " + template.toString(false));
    }

    //@Test(groups = "negativeUpdate", dependsOnMethods = "createTemplateForNegativeUpdateTests", expectedExceptions = EJBException.class, expectedExceptionsMessageRegExp = ".*base directory.*cannot be modified")
    private void doNotAllowBaseDirToBeUpdated() {
        DriftDefinitionTemplate template = loadTemplate(TEST_CREATE_TEMPLATE);
        DriftDefinition definition = template.getTemplateDefinition();
        definition.setBasedir(new DriftDefinition.BaseDirectory(fileSystem, "/foo/bar/TEST"));

        templateMgr.updateTemplate(getOverlord(), template);
    }
View Full Code Here

        templateMgr.updateTemplate(getOverlord(), template);
    }

    //@Test(groups = "negativeUpdate", dependsOnMethods = "createTemplateForNegativeUpdateTests", expectedExceptions = EJBException.class, expectedExceptionsMessageRegExp = ".*filters.*cannot be modified")
    private void doNotAllowFiltersToBeUpdated() {
        DriftDefinitionTemplate template = loadTemplate(TEST_CREATE_TEMPLATE);
        DriftDefinition definition = template.getTemplateDefinition();
        definition.addExclude(new Filter("/foo/bar/TEST/conf", "*.xml"));

        templateMgr.updateTemplate(getOverlord(), template);
    }
View Full Code Here

        templateMgr.updateTemplate(getOverlord(), template);
    }

    //@Test(groups = "negativeUpdate", dependsOnMethods = "createTemplateForNegativeUpdateTests", expectedExceptions = EJBException.class, expectedExceptionsMessageRegExp = ".*name.*cannot be modified")
    private void doNotAllowTemplateNameToBeUpdated() {
        DriftDefinitionTemplate template = loadTemplate(TEST_CREATE_TEMPLATE);
        template.setName(NAME_PREFIX + "A new name");

        templateMgr.updateTemplate(getOverlord(), template);
    }
View Full Code Here

        definition.setEnabled(true);
        definition.setDriftHandlingMode(normal);
        definition.setInterval(2400L);
        definition.setBasedir(new DriftDefinition.BaseDirectory(fileSystem, "/foo/bar/test"));

        DriftDefinitionTemplate template = templateMgr.createTemplate(getOverlord(), resourceType.getId(), true,
            definition);

        // next create some definitions from the template
        final DriftDefinition attachedDef1 = createDefinition(template, NAME_PREFIX + "attachedDef1", true);
        final DriftDefinition attachedDef2 = createDefinition(template, NAME_PREFIX + "attachedDef2", true);
        final DriftDefinition detachedDef1 = createDefinition(template, NAME_PREFIX + "detachedDef1", false);
        final DriftDefinition detachedDef2 = createDefinition(template, NAME_PREFIX + "detachedDef2", false);

        driftMgr.updateDriftDefinition(getOverlord(), forResource(resource.getId()), attachedDef1);
        driftMgr.updateDriftDefinition(getOverlord(), forResource(resource.getId()), attachedDef2);
        driftMgr.updateDriftDefinition(getOverlord(), forResource(resource.getId()), detachedDef1);
        driftMgr.updateDriftDefinition(getOverlord(), forResource(resource.getId()), detachedDef2);

        // update the template
        final DriftDefinition newTemplateDef = template.getTemplateDefinition();
        newTemplateDef.setInterval(4800L);
        newTemplateDef.setDriftHandlingMode(plannedChanges);
        newTemplateDef.setEnabled(false);

        templateMgr.updateTemplate(getOverlord(), template);

        // verify that the template has been updated
        final DriftDefinitionTemplate updatedTemplate = loadTemplate(template.getName());
        AssertUtils.assertPropertiesMatch("Failed to update template", template, updatedTemplate, "resourceType",
            "driftDefinitions", "templateDefinition");

        // verify that attached definitions are updated.
        for (DriftDefinition def : asList(attachedDef1, attachedDef2)) {
            DriftDefinition updatedDef = loadDefinition(def.getId());
            String msg = "Failed to propagate update to attached definition " + toString(updatedDef) + " - ";
            DriftDefinition updatedTemplateDef = updatedTemplate.getTemplateDefinition();

            assertEquals(msg + "enabled property not updated", updatedTemplateDef.isEnabled(), updatedDef.isEnabled());
            assertEquals(msg + "driftHandlingMode property not updated", updatedTemplateDef.getDriftHandlingMode(),
                updatedDef.getDriftHandlingMode());
            assertEquals(msg + "interval property not updated", updatedTemplateDef.getInterval(),
View Full Code Here

        templateDef.setEnabled(true);
        templateDef.setDriftHandlingMode(normal);
        templateDef.setInterval(2400L);
        templateDef.setBasedir(new DriftDefinition.BaseDirectory(fileSystem, "/foo/bar/test"));

        final DriftDefinitionTemplate template = templateMgr.createTemplate(getOverlord(), resourceType.getId(), true,
            templateDef);

        // next create some resource level definitions
        final DriftDefinition attachedDef1 = createDefinition(template, NAME_PREFIX + "attachedDef1", true);
        final DriftDefinition attachedDef2 = createDefinition(template, NAME_PREFIX + "attachedDef2", true);
        final DriftDefinition detachedDef1 = createDefinition(template, NAME_PREFIX + "detachedDef1", false);
        final DriftDefinition detachedDef2 = createDefinition(template, NAME_PREFIX + "detachedDef2", false);

        // create initial change set from which the snapshot will be generated
        final JPADriftChangeSet changeSet0 = new JPADriftChangeSet(resource, 0, COVERAGE, attachedDef1);

        driftFile1 = new JPADriftFile(driftFile1Hash);
        drift1 = new JPADrift(changeSet0, drift1Path, FILE_ADDED, null, driftFile1);

        final JPADriftSet driftSet = new JPADriftSet();
        driftSet.addDrift(drift1);

        // create change set v1
        driftFile2 = new JPADriftFile(driftFile2Hash);
        final JPADriftChangeSet changeSet1 = new JPADriftChangeSet(resource, 1, DRIFT, attachedDef1);
        drift2 = new JPADrift(changeSet1, drift2Path, FILE_ADDED, null, driftFile2);

        executeInTransaction(false, new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                em.persist(attachedDef1);

                em.persist(driftFile1);
                em.persist(driftFile2);

                em.persist(changeSet0);
                em.persist(driftSet);
                changeSet0.setInitialDriftSet(driftSet);
                em.merge(changeSet0);

                em.persist(changeSet1);
                em.persist(drift2);

                em.persist(attachedDef2);
                em.persist(detachedDef1);
                em.persist(detachedDef2);
            }
        });

        // now we pin the snapshot to the template
        templateMgr.pinTemplate(getOverlord(), template.getId(), attachedDef1.getId(), 1);

        // verify that the template is now pinned
        DriftDefinitionTemplate updatedTemplate = loadTemplate(template.getName());
        assertTrue("Template should be marked pinned", updatedTemplate.isPinned());
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    //@Test(groups = "pinning", dependsOnMethods = "pinTemplate")
    private void persistChangeSetWhenTemplateGetsPinned() throws Exception {

        DriftDefinitionTemplate template = loadTemplate(TEST_PIN_TEMPLATE);

        GenericDriftChangeSetCriteria criteria = new GenericDriftChangeSetCriteria();
        criteria.addFilterId(template.getChangeSetId());

        PageList<? extends DriftChangeSet<?>> changeSets = driftMgr.findDriftChangeSetsByCriteria(getOverlord(),
            criteria);

        assertEquals("Expected to find change set for pinned template", 1, changeSets.size());
View Full Code Here

    }

    public void testDriftDefRemoval() throws Exception {
        ResourceTypeCreator rtCreator = new ResourceTypeCreator() {
            public void modifyResourceTypeToPersist(ResourceType resourceType) {
                DriftDefinitionTemplate template = new DriftDefinitionTemplate();
                template.setName("drift1");
                template.setDescription("drift def template");
                Configuration config = new Configuration();
                DriftDefinition driftDef = new DriftDefinition(config);
                driftDef.setBasedir(new BaseDirectory(BaseDirValueContext.fileSystem, "/"));
                driftDef.setName("drift1");
                template.setTemplateDefinition(driftDef);
                resourceType.addDriftDefinitionTemplate(template);
            }
        };
        ResourceCreator rCreator = new ResourceCreator() {
            public void modifyResourceToPersist(Resource resource) {
View Full Code Here

            "The newDriftFile property was not set correctly for " + drift1);
    }

    //@Test(groups = "pinning", dependsOnMethods = "pinTemplate")
    private void updateAttachedDefinitionsWhenTemplateGetsPinned() throws Exception {
        DriftDefinitionTemplate template = loadTemplate(TEST_PIN_TEMPLATE);

        // get the attached definitions
        List<DriftDefinition> attachedDefs = new LinkedList<DriftDefinition>();
        for (DriftDefinition d : template.getDriftDefinitions()) {
            if (d.isAttached()
                && (d.getName().equals(NAME_PREFIX + "attachedDef1") || d.getName()
                    .equals(NAME_PREFIX + "attachedDef2"))) {
                attachedDefs.add(d);
            }
View Full Code Here

        assertDefinitionIsPinned(attachedDefs.get(1));
    }

    //@Test(groups = "pinning", dependsOnMethods = "pinTemplate")   
    private void doNotUpdateDetachedDefinitionsWhenTemplateGetsPinned() throws Exception {
        DriftDefinitionTemplate template = loadTemplate(TEST_PIN_TEMPLATE);

        // get the detached definitions
        List<DriftDefinition> detachedDefs = new LinkedList<DriftDefinition>();
        for (DriftDefinition d : template.getDriftDefinitions()) {
            if (!d.isAttached()
                && (d.getName().equals(NAME_PREFIX + "detachedDef1") || d.getName()
                    .equals(NAME_PREFIX + "detachedDef2"))) {
                detachedDefs.add(d);
            }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.drift.DriftDefinitionTemplate

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.