Package org.rhq.bundle.filetemplate.recipe

Examples of org.rhq.bundle.filetemplate.recipe.RecipeContext


        log.debug("The filetemplate bundle plugin has been shut down!!! : " + this);
    }

    public RecipeParseResults parseRecipe(String recipe) throws UnknownRecipeException, Exception {
        RecipeParser parser = new RecipeParser();
        RecipeContext recipeContext = new RecipeContext(recipe);
        try {
            parser.parseRecipe(recipeContext);
        } catch (Exception e) {
            if (recipeContext.isUnknownRecipe()) {
                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();
        bundleFileNames.addAll(scriptFiles);
        Set<String> files = recipeContext.getFiles().keySet();
        bundleFileNames.addAll(files);

        ConfigurationDefinition configDef = null;
        if (recipeContext.getReplacementVariables() != null) {
            configDef = new ConfigurationDefinition("replacementVariables", null);
            for (String replacementVar : recipeContext.getReplacementVariables()) {
                PropertyDefinitionSimple prop = new PropertyDefinitionSimple(replacementVar,
                    "Needed by bundle recipe.", false, PropertySimpleType.STRING);
                prop.setDisplayName(replacementVar);
                prop.setDefaultValue(recipeContext.getReplacementVariableDefaultValues().get(replacementVar));
                configDef.put(prop);
            }
        }

        RecipeParseResults results = new RecipeParseResults(bundleMetadata, configDef, bundleFileNames);
View Full Code Here


        File anotherDest = new File(testDestDir, "/OTHER/another.xml");

        addRecipeCommand("file --source=run-me.sh \"--destination=" + runmeDest + "\"");
        addRecipeCommand("file -s META-INF/another.xml -d \"" + anotherDest + "\"");

        RecipeContext context = parseRecipeNow(testDir);

        Map<String, String> files = context.getFiles();
        assert files.size() == 2 : files;
        assert files.get("run-me.sh") != null : files;
        assert files.get("run-me.sh").equals(runmeDest.getPath()) : files;
        assert files.get("META-INF/another.xml") != null : files;
        assert files.get("META-INF/another.xml").equals(anotherDest.getPath()) : files;
View Full Code Here

        File unzippedFile = new File(testDestDir, "zipped-file.txt");
        File zipFile = createZip("zipped file content", testDir, "deploy-test.zip", unzippedFile.getName());

        addRecipeCommand("deploy -f " + zipFile.getName() + " -d \"" + testDestDir + "\"");

        RecipeContext context = parseRecipeNow(testDir);

        Map<String, String> files = context.getDeployFiles();
        assert files.size() == 1 : files;
        assert files.get(zipFile.getName()) != null;

        String zippedFileContent = readFile(unzippedFile);
        assert zippedFileContent.equals("zipped file content");
View Full Code Here

        echoOutput.getParentFile().mkdirs();
        File script = writeFile("echo hello > \"" + echoOutput.getAbsolutePath() + "\"\n", testDir, "bin/test.sh");

        addRecipeCommand("script bin/test.sh");

        RecipeContext context = parseRecipeNow(testDir);

        Set<String> scripts = context.getScriptFiles();
        assert scripts.size() == 1 : scripts;
        assert scripts.contains("bin/test.sh") : scripts;
        String echoOutputContent = readFile(echoOutput);
        assert echoOutputContent.trim().equals("hello");
    }
View Full Code Here

            addRecipeCommand("command cmd /C \"echo helloWorld > '" + echoOutput.getAbsolutePath() + "'\"");
        } else {
            addRecipeCommand("command sh -c \"echo helloWorld > '" + echoOutput.getAbsolutePath() + "'\"");
        }

        RecipeContext context = parseRecipeNow(testDir);

        String echoOutputContent = readFile(echoOutput);
        assert echoOutputContent.trim().equals("helloWorld");
    }
View Full Code Here

TOP

Related Classes of org.rhq.bundle.filetemplate.recipe.RecipeContext

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.