Search in sources :

Example 1 with ArtefactHandler

use of grails.core.ArtefactHandler in project grails-core by grails.

the class CodecArtefactHandlerTests method testDomainClassWithNameEndingInCodecIsNotACodec.

public void testDomainClassWithNameEndingInCodecIsNotACodec() {
    GroovyClassLoader gcl = new GroovyClassLoader();
    Class<?> c = gcl.parseClass("class MySpecialCodec { Long id;Long version;}\n");
    ArtefactHandler domainClassHandler = new DomainClassArtefactHandler();
    assertTrue(domainClassHandler.isArtefact(c));
    ArtefactHandler codecHandler = new CodecArtefactHandler();
    assertFalse(codecHandler.isArtefact(c));
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) CodecArtefactHandler(org.grails.commons.CodecArtefactHandler) DomainClassArtefactHandler(org.grails.core.artefact.DomainClassArtefactHandler) ArtefactHandler(grails.core.ArtefactHandler) DomainClassArtefactHandler(org.grails.core.artefact.DomainClassArtefactHandler) CodecArtefactHandler(org.grails.commons.CodecArtefactHandler)

Example 2 with ArtefactHandler

use of grails.core.ArtefactHandler in project grails-core by grails.

the class CodecArtefactHandlerTests method testIsCodecClass.

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));
    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" + "static def encode = { str -> }\n" + "}\n");
    assertFalse("class was not a codec", handler.isArtefact(nonCodecClass));
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) CodecArtefactHandler(org.grails.commons.CodecArtefactHandler) DomainClassArtefactHandler(org.grails.core.artefact.DomainClassArtefactHandler) ArtefactHandler(grails.core.ArtefactHandler) CodecArtefactHandler(org.grails.commons.CodecArtefactHandler)

Example 3 with ArtefactHandler

use of grails.core.ArtefactHandler in project grails-core by grails.

the class DomainClassArtefactHandlerTests method testIsDomainClass.

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));
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) DomainClassArtefactHandler(org.grails.core.artefact.DomainClassArtefactHandler) ArtefactHandler(grails.core.ArtefactHandler) DomainClassArtefactHandler(org.grails.core.artefact.DomainClassArtefactHandler)

Example 4 with ArtefactHandler

use of grails.core.ArtefactHandler in project grails-core by grails.

the class ServiceArtefactHandlerTests method testIsServiceClass.

public void testIsServiceClass() {
    GroovyClassLoader gcl = new GroovyClassLoader();
    Class<?> c = gcl.parseClass("class TestService { }\n");
    ArtefactHandler handler = new ServiceArtefactHandler();
    assertTrue(handler.isArtefact(c));
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) ServiceArtefactHandler(org.grails.core.artefact.ServiceArtefactHandler) ArtefactHandler(grails.core.ArtefactHandler) ServiceArtefactHandler(org.grails.core.artefact.ServiceArtefactHandler)

Example 5 with ArtefactHandler

use of grails.core.ArtefactHandler in project grails-core by grails.

the class TagLibArtefactHandlerTests method testIsTagLibClass.

public void testIsTagLibClass() {
    GroovyClassLoader gcl = new GroovyClassLoader();
    Class<?> c = gcl.parseClass("class TestTagLib { }\n");
    ArtefactHandler handler = new TagLibArtefactHandler();
    assertTrue(handler.isArtefact(c));
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) TagLibArtefactHandler(org.grails.core.artefact.TagLibArtefactHandler) TagLibArtefactHandler(org.grails.core.artefact.TagLibArtefactHandler) ArtefactHandler(grails.core.ArtefactHandler)

Aggregations

ArtefactHandler (grails.core.ArtefactHandler)9 GroovyClassLoader (groovy.lang.GroovyClassLoader)7 DomainClassArtefactHandler (org.grails.core.artefact.DomainClassArtefactHandler)3 CodecArtefactHandler (org.grails.commons.CodecArtefactHandler)2 GrailsConfigurationAware (grails.core.support.GrailsConfigurationAware)1 GrailsPlugin (grails.plugins.GrailsPlugin)1 File (java.io.File)1 ControllerArtefactHandler (org.grails.core.artefact.ControllerArtefactHandler)1 ServiceArtefactHandler (org.grails.core.artefact.ServiceArtefactHandler)1 TagLibArtefactHandler (org.grails.core.artefact.TagLibArtefactHandler)1 WatchPattern (org.grails.plugins.support.WatchPattern)1 BootstrapArtefactHandler (org.grails.web.servlet.boostrap.BootstrapArtefactHandler)1