Examples of GroovyShell


Examples of groovy.lang.GroovyShell

  public GInterpolator(Configuration conf, boolean cache, String[] imports, Map utils)
  {
    _conf = conf;
    _binding = new ConfigurationBinding(conf, utils);
    _shell = new GroovyShell(_binding);
    setCache(cache);
    _imports = imports;
  }
View Full Code Here

Examples of groovy.lang.GroovyShell

        mock.startElement("", "module", "module", attrs);
        mock.endElement("", "module", "module");

        replayControls();

        Script script = new GroovyShell().parse("processor.module(id:'basic', version:'1.0.0')");

        runScript(script, mock);
    }
View Full Code Here

Examples of groovy.lang.GroovyShell

        parser.initialize(resource, getClassResolver());

        GroovyCodeSource source = new GroovyCodeSource(resource.getResourceURL());

        Script script = new GroovyShell().parse(source);

        try
        {
            runScript(script, parser);
View Full Code Here

Examples of groovy.lang.GroovyShell

        assertEquals("cd",result);
    }
   
    @Test
    public void testEvaluateString() {
        GroovyShell shell = new GroovyShell();
        Object result = shell.evaluate("3+4");
        assertEquals(7, result);
    }
View Full Code Here

Examples of groovy.lang.GroovyShell

    public void testLatLng() {
        Binding binding = new Binding();
        binding.setVariable("street", "1600 Pennsylvania Avenue");
        binding.setVariable("city", "Washington");
        binding.setVariable("state", "DC");
        GroovyShell shell = new GroovyShell(binding);
        try {
            shell.evaluate(new File("src/geocodeV3.groovy"));
            assertEquals(38.898,
                Double.parseDouble((String) binding.getVariable("lat")),0.01);
            assertEquals(-77.037,
                Double.parseDouble((String) binding.getVariable("lng")),0.01);
        } catch (CompilationFailedException | IOException e) {
View Full Code Here

Examples of groovy.lang.GroovyShell

        // The White House, Washington, DC
        binding.setVariable("street", "1600 Pennsylvania Avenue");
        binding.setVariable("city", "Washington");
        binding.setVariable("state", "DC");
        GroovyShell shell = new GroovyShell(binding);
        try {
            shell.evaluate(new File("src/geocodeV3.groovy"));
            assertEquals(38.898,
                Double.parseDouble((String) binding.getVariable("lat")),0.01);
            assertEquals(-77.037,
                Double.parseDouble((String) binding.getVariable("lng")),0.01);

            // Greenwich Observatory, Greenwich, England
            binding.setVariable("street", "Blackheath Avenue");
            binding.setVariable("city","Greenwich");
            binding.setVariable("state","UK");
            shell.evaluate(new File("src/geocodeV3.groovy"));
            assertEquals(51.476,
                    Double.parseDouble((String) binding.getVariable("lat")),0.01);
                assertEquals(0.001,
                    Double.parseDouble((String) binding.getVariable("lng")),0.01);
               
View Full Code Here

Examples of groovy.lang.GroovyShell

        binding.put("it", new ScriptContentBuildWrapper(build));
        binding.put("rooturl", descriptor.getHudsonUrl());
        binding.put("project", build.getParent());
       
        // we add the binding to the SimpleTemplateEngine instead of the shell
        GroovyShell shell = createEngine(descriptor, Collections.EMPTY_MAP);
        SimpleTemplateEngine engine = new SimpleTemplateEngine(shell);
        try {
            String text = IOUtils.toString(templateStream);
            Template tmpl;
            synchronized (templateCache) {
View Full Code Here

Examples of groovy.lang.GroovyShell

        binding.put("it", new ScriptContentBuildWrapper(build));
        binding.put("project", build.getParent());
        binding.put("rooturl", descriptor.getHudsonUrl());
        binding.put("logger", listener.getLogger());

        GroovyShell shell = createEngine(descriptor, binding);
        Object res = shell.evaluate(new InputStreamReader(scriptStream));
        if (res != null) {
            result = res.toString();
        }
        return result;
    }
View Full Code Here

Examples of groovy.lang.GroovyShell

        Binding binding = new Binding();
        for (Map.Entry<String, Object> e : variables.entrySet()) {
            binding.setVariable(e.getKey(), e.getValue());
        }

        GroovyShell shell = new GroovyShell(cl, binding, cc);
        if (sandbox != null) {
            sandbox.register();
        }
        return shell;
    }
View Full Code Here

Examples of groovy.lang.GroovyShell

    public abstract boolean isPreBuild();

    @Override
    public boolean trigger(AbstractBuild<?, ?> build, TaskListener listener) {
        boolean result = false;
        GroovyShell engine = createEngine(build, listener);
        if (engine != null && !StringUtils.isEmpty(triggerScript)) {
            try {
                Object res = engine.evaluate(triggerScript);
                if (res != null) {
                    result = (Boolean)res;
                }
            } finally {
               
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.