Search in sources :

Example 1 with AbstractGrailsClass

use of org.grails.core.AbstractGrailsClass in project grails-core by grails.

the class GrailsClassTests method testAbstractGrailsClassNoPackage.

@Test
public void testAbstractGrailsClassNoPackage() throws Exception {
    GroovyClassLoader cl = new GroovyClassLoader();
    Class<?> clazz = cl.parseClass("class TestService { }");
    GrailsClass grailsClass = new AbstractGrailsClass(clazz, "Service") {
    };
    assertEquals("TestService", clazz.getName());
    assertEquals("Test", grailsClass.getName());
    assertEquals("TestService", grailsClass.getFullName());
    assertNotNull(grailsClass.newInstance());
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) AbstractGrailsClass(org.grails.core.AbstractGrailsClass) GrailsClass(grails.core.GrailsClass) AbstractGrailsClass(org.grails.core.AbstractGrailsClass) Test(org.junit.jupiter.api.Test)

Example 2 with AbstractGrailsClass

use of org.grails.core.AbstractGrailsClass in project grails-core by grails.

the class GrailsClassTests method testAbstractGrailsClassPackage.

@Test
public void testAbstractGrailsClassPackage() throws Exception {
    GroovyClassLoader cl = new GroovyClassLoader();
    Class<?> clazz = cl.parseClass("package test.casey; class TestService { }");
    GrailsClass grailsClass = new AbstractGrailsClass(clazz, "Service") {
    };
    assertEquals("test.casey.TestService", clazz.getName());
    assertEquals("Test", grailsClass.getName());
    assertEquals("test.casey.TestService", grailsClass.getFullName());
    assertNotNull(grailsClass.newInstance());
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) AbstractGrailsClass(org.grails.core.AbstractGrailsClass) GrailsClass(grails.core.GrailsClass) AbstractGrailsClass(org.grails.core.AbstractGrailsClass) Test(org.junit.jupiter.api.Test)

Example 3 with AbstractGrailsClass

use of org.grails.core.AbstractGrailsClass in project grails-core by grails.

the class GrailsClassTests method testGrailsClassNonPublicConstructor.

@Test
public void testGrailsClassNonPublicConstructor() throws Exception {
    GroovyClassLoader cl = new GroovyClassLoader();
    Class<?> clazz = cl.parseClass("class ProtectedConstructor { protected ProtectedConstructor() {}}");
    GrailsClass grailsClass = new AbstractGrailsClass(clazz, "ProtectedConstructor") {
    };
    assertNotNull(grailsClass.newInstance());
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) AbstractGrailsClass(org.grails.core.AbstractGrailsClass) GrailsClass(grails.core.GrailsClass) AbstractGrailsClass(org.grails.core.AbstractGrailsClass) Test(org.junit.jupiter.api.Test)

Aggregations

GrailsClass (grails.core.GrailsClass)3 GroovyClassLoader (groovy.lang.GroovyClassLoader)3 AbstractGrailsClass (org.grails.core.AbstractGrailsClass)3 Test (org.junit.jupiter.api.Test)3