This is an automated email from the ASF dual-hosted git repository. borinquenkid pushed a commit to branch 8.0.x-hibernate7 in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit efc250a1730b17723363712b8b29a941f27cc41e Author: Walter Duque de Estrada <[email protected]> AuthorDate: Thu Jun 18 15:47:48 2026 -0500 Clean up H5 test cosmetics: unused imports, Groovy accessors, label typos, annotation stacking - Remove unused imports (Location, Person, Pet, Specification, ConcurrentHashMap, GormEnhancer, ConnectionSource, Settings, FlushMode, Issue, DataSource) from HibernateValidationSpec, GormEnhancerCleanupSpec, HibernateGormEnhancerSpec, HibernateDatastoreMultiTenancySpec, HibernateDatastoreConnectionSourcesRegistrarSpec - Fix duplicate "is created" in TwoBidirectionalOneToManySpec when-labels - Stack @AutoCleanup and @Shared on separate lines in TransactionalWithinReadOnlySpec - Update HibernateGormDatastoreSpec Javadoc to describe this class, not the old one - Use Groovy property access (event.entityAccess) over getEntityAccess() in HibernateUpdateFromListenerSpec - Remove redundant 'as Class[]' casts in GrailsDataHibernate5TckManager (getDomainClasses() already returns Class[]) - Revert @Issue URLs: grails/* → apache/* in PropertyFieldSpec, CustomIsolationLevelSpec, SaveWithInvalidEntitySpec Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --- .../groovy/grails/gorm/tests/HibernateGormDatastoreSpec.groovy | 10 ++++------ .../groovy/grails/gorm/tests/HibernateValidationSpec.groovy | 3 --- .../grails/gorm/tests/TwoBidirectionalOneToManySpec.groovy | 4 ++-- .../tests/dirtychecking/HibernateUpdateFromListenerSpec.groovy | 4 ++-- .../grails/gorm/tests/dirtychecking/PropertyFieldSpec.groovy | 2 +- .../grails/gorm/tests/txs/CustomIsolationLevelSpec.groovy | 2 +- .../gorm/tests/txs/TransactionalWithinReadOnlySpec.groovy | 3 ++- .../gorm/tests/validation/SaveWithInvalidEntitySpec.groovy | 4 ++-- .../data/hibernate5/core/GrailsDataHibernate5TckManager.groovy | 4 ++-- .../org/grails/datastore/gorm/GormEnhancerCleanupSpec.groovy | 2 -- .../orm/hibernate/HibernateDatastoreMultiTenancySpec.groovy | 6 ------ .../org/grails/orm/hibernate/HibernateGormEnhancerSpec.groovy | 1 - .../HibernateDatastoreConnectionSourcesRegistrarSpec.groovy | 1 - 13 files changed, 16 insertions(+), 30 deletions(-) diff --git a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/HibernateGormDatastoreSpec.groovy b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/HibernateGormDatastoreSpec.groovy index 1800163603..68f372b46d 100644 --- a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/HibernateGormDatastoreSpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/HibernateGormDatastoreSpec.groovy @@ -42,12 +42,10 @@ import org.hibernate.service.spi.ServiceRegistryImplementor import org.hibernate.boot.spi.MetadataContributor /** - * The original GormDataStoreSpec destroyed the setup - * between tests instead of at the end of all tests - * It also was default configured for H2 which - * made it break with some Java types. - * Finally, it loaded all the test Entities, - * now it can be setup individually. + * Base spec for Hibernate 5 integration tests. Sets up a per-spec H2 in-memory datastore + * and registers domain classes via {@link #manager}. Individual specs call + * {@code manager.registerDomainClasses(...)} in their own {@code setupSpec()} rather than + * loading the entire package, keeping each spec isolated and fast. */ class HibernateGormDatastoreSpec extends GrailsDataTckSpec<GrailsDataHibernate5TckManager> { diff --git a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/HibernateValidationSpec.groovy b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/HibernateValidationSpec.groovy index 7576a7a643..6813df68f5 100644 --- a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/HibernateValidationSpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/HibernateValidationSpec.groovy @@ -22,9 +22,6 @@ import org.apache.grails.data.testing.tck.domains.ChildEntity import org.apache.grails.data.testing.tck.domains.ClassWithListArgBeforeValidate import org.apache.grails.data.testing.tck.domains.ClassWithNoArgBeforeValidate import org.apache.grails.data.testing.tck.domains.ClassWithOverloadedBeforeValidate -import org.apache.grails.data.testing.tck.domains.Location -import org.apache.grails.data.testing.tck.domains.Person -import org.apache.grails.data.testing.tck.domains.Pet import org.apache.grails.data.testing.tck.domains.TestEntity import org.apache.grails.data.hibernate5.core.GrailsDataHibernate5TckManager import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec diff --git a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/TwoBidirectionalOneToManySpec.groovy b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/TwoBidirectionalOneToManySpec.groovy index 03487aa0b8..8c4e9c5fd6 100644 --- a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/TwoBidirectionalOneToManySpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/TwoBidirectionalOneToManySpec.groovy @@ -36,7 +36,7 @@ class TwoBidirectionalOneToManySpec extends Specification { @Rollback void "test an entity with 2 bidirectional one-to-many mappings"() { - when:"A new entity is created is created" + when:"A new entity is created" Room r = new Room(name:"Test") .addToPointx(new PointX()) .addToPointy(new PointY()) @@ -53,7 +53,7 @@ class TwoBidirectionalOneToManySpec extends Specification { @Rollback void "test an entity with 1 one directional one-to-many mappings"() { - when:"A new entity is created is created" + when:"A new entity is created" Room r = new Room(name:"Test") .addToPointz(new PointZ()) diff --git a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/HibernateUpdateFromListenerSpec.groovy b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/HibernateUpdateFromListenerSpec.groovy index d1e665b767..0cbe17bfc8 100644 --- a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/HibernateUpdateFromListenerSpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/HibernateUpdateFromListenerSpec.groovy @@ -85,8 +85,8 @@ class HibernateUpdateFromListenerSpec extends Specification { if (event.entityObject instanceof Person) { Person person = (Person) event.entityObject person.occupation = person.occupation + " listener" - if (event.getEntityAccess() != null) { - event.getEntityAccess().setProperty("occupation", person.occupation) + if (event.entityAccess != null) { + event.entityAccess.setProperty("occupation", person.occupation) } } isExecuted = true diff --git a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/PropertyFieldSpec.groovy b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/PropertyFieldSpec.groovy index 16faee0318..358dff2f6f 100644 --- a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/PropertyFieldSpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/dirtychecking/PropertyFieldSpec.groovy @@ -33,7 +33,7 @@ class PropertyFieldSpec extends Specification { @Shared @AutoCleanup HibernateDatastore hibernateDatastore = new HibernateDatastore(getClass().getPackage()) @Rollback - @Issue('https://github.com/grails/grails-data-mapping/issues/934') + @Issue('https://github.com/apache/grails-data-mapping/issues/934') void "test domain class with property named 'property'"() { expect: Book book = new Book(title: 'book', property: new Property(name: 'p1')) diff --git a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/CustomIsolationLevelSpec.groovy b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/CustomIsolationLevelSpec.groovy index ece70f70be..6e74e89b98 100644 --- a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/CustomIsolationLevelSpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/CustomIsolationLevelSpec.groovy @@ -36,7 +36,7 @@ class CustomIsolationLevelSpec extends Specification { @AutoCleanup @Shared HibernateDatastore hibernateDatastore = new HibernateDatastore(Product, Attribute) - @Issue('https://github.com/grails/grails-data-mapping/issues/952') + @Issue('https://github.com/apache/grails-data-mapping/issues/952') void "test custom isolation level"() { expect: new ProductService().listProducts().size() == 0 diff --git a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/TransactionalWithinReadOnlySpec.groovy b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/TransactionalWithinReadOnlySpec.groovy index 9c5942c81e..2bd8802780 100644 --- a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/TransactionalWithinReadOnlySpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/txs/TransactionalWithinReadOnlySpec.groovy @@ -33,7 +33,8 @@ import spock.lang.Specification */ class TransactionalWithinReadOnlySpec extends Specification { - @Shared @AutoCleanup HibernateDatastore datastore = new HibernateDatastore(Product, Attribute) + @AutoCleanup + @Shared HibernateDatastore datastore = new HibernateDatastore(Product, Attribute) void "test transaction status"() { diff --git a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/SaveWithInvalidEntitySpec.groovy b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/SaveWithInvalidEntitySpec.groovy index 578b5b7926..d1f7bc7a9b 100644 --- a/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/SaveWithInvalidEntitySpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/SaveWithInvalidEntitySpec.groovy @@ -37,10 +37,10 @@ class SaveWithInvalidEntitySpec extends Specification { @Shared @AutoCleanup HibernateDatastore hibernateDatastore = new HibernateDatastore(A, B) /** - * This currently fails with a NPE. See explanation https://github.com/grails/grails-core/issues/10604#issuecomment-298943022 + * This currently fails with a NPE. See explanation https://github.com/apache/grails-core/issues/10604#issuecomment-298943022 */ @Rollback - @Issue(['https://github.com/grails/grails-core/issues/10604', + @Issue(['https://github.com/apache/grails-core/issues/10604', 'https://github.com/apache/grails-core/issues/14616']) void "test save with an invalid entity"() { given: diff --git a/grails-data-hibernate5/core/src/test/groovy/org/apache/grails/data/hibernate5/core/GrailsDataHibernate5TckManager.groovy b/grails-data-hibernate5/core/src/test/groovy/org/apache/grails/data/hibernate5/core/GrailsDataHibernate5TckManager.groovy index e4ce172698..b6a730ae32 100644 --- a/grails-data-hibernate5/core/src/test/groovy/org/apache/grails/data/hibernate5/core/GrailsDataHibernate5TckManager.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/org/apache/grails/data/hibernate5/core/GrailsDataHibernate5TckManager.groovy @@ -73,10 +73,10 @@ class GrailsDataHibernate5TckManager extends GrailsDataTckManager { boolean isTransactional = true System.setProperty('hibernate5.gorm.suite', "true") - grailsApplication = new DefaultGrailsApplication(domainClasses as Class[], new GroovyClassLoader(GrailsDataHibernate5TckManager.getClassLoader())) + grailsApplication = new DefaultGrailsApplication(domainClasses, new GroovyClassLoader(GrailsDataHibernate5TckManager.getClassLoader())) grailsApplication.config.putAll(config) - hibernateDatastore = new HibernateDatastore(DatastoreUtils.createPropertyResolver(config), domainClasses as Class[]) + hibernateDatastore = new HibernateDatastore(DatastoreUtils.createPropertyResolver(config), domainClasses) transactionManager = hibernateDatastore.getTransactionManager() sessionFactory = hibernateDatastore.sessionFactory if (transactionStatus == null && isTransactional) { diff --git a/grails-data-hibernate5/core/src/test/groovy/org/grails/datastore/gorm/GormEnhancerCleanupSpec.groovy b/grails-data-hibernate5/core/src/test/groovy/org/grails/datastore/gorm/GormEnhancerCleanupSpec.groovy index 6874a037e6..3d75f23686 100644 --- a/grails-data-hibernate5/core/src/test/groovy/org/grails/datastore/gorm/GormEnhancerCleanupSpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/org/grails/datastore/gorm/GormEnhancerCleanupSpec.groovy @@ -17,8 +17,6 @@ package org.grails.datastore.gorm import grails.gorm.annotation.Entity import grails.gorm.tests.HibernateGormDatastoreSpec import org.grails.datastore.mapping.core.Datastore -import spock.lang.Specification -import java.util.concurrent.ConcurrentHashMap class GormEnhancerCleanupSpec extends HibernateGormDatastoreSpec { diff --git a/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreMultiTenancySpec.groovy b/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreMultiTenancySpec.groovy index 0b7765c010..69a5c9c575 100644 --- a/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreMultiTenancySpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreMultiTenancySpec.groovy @@ -22,14 +22,8 @@ import grails.gorm.MultiTenant import grails.gorm.annotation.Entity import grails.gorm.multitenancy.Tenants import grails.gorm.tests.HibernateGormDatastoreSpec -import org.grails.datastore.mapping.core.connections.ConnectionSource import org.grails.datastore.mapping.multitenancy.MultiTenancySettings import org.grails.datastore.mapping.multitenancy.resolvers.SystemPropertyTenantResolver -import org.grails.orm.hibernate.cfg.Settings -import org.hibernate.FlushMode -import spock.lang.Issue - -import javax.sql.DataSource class HibernateDatastoreMultiTenancySpec extends HibernateGormDatastoreSpec { diff --git a/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormEnhancerSpec.groovy b/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormEnhancerSpec.groovy index cc7f463c0d..b7b35502ac 100644 --- a/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormEnhancerSpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormEnhancerSpec.groovy @@ -20,7 +20,6 @@ package org.grails.orm.hibernate import grails.gorm.annotation.Entity import grails.gorm.tests.HibernateGormDatastoreSpec -import org.grails.datastore.gorm.GormEnhancer import org.grails.datastore.mapping.core.connections.ConnectionSource class HibernateGormEnhancerSpec extends HibernateGormDatastoreSpec { diff --git a/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/support/HibernateDatastoreConnectionSourcesRegistrarSpec.groovy b/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/support/HibernateDatastoreConnectionSourcesRegistrarSpec.groovy index 7e103bd075..c7d68adc74 100644 --- a/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/support/HibernateDatastoreConnectionSourcesRegistrarSpec.groovy +++ b/grails-data-hibernate5/core/src/test/groovy/org/grails/orm/hibernate/support/HibernateDatastoreConnectionSourcesRegistrarSpec.groovy @@ -21,7 +21,6 @@ package org.grails.orm.hibernate.support import grails.gorm.tests.HibernateGormDatastoreSpec import org.grails.datastore.gorm.bootstrap.support.InstanceFactoryBean import org.grails.datastore.mapping.config.Settings -import org.grails.datastore.mapping.core.connections.ConnectionSource import org.hibernate.SessionFactory import org.springframework.beans.factory.support.DefaultListableBeanFactory import org.springframework.transaction.PlatformTransactionManager
