Package org.rhq.core.util.updater

Examples of org.rhq.core.util.updater.DeploymentProperties


    public void testBundleCommand() throws Exception {
        addRecipeCommand("bundle --version \"1.0\" --name \"my-name\" --description \"my description here\"");
        RecipeParser parser = new RecipeParser();
        RecipeContext context = new RecipeContext(getRecipe());
        parser.parseRecipe(context);
        DeploymentProperties props = context.getDeploymentProperties();
        assert props.getBundleName().equals("my-name");
        assert props.getBundleVersion().equals("1.0");
        assert props.getDescription().equals("my description here");
        assert props.getDeploymentId() == 0;

        cleanRecipe();
        addRecipeCommand("bundle --name=my-name --version=1.0 \"--description=my description here\"");
        parser = new RecipeParser();
        context = new RecipeContext(getRecipe());
        parser.parseRecipe(context);
        props = context.getDeploymentProperties();
        assert props.getBundleName().equals("my-name");
        assert props.getBundleVersion().equals("1.0");
        assert props.getDescription().equals("my description here");
        assert props.getDeploymentId() == 0;

        // use the "-arg value" notation, as opposed to "--arg=value"
        cleanRecipe();
        addRecipeCommand("bundle -n my-name2 -v 2.0 -d \"my description here 2\"");
        parser = new RecipeParser();
        context = new RecipeContext(getRecipe());
        parser.parseRecipe(context);
        props = context.getDeploymentProperties();
        assert props.getBundleName().equals("my-name2");
        assert props.getBundleVersion().equals("2.0");
        assert props.getDescription().equals("my description here 2");
        assert props.getDeploymentId() == 0;

        // show that you only need name and version but not description
        cleanRecipe();
        addRecipeCommand("bundle -n one -v 1.0");
        parser = new RecipeParser();
        context = new RecipeContext(getRecipe());
        parser.parseRecipe(context);
        props = context.getDeploymentProperties();
        assert props.getBundleName().equals("one");
        assert props.getBundleVersion().equals("1.0");
        assert props.getDescription() == null;
        assert props.getDeploymentId() == 0;

        // show that you need name and version
        cleanRecipe();
        addRecipeCommand("bundle -n one");
        parser = new RecipeParser();
View Full Code Here


            writeFile(new File(tmpDir, bundleFile3), "third bundle file found inside bundle distro");

            String bundleName = TEST_PREFIX + "-create-from-distro";
            String bundleVersion = "1.2.3";
            String bundleDescription = "test bundle desc";
            DeploymentProperties bundleMetadata = new DeploymentProperties(0, bundleName, bundleVersion,
                bundleDescription);

            ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
            int propDefaultValue1 = 998877;
            String propDefaultValue4 = "this.is.the.default";
View Full Code Here

    protected RecipeParseResults doParseRecipe(String recipe) throws UnknownRecipeException, Exception {

        ConfigurationDefinition configDef;
        Set<String> bundleFileNames;
        DeploymentProperties metadata;

        metadata = new DeploymentProperties(0, "bundletest", "1.0", "bundle test description");

        configDef = new ConfigurationDefinition("bundletest-configdef", "Test Config Def for testing BundleVersion");
        configDef.put(new PropertyDefinitionSimple("bundletest.property",
            "Test property for BundleVersion Config Def testing", true, PropertySimpleType.STRING));
View Full Code Here

                Patch patch = patchInfo.as(Patch.class);

                String version = patch.getType() == Patch.Type.ONE_OFF ? patch.getTargetVersion() + "+" + patch.getId()
                    : patch.getTargetVersion();

                DeploymentProperties props = new DeploymentProperties(0, patch.getIdentityName(),
                    version, patch.getDescription(), DestinationComplianceMode.full);

                ConfigurationDefinition config = new ConfigurationDefinition("wildfly-patch", null);
                PropertyDefinitionSimple patchIdProp = new PropertyDefinitionSimple("patchId", "The ID of the patch",
                    true,
                    PropertySimpleType.STRING);
                patchIdProp.setDefaultValue(patch.getId());
                patchIdProp.setReadOnly(true);
                PropertyDefinitionSimple patchTypeProp = new PropertyDefinitionSimple("patchType",
                    "The type of the patch",
                    true, PropertySimpleType.STRING);
                patchTypeProp.setDefaultValue(patch.getType().toString());
                patchTypeProp.setReadOnly(true);

                config.put(patchIdProp);
                config.put(patchTypeProp);
                addCommonProperties(config);

                parseResults = new RecipeParseResults(props, config, null);
                fileName = patch.getId();
                recipe = patch.getContents();
            } else if (patchInfo.is(PatchBundle.class)) {
                PatchBundle patchBundle = patchInfo.as(PatchBundle.class);

                Patch lastPatch = null;
                StringBuilder allPatchIds = new StringBuilder();

                for (PatchBundle.Element p : patchBundle) {
                    lastPatch = p.getPatch();
                    allPatchIds.append(p.getPatch().getId()).append("#");
                }
                allPatchIds.replace(allPatchIds.length() - 1, allPatchIds.length(), "");

                if (lastPatch == null) {
                    throw new UnknownRecipeException("Not a Wildfly patch");
                }

                DeploymentProperties props = new DeploymentProperties(0, lastPatch.getIdentityName(),
                    lastPatch.getTargetVersion(), lastPatch.getDescription(), DestinationComplianceMode.full);

                ConfigurationDefinition config = new ConfigurationDefinition("wildfly-patch", null);
                PropertyDefinitionSimple allPatchIdsProp = new PropertyDefinitionSimple("allPatchIds",
                    "Hash-separated list of all individual patches the patch bundle is composed of.", true,
View Full Code Here

                throw new UnknownRecipeException("Not a valid file template recipe");
            }
            throw e;
        }

        DeploymentProperties bundleMetadata = recipeContext.getDeploymentProperties();

        Set<String> bundleFileNames = new HashSet<String>();
        Map<String, String> deployFiles = recipeContext.getDeployFiles();
        bundleFileNames.addAll(deployFiles.keySet());
        Set<String> scriptFiles = recipeContext.getScriptFiles();
View Full Code Here

        // string of that antlib URI, that means this probably isn't an Ant recipe in the first place
        if (!recipe.contains("antlib:org.rhq.bundle")) {
            throw new UnknownRecipeException("Not a valid Ant recipe");
        }

        DeploymentProperties deploymentProps;
        Set<String> bundleFiles;
        ConfigurationDefinition configDef;

        RecipeParseResults results;

        File recipeFile = File.createTempFile("ant-bundle-recipe", ".xml", this.tmpDirectory);
        File logFile = File.createTempFile("ant-bundle-recipe", ".log", this.tmpDirectory);
        try {
            // store the recipe in the tmp recipe file
            ByteArrayInputStream in = new ByteArrayInputStream(recipe.getBytes());
            FileOutputStream out = new FileOutputStream(recipeFile);
            StreamUtil.copy(in, out);

            // parse, but do not execute, the Ant script
            AntLauncher antLauncher = new AntLauncher(true);
            BundleAntProject project = antLauncher.parseBundleDeployFile(recipeFile, null);

            // obtain the parse results
            deploymentProps = new DeploymentProperties(0, project.getBundleName(), project.getBundleVersion(),
                project.getBundleDescription(), project.getDestinationCompliance());

            bundleFiles = project.getBundleFileNames();
            configDef = project.getConfigurationDefinition();
        } catch (Throwable t) {
View Full Code Here

        this.realizedFiles = new HashSet<String>();
        this.replacementVariables = new HashSet<String>();
        this.replacementVariableDefaultValues = new HashMap<String, String>();
        this.scripts = new ArrayList<Script>();
        this.commands = new ArrayList<Command>();
        this.deploymentProperties = new DeploymentProperties();
        this.unknownRecipe = true; // will be false if the recipe at least looks like one we understand
    }
View Full Code Here

        if (version == null || version.trim().length() == 0) {
            throw new IllegalArgumentException("Did not specify the description of the bundle");
        }

        DeploymentProperties props = context.getDeploymentProperties();
        if (props.isValid()) {
            throw new IllegalArgumentException("Cannot specify multiple bundle commands in the same recipe");
        }

        props.setBundleName(name.trim());
        props.setBundleVersion(version.trim());
        if (description != null) {
            props.setDescription(description);
        }
        props.setDeploymentId(0);

        //file templates don't support destination compliance, so let's just provide something dummy
        props.setDestinationCompliance(DestinationComplianceMode.full);

        return;
    }
View Full Code Here

        File extraFile = new File(this.destDir, "extra/extra-file.txt");
        assert extraFile.exists() : "extra file should have been restored due to revert deployment request";
        assert readFile(extraFile).startsWith("extra") : "bad restore of extra file";

        DeploymentsMetadata metadata = new DeploymentsMetadata(this.destDir);
        DeploymentProperties deploymentProps = metadata.getDeploymentProperties(deployment.getId());
        assert deploymentProps.getDeploymentId() == deployment.getId();
        assert deploymentProps.getBundleName().equals(bundle.getName());
        assert deploymentProps.getBundleVersion().equals(bundleVersion.getVersion());
        assert deploymentProps.getManageRootDir() == true;

        DeploymentProperties currentProps = metadata.getCurrentDeploymentProperties();
        assert deploymentProps.equals(currentProps);

        // check the backup directory - note, clean flag is irrelevent when determining what should be backed up
        File backupDir = metadata.getDeploymentBackupDirectory(deployment.getId());
        File ignoredBackupFile = new File(backupDir, "ignore/ignore-file.txt");
        assert ignoredBackupFile.isFile() : "old recipe didn't ignore these, should be backed up";

        DeploymentProperties previousProps = metadata.getPreviousDeploymentProperties(789);
        assert previousProps != null : "There should be previous deployment metadata";
        assert previousProps.getDeploymentId() == 456 : "bad previous deployment metadata"; // testAntBundleUpgrade used 456
        assert previousProps.getBundleName().equals(deploymentProps.getBundleName());
        assert previousProps.getBundleVersion().equals("3.0"); // testAntBundleUpgrade deployed version 3.0
    }
View Full Code Here

        assert readFile(zeroFile).startsWith("zero");
        assert readFile(oneFile).startsWith(onePropValue);
        assert readFile(twoFile).startsWith("@@two.prop@@");

        DeploymentsMetadata metadata = new DeploymentsMetadata(this.destDir);
        DeploymentProperties deploymentProps = metadata.getDeploymentProperties(deployment.getId());
        assert deploymentProps.getDeploymentId() == deployment.getId();
        assert deploymentProps.getBundleName().equals(bundle.getName());
        assert deploymentProps.getBundleVersion().equals(bundleVersion.getVersion());
        assert deploymentProps.getManageRootDir() == true;
        DeploymentProperties currentProps = metadata.getCurrentDeploymentProperties();
        assert deploymentProps.equals(currentProps);
        DeploymentProperties previousProps = metadata.getPreviousDeploymentProperties(deployment.getId());
        assert previousProps == null : "There should not be any previous deployment metadata";
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.util.updater.DeploymentProperties

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.