Skip to content

Commit

Permalink
Merge pull request #912 from jdaugherty/9.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jdaugherty authored Oct 30, 2024
2 parents b5e5565 + ee37c0a commit 97aefb3
Show file tree
Hide file tree
Showing 32 changed files with 30 additions and 271 deletions.
1 change: 1 addition & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java=17.0.12-librca
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class HibernateGormAutoConfigurationSpec extends Specification{
PropertyPlaceholderAutoConfiguration.class);
}

@Ignore("java.lang.IllegalStateException: Either class [org.grails.datastore.gorm.boot.autoconfigure.Person] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void 'Test that GORM is correctly configured'() {
when:"The context is refreshed"
context.refresh()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import spock.lang.Ignore
class ProxySpec extends HibernateSpec {

@Rollback
@Ignore("java.lang.IllegalStateException: Either class [example.Customer] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void "Test Proxy"() {
when:
new Customer(1, "Bob").save(failOnError: true, flush: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class DatabasePerTenantSpec extends HibernateSpec {
System.setProperty(SystemPropertyTenantResolver.PROPERTY_NAME, "")
}

//@Rollback("moreBooks")
@Ignore("java.lang.IllegalStateException: Either class [example.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
@Rollback("moreBooks")
void "Test should rollback changes in a previous test"() {
when:"When there is no tenant"
Book.count()
Expand All @@ -45,8 +44,7 @@ class DatabasePerTenantSpec extends HibernateSpec {
bookDataService.countBooks() == 1
}

@Ignore("java.lang.IllegalStateException: Either class [example.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void 'Test database per tenant'() {
void 'Test database per tenant'() {
when:"When there is no tenant"
Book.count()

Expand Down
28 changes: 1 addition & 27 deletions examples/grails3-hibernate5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,7 @@ dependencies {
exclude group: "org.spockframework", module: "spock-core"
}

integrationTestImplementation "org.gebish:geb-spock:$gebVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-safari-driver:$seleniumSafariDriverVersion"

integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-api:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
}

tasks.withType(Test) {
systemProperty "geb.env", System.getProperty('geb.env')
systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
if (!System.getenv().containsKey('CI')) {
systemProperty 'webdriver.chrome.driver', System.getProperty('webdriver.chrome.driver')
systemProperty 'webdriver.gecko.driver', System.getProperty('webdriver.gecko.driver')
} else {
systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver"
systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver"
}
}

webdriverBinaries {
if (!System.getenv().containsKey('CI')) {
chromedriver "$chromeDriverVersion"
geckodriver "$geckodriverVersion"
}
integrationTestImplementation testFixtures("org.grails.plugins:geb:$gebPluginVersion")
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package functional.tests

import grails.plugin.geb.ContainerGebSpec
import grails.testing.mixin.integration.Integration
import geb.spock.GebSpec
import spock.lang.Ignore

@Integration(applicationClass = Application)
@Ignore //FAILING downloading the firefox driver
class BookControllerSpec extends GebSpec {
class BookControllerSpec extends ContainerGebSpec {

void "Test list books"() {
when:"The home page is visited"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import spock.lang.Specification
@Integration(applicationClass = Application)
class CascadeValidationSpec extends Specification {

@Ignore("org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'functional.tests.Employee : (unsaved)' with class 'functional.tests.Employee' to class 'functional.tests.Person'")
void "validation cascades correctly"() {
given: "an invalid business"
Business b = new Business(name: null)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class BookControllerUnitSpec extends HibernateSpec implements ControllerUnitTest
params["title"] = 'The Stand'
}

@Ignore("java.lang.IllegalStateException: Either class [functional.tests.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void "Test the index action returns the correct model"() {

when:"The index action is executed"
Expand All @@ -50,7 +49,6 @@ class BookControllerUnitSpec extends HibernateSpec implements ControllerUnitTest
model.book!= null
}

@Ignore("java.lang.IllegalStateException: Either class [functional.tests.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void "Test the save action correctly persists an instance"() {

when:"The save action is executed with an invalid instance"
Expand All @@ -77,7 +75,6 @@ class BookControllerUnitSpec extends HibernateSpec implements ControllerUnitTest
Book.count() == 1
}

@Ignore("java.lang.IllegalStateException: Either class [functional.tests.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void "Test that the show action returns the correct model"() {
when:"The show action is executed with a null domain"
controller.show(null)
Expand Down Expand Up @@ -111,7 +108,6 @@ class BookControllerUnitSpec extends HibernateSpec implements ControllerUnitTest
model.book == book
}

@Ignore("java.lang.IllegalStateException: Either class [functional.tests.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void "Test the update action performs an update on a valid domain instance"() {
when:"Update is called for a domain instance that doesn't exist"
request.contentType = FORM_CONTENT_TYPE
Expand Down Expand Up @@ -144,7 +140,6 @@ class BookControllerUnitSpec extends HibernateSpec implements ControllerUnitTest
flash.message != null
}

@Ignore("java.lang.IllegalStateException: Either class [functional.tests.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void "Test that the delete action deletes an instance if it exists"() {
when:"The delete action is called for a null instance"
request.contentType = FORM_CONTENT_TYPE
Expand Down
27 changes: 1 addition & 26 deletions examples/grails3-multiple-datasources/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,7 @@ dependencies {

testImplementation "org.grails:grails-gorm-testing-support:$testingSupportVersion"

integrationTestImplementation "org.gebish:geb-spock:$gebVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-safari-driver:$seleniumSafariDriverVersion"

integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-api:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
}

tasks.withType(Test) {
systemProperty "geb.env", System.getProperty('geb.env')
systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
if (!System.getenv().containsKey('CI')) {
systemProperty 'webdriver.chrome.driver', System.getProperty('webdriver.chrome.driver')
systemProperty 'webdriver.gecko.driver', System.getProperty('webdriver.gecko.driver')
} else {
systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver"
systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver"
}
}

webdriverBinaries {
if (!System.getenv().containsKey('CI')) {
chromedriver "$chromeDriverVersion"
geckodriver "$geckodriverVersion"
}
integrationTestImplementation testFixtures("org.grails.plugins:geb:$gebPluginVersion")
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class PartitionedMultiTenancySpec extends HibernateSpec {
System.setProperty(SystemPropertyTenantResolver.PROPERTY_NAME, "")
}


@Ignore("java.lang.IllegalStateException: Either class [example.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void "Test should rollback changes in a previous test"() {
when: "When there is no tenant"
Book.count()
Expand All @@ -44,7 +42,6 @@ class PartitionedMultiTenancySpec extends HibernateSpec {
bookDataService.countBooks() == 1
}

@Ignore("java.lang.IllegalStateException: Either class [example.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void 'Test database per tenant'() {
when: "When there is no tenant"
Book.count()
Expand Down
29 changes: 2 additions & 27 deletions examples/grails3-schema-per-tenant/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,6 @@ dependencies {
runtimeOnly "org.grails.plugins:scaffolding:$scaffoldingVersion"

testImplementation "org.grails:grails-gorm-testing-support:$testingSupportVersion"
integrationTestImplementation "org.gebish:geb-spock:$gebVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-safari-driver:$seleniumSafariDriverVersion"

integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-api:$seleniumVersion"
integrationTestRuntimeOnly "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
}

tasks.withType(Test) {
systemProperty "geb.env", System.getProperty('geb.env')
systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
if (!System.getenv().containsKey('CI')) {
systemProperty 'webdriver.chrome.driver', System.getProperty('webdriver.chrome.driver')
systemProperty 'webdriver.gecko.driver', System.getProperty('webdriver.gecko.driver')
} else {
systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver"
systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver"
}
}

webdriverBinaries {
if (!System.getenv().containsKey('CI')) {
chromedriver "$chromeDriverVersion"
geckodriver "$geckodriverVersion"
}
}
integrationTestImplementation testFixtures("org.grails.plugins:geb:$gebPluginVersion")
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class SchemaPerTenantSpec extends HibernateSpec implements GrailsUnitTest{
}

@Rollback("moreBooks")
@Ignore("java.lang.IllegalStateException: Either class [example.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void "Test should rollback changes in a previous test"() {
when:"When there is no tenant"
Book.count()
Expand All @@ -55,7 +54,6 @@ class SchemaPerTenantSpec extends HibernateSpec implements GrailsUnitTest{
bookDataService.countBooks() == 1
}

@Ignore("java.lang.IllegalStateException: Either class [example.Book] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.")
void 'Test database per tenant'() {
when:"When there is no tenant"
Book.count()
Expand Down
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ projectVersion=9.0.0-SNAPSHOT
asciidoctorGradleVersion=4.0.1
assetPipelineVersion=5.0.1
fieldsVersion=6.0.0-SNAPSHOT
gebVersion=7.0
gebPluginVersion=5.0.0-SNAPSHOT
grolifantVersion=4.0.0
gormVersion=9.0.0-SNAPSHOT
Expand All @@ -28,8 +27,6 @@ junitJupiterPlatformVersion=1.11.3
picocliVersion=4.7.6
projectReactorVersion=3.6.10
scaffoldingVersion=6.0.0-SNAPSHOT
seleniumSafariDriverVersion=4.23.1
seleniumVersion=4.23.1
servletApiVersion=6.0.0
snakeYamlVersion=2.3
slf4jVersion=2.0.16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ public class TraitPropertyAccessStrategy implements PropertyAccessStrategy {
@Override
public PropertyAccess buildPropertyAccess(Class containerJavaType, String propertyName) {
Method readMethod = ReflectionUtils.findMethod(containerJavaType, NameUtils.getGetterName(propertyName));
if(readMethod == null) {
// See https://issues.apache.org/jira/browse/GROOVY-11512
readMethod = ReflectionUtils.findMethod(containerJavaType, NameUtils.getGetterName(propertyName, true));
if(readMethod != null && readMethod.getReturnType() != Boolean.class && readMethod.getReturnType() != boolean.class) {
readMethod = null;
}
}

if(readMethod == null) {
throw new IllegalStateException("TraitPropertyAccessStrategy used on property ["+propertyName+"] of class ["+containerJavaType.getName()+"] that is not provided by a trait!");
}
Expand Down
Loading

0 comments on commit 97aefb3

Please sign in to comment.