Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetbehl committed Nov 24, 2021
2 parents 9600e3c + 8d1f769 commit c876194
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name-template: $NEXT_PATCH_VERSION
tag-template: v$NEXT_PATCH_VERSION
name-template: $RESOLVED_VERSION
tag-template: v$RESOLVED_VERSION
version-resolver:
major:
labels:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- master
- '[4-9]+.[0-9]+.x'
- '[3-9]+.[3-9]+.x'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ buildscript {
classpath "javax.xml.bind:jaxb-api:$jaxbVersion"
classpath "com.sun.xml.bind:jaxb-impl:$jaxbVersion"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.2"
classpath "org.gradle:test-retry-gradle-plugin:1.3.1"
}
}

Expand Down Expand Up @@ -340,6 +341,7 @@ subprojects { project ->
apply plugin: 'idea'
apply plugin: 'project-report'
apply plugin: 'nebula.optional-base'
apply plugin: "org.gradle.test-retry"

if (!isTestSuite) {

Expand Down Expand Up @@ -502,6 +504,11 @@ subprojects { project ->
}

test {
retry {
maxRetries = 2
maxFailures = 20
failOnPassedAfterRetry = true
}
testLogging {
events "passed", "skipped", "failed"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.grails.databinding.xml.GPathResultMap
import java.lang.annotation.Annotation
import java.lang.reflect.Array
import java.lang.reflect.Field
import java.lang.reflect.Modifier
import java.lang.reflect.ParameterizedType

/**
Expand Down Expand Up @@ -622,6 +623,9 @@ class SimpleDataBinder implements DataBinder {
if (metaProperty instanceof MetaBeanProperty) {
def mbp = (MetaBeanProperty)metaProperty
propertyType = mbp.getter?.returnType ?: mbp.field?.type
if(propertyType && (propertyType.interface || Modifier.isAbstract(propertyType.modifiers))) {
propertyType = mbp.field?.type
}
propertyGetter = mbp.getter
}
if (propertyType == null || propertyType == Object) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,38 @@ class SimpleDataBinderSpec extends Specification {
comment.attachments.find { it.filename == 'foo.txt' }
comment.attachments.find { it.filename == 'bar.txt' }
}

@Issue('https://github.com/grails/grails-core/issues/12150')
void 'Test binding when class and embedded classes both implements an interface'() {
given:
SimpleDataBinder binder = new SimpleDataBinder()

and:
SimpleMapDataBindingSource input = [a: [data: 'abc']] as SimpleMapDataBindingSource
ClassB classWithInterface = new ClassB()

when:
binder.bind(classWithInterface, input)

then:
classWithInterface.a.data == 'abc'
}

@Issue('https://github.com/grails/grails-core/issues/12150')
void 'Test binding when class and embedded classes extends abstract class and implements an interface'() {
given:
SimpleDataBinder binder = new SimpleDataBinder()

and:
SimpleMapDataBindingSource input = [a: [data: 'abc']] as SimpleMapDataBindingSource
FromAbstractB fromAbstractB = new FromAbstractB()

when:
binder.bind(fromAbstractB, input)

then:
fromAbstractB.a.data == 'abc'
}
}

class Factory {
Expand Down Expand Up @@ -688,3 +720,26 @@ class Attachment {
String filename
}

interface InterfaceA {
String getData()
}

interface InterfaceB {
InterfaceA getA()
}

class ClassA implements InterfaceA {
String data
}

class ClassB implements InterfaceB {
ClassA a
}

class AbstractB {
ClassA a
}

class FromAbstractB extends AbstractB {

}
2 changes: 1 addition & 1 deletion grails-shell/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
}

testImplementation "net.sf.expectit:expectit-core:0.9.0"
testImplementation "com.github.jnr:jnr-posix:3.1.10"
testImplementation "com.github.jnr:jnr-posix:3.1.11"

runtimeOnly "org.slf4j:slf4j-simple:$slf4jVersion"
runtimeOnly "org.codehaus.plexus:plexus-component-api:1.0-alpha-33"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import org.grails.support.MockApplicationContext
import org.grails.web.mapping.DefaultLinkGenerator
import org.grails.web.mapping.DefaultUrlMappingEvaluator
import org.grails.web.mapping.DefaultUrlMappingsHolder
import org.grails.web.util.WebUtils
import spock.lang.Issue
import spock.lang.Specification

class RestfulUrlMappingSpec extends Specification {

def setup() {
WebUtils.clearGrailsWebRequest()
}

def mappings = {
delete "/$controller/$id(.$format)?"(action: "delete")
get "/$controller(.$format)?"(action: "index")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.grails.support.MockApplicationContext
import org.grails.web.mapping.DefaultLinkGenerator
import org.grails.web.mapping.DefaultUrlMappingEvaluator
import org.grails.web.mapping.DefaultUrlMappingsHolder
import org.grails.web.util.WebUtils
import org.springframework.mock.web.MockServletContext
import spock.lang.IgnoreIf
import spock.lang.Specification
Expand All @@ -20,6 +21,10 @@ import spock.lang.Specification
@IgnoreIf({ env['CI'] })
class UrlMappingsWithHttpMethodSpec extends Specification{

def setup() {
WebUtils.clearGrailsWebRequest()
}

def mappings = {
"/foo"( controller:"bar", action:"save", method:"POST" )
"/foo2"( controller:"bar", action:"save", method:"PUT" )
Expand Down

0 comments on commit c876194

Please sign in to comment.