Package groovy.lang

Examples of groovy.lang.GroovyClassLoader.parseClass()


            request.setRequestURI("orders/list");
            ServletContext context = webRequest.getServletContext();
            GroovyClassLoader gcl = new GroovyClassLoader();

            // create mock controller
            GroovyObject controller = (GroovyObject)gcl.parseClass("class FooController {\n" +
                    "def controllerName = 'foo'\n" +
                    "def actionUri = '/foo/fooAction'\n" +
            "}").newInstance();

            request.setAttribute(GrailsApplicationAttributes.CONTROLLER, controller);
View Full Code Here


        request.setRequestURI("orders/list");
        ServletContext context = webRequest.getServletContext();
        GroovyClassLoader gcl = new GroovyClassLoader();

        // create mock controller
        GroovyObject controller = (GroovyObject)gcl.parseClass("class TestController {\n" +
                "def controllerName = 'test'\n" +
                "def actionUri = '/test/testAction'\n" +
        "}").newInstance();

        request.setAttribute(GrailsApplicationAttributes.CONTROLLER, controller);
View Full Code Here

        request.setRequestURI("orders/list");
        ServletContext context = webRequest.getServletContext();
        GroovyClassLoader gcl = new GroovyClassLoader();

        // create mock controller
        GroovyObject controller = (GroovyObject)gcl.parseClass("class Test2Controller {\n" +
                "def controllerName = 'test2'\n" +
                "def actionUri = '/test2/testAction'\n" +
        "}").newInstance();

        request.setAttribute(GrailsApplicationAttributes.CONTROLLER, controller);        GrailsLayoutDecoratorMapper m = new GrailsLayoutDecoratorMapper();
View Full Code Here

        request.setRequestURI("orders/list");
        ServletContext context = webRequest.getServletContext();
        GroovyClassLoader gcl = new GroovyClassLoader();

        // create mock controller
        GroovyObject controller = (GroovyObject)gcl.parseClass("class TestController {\n" +
                "def controllerName = 'test'\n" +
                "def actionUri = '/test/testAction'\n" +
                "static layout = 'mylayout'\n" +
        "}").newInstance();
View Full Code Here

    @SuppressWarnings("rawtypes")
    public void testConstraintBuilder() throws Exception {
        GroovyClassLoader gcl = new GroovyClassLoader();

        Class groovyClass = gcl.parseClass("class TestClass {\n" +
                        "Long id\n" +
                        "Long version\n" +
                        "String login\n" +
                        "String other\n" +
                        "String email\n" +
View Full Code Here

public class DomainClassArtefactHandlerTests extends TestCase {

    public void testIsDomainClass() {

        GroovyClassLoader gcl = new GroovyClassLoader();
        Class<?> c = gcl.parseClass("class Test { Long id;Long version;}\n");

        ArtefactHandler handler = new DomainClassArtefactHandler();
        assertTrue(handler.isArtefact(c));
    }
}
View Full Code Here

    public void testIsCodecClass() {

        ArtefactHandler handler = new CodecArtefactHandler();
        GroovyClassLoader gcl = new GroovyClassLoader();

        Class<?> fullCodecClass = gcl.parseClass("class FullCodec {\n" +
                "static def encode = { str -> }\n" +
                "static def decode = { str -> }\n" +
                "}\n");
        assertTrue("class was an encoder/decoder", handler.isArtefact(fullCodecClass));
View Full Code Here

        InputStream stream = getClass().getClassLoader().getResourceAsStream(constraintsScript);

        if (stream != null) {
            GroovyClassLoader gcl = new GroovyClassLoader();
            try {
                Class<?> scriptClass = gcl.parseClass(IOUtils.toString(stream, "UTF-8"));
                Script script = (Script)scriptClass.newInstance();
                script.run();
                Binding binding = script.getBinding();
                if (binding.getVariables().containsKey(ConstraintsEvaluator.PROPERTY_NAME)) {
                    return (Closure<?>)binding.getVariable(ConstraintsEvaluator.PROPERTY_NAME);
View Full Code Here

                "static def encode = { str -> }\n" +
                "static def decode = { str -> }\n" +
                "}\n");
        assertTrue("class was an encoder/decoder", handler.isArtefact(fullCodecClass));

        Class<?> decodeOnlyCodecClass = gcl.parseClass("class DecodeOnlyCodec {\n" +
                "static def decode = { str -> }\n" +
                "}\n");
        assertTrue("class was a decoder", handler.isArtefact(decodeOnlyCodecClass));

        Class<?> encodeOnlyCodecClass = gcl.parseClass("class EncodeOnlyCodec {\n" +
View Full Code Here

        Class<?> decodeOnlyCodecClass = gcl.parseClass("class DecodeOnlyCodec {\n" +
                "static def decode = { str -> }\n" +
                "}\n");
        assertTrue("class was a decoder", handler.isArtefact(decodeOnlyCodecClass));

        Class<?> encodeOnlyCodecClass = gcl.parseClass("class EncodeOnlyCodec {\n" +
                "static def encode = { str -> }\n" +
                "}\n");
        assertTrue("class was an encoder", handler.isArtefact(encodeOnlyCodecClass));

        Class<?> nonCodecClass = gcl.parseClass("class SomeFoo {\n" +
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.