Skip to content

Commit

Permalink
GRAILS-10448 - Remove JdkVersion.isAtLeastJava15() check
Browse files Browse the repository at this point in the history
pre 1.5 is no longer supported
  • Loading branch information
Jeff Scott Brown committed Sep 17, 2013
1 parent ab44185 commit 1ed1a5a
Showing 1 changed file with 14 additions and 19 deletions.
Expand Up @@ -7,7 +7,6 @@ import grails.persistence.Entity
import org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerTests
import org.codehaus.groovy.grails.web.servlet.mvc.HibernateProxy
import org.codehaus.groovy.grails.web.servlet.mvc.LazyInitializer
import org.springframework.core.JdkVersion
import org.springframework.validation.BeanPropertyBindingResult
import org.springframework.validation.Errors

Expand Down Expand Up @@ -78,35 +77,31 @@ class JSONConverterTests extends AbstractGrailsControllerTests {
}

void testJSONEnumConverting() {
if (JdkVersion.isAtLeastJava15()) {
def enumClass = ga.classLoader.loadClass("Role")
enumClass.metaClass.asType = {java.lang.Class clazz ->
if (ConverterUtil.isConverterClass(clazz)) {
return ConverterUtil.createConverter(clazz, delegate)
}
return ConverterUtil.invokeOriginalAsTypeMethod(delegate, clazz)
def enumClass = ga.classLoader.loadClass("Role")
enumClass.metaClass.asType = {java.lang.Class clazz ->
if (ConverterUtil.isConverterClass(clazz)) {
return ConverterUtil.createConverter(clazz, delegate)
}
return ConverterUtil.invokeOriginalAsTypeMethod(delegate, clazz)
}

def enumInstance = enumClass.HEAD
def c = new JSONConverterController()
c.params.e = enumInstance
c.testEnum()
def enumInstance = enumClass.HEAD
def c = new JSONConverterController()
c.params.e = enumInstance
c.testEnum()

// @todo this test is fragile and depends on runtime environment because
// of hash key ordering variations
assertEquals('{"enumType":"Role","name":"HEAD"}', response.contentAsString)
}
// @todo this test is fragile and depends on runtime environment because
// of hash key ordering variations
assertEquals('{"enumType":"Role","name":"HEAD"}', response.contentAsString)
}

void onSetUp() {
GroovySystem.metaClassRegistry.removeMetaClass Errors
GroovySystem.metaClassRegistry.removeMetaClass BeanPropertyBindingResult

if (JdkVersion.isAtLeastJava15()) {
gcl.parseClass '''
gcl.parseClass '''
enum Role { HEAD, DISPATCHER, ADMIN }
'''
}
}
}

Expand Down

0 comments on commit 1ed1a5a

Please sign in to comment.