Package groovy.lang

Examples of groovy.lang.GroovyShell


                        "    elem1('hello1') ",
                        "    elem2('hello2') ",
                        "    elem3(x:7) ",
                        "}"};
        String code = asCode(lines);
        GroovyShell shell = new GroovyShell();
        shell.evaluate(code);
    }
View Full Code Here


        // @todo refactor this path
        File currentDir = new File("./src/test/groovy/bugs");
        String file = "bug1567_script.groovy";

        Binding binding = new Binding();
        GroovyShell shell = new GroovyShell(binding);
        String[] test = null;
        Object result = shell.run(new File(currentDir, file), test);

        String[] roots = new String[]{currentDir.getAbsolutePath()};
        GroovyScriptEngine gse = new GroovyScriptEngine(roots);
        binding = new Binding();
        // a MME was ensued here stating no 't.start()' was available
View Full Code Here

    // feature: static imports
    // -----------------------
    // TODO: move somewhere else
    public void test_StaticImport1() throws Exception {
        //GROOVY-3711: The following call now results in a valid script class node, so foo.Bar needs to get resolved.
        GroovyShell groovyShell = new GroovyShell();
        compile("package foo; class Bar{}", groovyShell);
        assertNotNull(compile("import static foo.Bar.mooky", groovyShell));
    }
View Full Code Here

        assertNotNull(compile("import static foo.Bar.mooky", groovyShell));
    }

    public void test_StaticImport2() throws Exception {
        //GROOVY-3711: The following call now results in a valid script class node, so foo.Bar needs to get resolved.
        GroovyShell groovyShell = new GroovyShell();
        compile("package foo; class Bar{}", groovyShell);
        assertNotNull(compile("import static foo.Bar.*", groovyShell));
    }
View Full Code Here

        // Unexpected node type: TYPE_PARAMETERS found when expecting type: OBJBLOCK
        assertNotNull(compile("class Foo<T extends C & I> {T t}")); // fails after parser
    }

    private Script compile(String input) throws Exception {
        return compile(input, new GroovyShell());
    }
View Full Code Here

* @version $Revision: 21495 $
*/
public class MainTest extends TestSupport {

    public void testMainMethod() throws Exception {
        GroovyShell shell = new GroovyShell();
        shell.run(new File("src/test/groovy/SampleMain.groovy"), new String[]{"A", "B", "C"});
    }
View Full Code Here

  //Interpreter//
  public void init(Page owner, String zslang) {
    super.init(owner, zslang);

    _global = new Binding(new Variables());
    _ip = new GroovyShell(_global);
  }
View Full Code Here

        // Add some completors to fancy things up
        reader.addCompletor(new CommandNameCompletor());

        if (parent != null) {
            shell = new GroovyShell(parent, binding);
        }
        else {
            shell = new GroovyShell(binding);
        }       

        // Add some default variables to the shell
        Map map = shell.getContext().getVariables();
View Full Code Here

     * Asserts that the script runs without any exceptions
     *
     * @param script the script that should pass without any exception thrown
     */
    protected void assertScript(final String script) throws Exception {
        GroovyShell shell = new GroovyShell();
        shell.evaluate(script, getTestClassName());
    }
View Full Code Here

            p.put("openejb.localcopy", copy);
        }
        try {
            InitialContext ctx = new InitialContext(p);

            GroovyShell shell = new GroovyShell();
            shell.setVariable("context", ctx);
            //shell.evaluate("src/test/groovy/j2ee/CreateData.groovy");

            //shell.evaluate("src/main/groovy/ui/Console.groovy");
            GroovyObject console = (GroovyObject) InvokerHelper.invokeConstructorOf("groovy.ui.Console", null);
            console.setProperty("shell", shell);
View Full Code Here

TOP

Related Classes of groovy.lang.GroovyShell

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.