Package groovy.lang

Examples of groovy.lang.GroovyClassLoader.parseClass()


public class TagLibArtefactHandlerTests extends TestCase {

    public void testIsTagLibClass() {
        GroovyClassLoader gcl = new GroovyClassLoader();

        Class<?> c = gcl.parseClass("class TestTagLib { }\n");

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


     * Test method for 'org.codehaus.groovy.grails.validation.metaclass.ConstraintsDynamicProperty.get(Object)'
     */
    @SuppressWarnings("rawtypes")
    public void testGet() throws Exception {
        GroovyClassLoader gcl = new GroovyClassLoader();
        Class<?> groovyClass = gcl.parseClass("package org.codehaus.groovy.grails.validation\n" +
                "class Test {\n" +
                "   Long id\n"// WE NEED this even though GORM 2 doesn't, as we're not a "domain" class within grails-app
                "   Long version\n"+ // WE NEED this even though GORM 2 doesn't, as we're not a "domain" class within grails-app
                " String name\n" +
                "}");
View Full Code Here

                "   String text\n" +
                "}";

        GroovyClassLoader gcl = new GroovyClassLoader();

        DefaultGrailsDomainClass bookClass = new DefaultGrailsDomainClass(gcl.parseClass(bookClassSource, "Book"));

        Map constraints = bookClass.getConstrainedProperties();
        Constrained p = (Constrained)constraints.get("title");
        assertFalse("Title property should be required", p.isNullable());
        p = (Constrained)constraints.get("description");
View Full Code Here

        super(name);
    }

    public void testAbstractGrailsClassNoPackage() throws Exception {
        GroovyClassLoader cl = new GroovyClassLoader();
        Class<?> clazz = cl.parseClass("class TestService { }");
        GrailsClass grailsClass = new AbstractGrailsClass(clazz, "Service") {/*empty*/};
        assertEquals("TestService", clazz.getName());
        assertEquals("Test", grailsClass.getName());
        assertEquals("TestService", grailsClass.getFullName());
        assertNotNull(grailsClass.newInstance());
View Full Code Here

            throws Exception {
        // We need to do a real test here to make sure
        GroovyClassLoader gcl = new GroovyClassLoader();
        Class[] classes = new Class[classSource.length];
        for (int i = 0; i < classSource.length; i++) {
            classes[i] = gcl.parseClass(classSource[i]);
        }

        DefaultGrailsDomainClass domainClass = new DefaultGrailsDomainClass(classes[classIndexToTest]);

        Map constraints = domainClass.getConstrainedProperties();
View Full Code Here

        assertNotNull(grailsClass.newInstance());
    }

    public void testAbstractGrailsClassPackage() throws Exception {
        GroovyClassLoader cl = new GroovyClassLoader();
        Class<?> clazz = cl.parseClass("package test.casey; class TestService { }");
        GrailsClass grailsClass = new AbstractGrailsClass(clazz, "Service") {/*empty*/};
        assertEquals("test.casey.TestService", clazz.getName());
        assertEquals("Test", grailsClass.getName());
        assertEquals("test.casey.TestService", grailsClass.getFullName());
        assertNotNull(grailsClass.newInstance());
View Full Code Here

        assertNotNull(grailsClass.newInstance());
    }

    public void testGrailsClassNonPublicConstructor() throws Exception {
        GroovyClassLoader cl = new GroovyClassLoader();
        Class<?> clazz = cl.parseClass("class ProtectedConstructor { protected ProtectedConstructor() {}}");
        GrailsClass grailsClass = new AbstractGrailsClass(clazz, "ProtectedConstructor") {/*empty*/};
        assertNotNull(grailsClass.newInstance());
    }
}
View Full Code Here

public class BootStrapArtefactHandlerTests extends TestCase {

    public void testIsBootStrapClass() {
        GroovyClassLoader gcl = new GroovyClassLoader();

        Class<?> c = gcl.parseClass("class TestBootStrap { }\n");

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

public class HeirarchyDomainClassTests extends TestCase {

    public void testClassHeirarchy() throws Exception {
        GroovyClassLoader gcl = new GroovyClassLoader();

        gcl.parseClass("class Super { Long id;Long version;}\n" +
                       "class Sub extends Super { }\n" +
                       "class Sub2 extends Sub { }");

        GrailsApplication ga = new DefaultGrailsApplication(gcl.getLoadedClasses(),gcl);
        ga.initialise();
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 FooController {\n" +
                "def controllerName = 'foo'\n" +
                "def actionUri = '/foo/fooAction'\n" +
        "}").newInstance();

        request.setAttribute(GrailsApplicationAttributes.CONTROLLER, controller);
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.