From 36be5cc3da2f365bb47088635edd287df6aa0458 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Mon, 13 Dec 2021 11:52:42 +0100 Subject: [PATCH] Re-enabled additional tests --- .../jpa/test/mapping/QuotingTest.java | 37 ----- .../DefaultCatalogAndSchemaTest.java | 2 +- .../test/formulajoin/AnnotatedDetail.java | 2 +- ...atedFormWithBeanValidationNotNullTest.java | 10 +- .../test/formulajoin/AnnotatedRoot.java | 2 +- .../jpa}/mapping/NestedEmbeddableTest.java | 61 ++++---- .../test => orm/test/jpa}/mapping/Phone.java | 2 +- .../test/namingstrategy/Category.java | 13 +- .../test/namingstrategy/Customers.hbm.xml | 2 +- .../test/namingstrategy/Customers.java | 2 +- ...QualifiedEntityNameNamingStrategyTest.java | 21 +-- .../{ => orm}/test/namingstrategy/Item.java | 2 +- .../namingstrategy/LocalizedEmbeddable.java | 2 +- .../namingstrategy/NamingStrategyTest.java | 63 ++++++++ .../namingstrategy/TestNamingStrategy.java | 2 +- .../test/namingstrategy/Workflow.java | 2 +- .../CollectionJoinTableNamingTest.java | 17 +-- ...ponentNamingStrategyForJoinColumnTest.java | 29 ++-- .../ComponentNamingStrategyTest.java | 15 +- .../namingstrategy/components/Container.java | 2 +- .../test/namingstrategy/components/Item.java | 2 +- .../ejb3joincolumn/Language.java | 2 +- .../PhysicalNamingStrategyImpl.java | 2 +- .../namingstrategy/ejb3joincolumn/Tests.java | 20 +-- .../synchronizedTables/DynamicEntity.java | 2 +- .../SynchronizeTableNamingTest.java | 19 +-- .../test/subclassfilter/Customer.java | 2 +- .../DiscrimSubclassFilterTest.java | 135 ++++++++++++++++++ .../test/subclassfilter/Employee.java | 2 +- .../{ => orm}/test/subclassfilter/Person.java | 2 +- .../UnionSubclassFilterTest.java | 135 ++++++++++++++++++ .../subclassfilter/discrim-subclass.hbm.xml | 2 +- .../subclassfilter/union-subclass.hbm.xml | 2 +- .../{ => orm}/test/tenantid/Account.java | 2 +- .../{ => orm}/test/tenantid/Client.java | 2 +- .../{ => orm}/test/tenantid/TenantIdTest.java | 2 +- .../namingstrategy/NamingStrategyTest.java | 62 -------- .../DiscrimSubclassFilterTest.java | 130 ----------------- .../JoinedSubclassFilterTest.java | 4 + .../UnionSubclassFilterTest.java | 130 ----------------- .../subclassfilter/joined-subclass.hbm.xml | 2 +- ...icit-file-level-catalog-and-schema.hbm.xml | 2 +- ...icit-file-level-catalog-and-schema.orm.xml | 2 +- ...implicit-global-catalog-and-schema.orm.xml | 0 .../synchronizedTables/mapping.hbm.xml | 2 +- 45 files changed, 469 insertions(+), 486 deletions(-) delete mode 100644 hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/QuotingTest.java rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/boot/database/qualfiedTableNaming/DefaultCatalogAndSchemaTest.java (99%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/formulajoin/AnnotatedDetail.java (93%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java (75%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/formulajoin/AnnotatedRoot.java (96%) rename hibernate-core/src/test/java/org/hibernate/{jpa/test => orm/test/jpa}/mapping/NestedEmbeddableTest.java (87%) rename hibernate-core/src/test/java/org/hibernate/{jpa/test => orm/test/jpa}/mapping/Phone.java (96%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/Category.java (66%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/Customers.hbm.xml (91%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/Customers.java (93%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/FullyQualifiedEntityNameNamingStrategyTest.java (92%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/Item.java (98%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/LocalizedEmbeddable.java (97%) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/NamingStrategyTest.java rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/TestNamingStrategy.java (97%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/Workflow.java (97%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/collectionJoinTableNaming/CollectionJoinTableNamingTest.java (93%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/components/ComponentNamingStrategyForJoinColumnTest.java (94%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/components/ComponentNamingStrategyTest.java (89%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/components/Container.java (89%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/components/Item.java (86%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/ejb3joincolumn/Language.java (95%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/ejb3joincolumn/PhysicalNamingStrategyImpl.java (95%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/ejb3joincolumn/Tests.java (83%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/synchronizedTables/DynamicEntity.java (88%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/namingstrategy/synchronizedTables/SynchronizeTableNamingTest.java (86%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/subclassfilter/Customer.java (93%) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/DiscrimSubclassFilterTest.java rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/subclassfilter/Employee.java (96%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/subclassfilter/Person.java (95%) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/UnionSubclassFilterTest.java rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/subclassfilter/discrim-subclass.hbm.xml (95%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/subclassfilter/union-subclass.hbm.xml (95%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/tenantid/Account.java (94%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/tenantid/Client.java (94%) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/tenantid/TenantIdTest.java (99%) delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/namingstrategy/NamingStrategyTest.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java rename hibernate-core/src/test/resources/org/hibernate/{ => orm}/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.hbm.xml (92%) rename hibernate-core/src/test/resources/org/hibernate/{ => orm}/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.orm.xml (96%) rename hibernate-core/src/test/resources/org/hibernate/{ => orm}/test/boot/database/qualfiedTableNaming/implicit-global-catalog-and-schema.orm.xml (100%) diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/QuotingTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/QuotingTest.java deleted file mode 100644 index 0d233f09d1..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/QuotingTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.jpa.test.mapping; - -import org.junit.Ignore; -import org.junit.Test; - -import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; - -/** - * @author Emmanuel Bernard - */ -public class QuotingTest extends BaseEntityManagerFunctionalTestCase { - @Test - @Ignore("don't know what this test doing, just ignore it for now --stliu") - public void testQuote() { - // the configuration was failing - } - - @Override - public String[] getEjb3DD() { - return new String[] { - "org/hibernate/ejb/test/mapping/orm.xml" - }; - } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { - Phone.class - }; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/boot/database/qualfiedTableNaming/DefaultCatalogAndSchemaTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/database/qualfiedTableNaming/DefaultCatalogAndSchemaTest.java similarity index 99% rename from hibernate-core/src/test/java/org/hibernate/test/boot/database/qualfiedTableNaming/DefaultCatalogAndSchemaTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/boot/database/qualfiedTableNaming/DefaultCatalogAndSchemaTest.java index a9111a8382..0fb361dc1c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/boot/database/qualfiedTableNaming/DefaultCatalogAndSchemaTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/database/qualfiedTableNaming/DefaultCatalogAndSchemaTest.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.test.boot.database.qualfiedTableNaming; +package org.hibernate.orm.test.boot.database.qualfiedTableNaming; import java.io.StringWriter; import java.util.ArrayList; diff --git a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedDetail.java b/hibernate-core/src/test/java/org/hibernate/orm/test/formulajoin/AnnotatedDetail.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedDetail.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/formulajoin/AnnotatedDetail.java index c452a32ae2..0670c6f174 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedDetail.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/formulajoin/AnnotatedDetail.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.formulajoin; +package org.hibernate.orm.test.formulajoin; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java similarity index 75% rename from hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java index fdd052786a..6bd7d9a9d9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/formulajoin/AnnotatedFormWithBeanValidationNotNullTest.java @@ -4,19 +4,19 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.formulajoin; +package org.hibernate.orm.test.formulajoin; import org.hibernate.cfg.Configuration; -import org.junit.Test; - import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.hibernate.testing.orm.junit.BaseUnitTest; +import org.junit.jupiter.api.Test; /** * @author Steve Ebersole */ -public class AnnotatedFormWithBeanValidationNotNullTest extends BaseUnitTestCase { +@BaseUnitTest +public class AnnotatedFormWithBeanValidationNotNullTest { @Test @TestForIssue( jiraKey = "HHH-8167" ) public void testAnnotatedFormWithBeanValidationNotNull() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedRoot.java b/hibernate-core/src/test/java/org/hibernate/orm/test/formulajoin/AnnotatedRoot.java similarity index 96% rename from hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedRoot.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/formulajoin/AnnotatedRoot.java index c95a2d0ef1..14dc1e06b1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/AnnotatedRoot.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/formulajoin/AnnotatedRoot.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.formulajoin; +package org.hibernate.orm.test.formulajoin; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/NestedEmbeddableTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/NestedEmbeddableTest.java similarity index 87% rename from hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/NestedEmbeddableTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/NestedEmbeddableTest.java index 1836686c87..c9e8fd8ca4 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/NestedEmbeddableTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/NestedEmbeddableTest.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.jpa.test.mapping; +package org.hibernate.orm.test.jpa.mapping; import java.io.Serializable; import java.util.Collections; @@ -14,9 +14,9 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; +import org.hibernate.testing.orm.junit.Jpa; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jakarta.persistence.AssociationOverride; import jakarta.persistence.Column; @@ -42,17 +42,16 @@ import jakarta.persistence.Table; /** * @author Vlad Mihalcea */ -public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase { +@Jpa( + annotatedClasses = { + NestedEmbeddableTest.Categorization.class, + NestedEmbeddableTest.Category.class, + NestedEmbeddableTest.CcmObject.class, + NestedEmbeddableTest.Domain.class + } +) +public class NestedEmbeddableTest { - @Override - public Class[] getAnnotatedClasses() { - return new Class[] { - Categorization.class, - Category.class, - CcmObject.class, - Domain.class - }; - } @Test public void test() { @@ -115,7 +114,8 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase { name = "values", joinTable = @JoinTable(name = "CATEGORY_TITLES", joinColumns = { - @JoinColumn(name = "OBJECT_ID")} + @JoinColumn(name = "OBJECT_ID") + } )) private LocalizedString title; @@ -124,7 +124,8 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase { name = "values", joinTable = @JoinTable(name = "CATEGORY_DESCRIPTIONS", joinColumns = { - @JoinColumn(name = "OBJECT_ID")} + @JoinColumn(name = "OBJECT_ID") + } )) private LocalizedString description; @@ -207,7 +208,8 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase { name = "values", joinTable = @JoinTable(name = "DOMAIN_TITLES", joinColumns = { - @JoinColumn(name = "OBJECT_ID")})) + @JoinColumn(name = "OBJECT_ID") + })) private LocalizedString title; @Embedded @@ -215,7 +217,8 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase { name = "values", joinTable = @JoinTable(name = "DOMAIN_DESCRIPTIONS", joinColumns = { - @JoinColumn(name = "OBJECT_ID")})) + @JoinColumn(name = "OBJECT_ID") + })) private LocalizedString description; public String getDomainKey() { @@ -261,39 +264,41 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase { } public Map getValues() { - if (values == null) { + if ( values == null ) { return null; - } else { - return Collections.unmodifiableMap( values); + } + else { + return Collections.unmodifiableMap( values ); } } protected void setValues(final Map values) { - if (values == null) { + if ( values == null ) { this.values = new HashMap<>(); - } else { - this.values = new HashMap<>(values); + } + else { + this.values = new HashMap<>( values ); } } public String getValue() { - return getValue(Locale.getDefault()); + return getValue( Locale.getDefault() ); } public String getValue(final Locale locale) { - return values.get(locale); + return values.get( locale ); } public void addValue(final Locale locale, final String value) { - values.put(locale, value); + values.put( locale, value ); } public void removeValue(final Locale locale) { - values.remove(locale); + values.remove( locale ); } public boolean hasValue(final Locale locale) { - return values.containsKey(locale); + return values.containsKey( locale ); } public Set getAvailableLocales() { diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/Phone.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/Phone.java similarity index 96% rename from hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/Phone.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/Phone.java index 7f99a1f1bd..1eb82a988a 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/mapping/Phone.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/Phone.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.jpa.test.mapping; +package org.hibernate.orm.test.jpa.mapping; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Category.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Category.java similarity index 66% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Category.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Category.java index 5ed60d41a6..09182ec417 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Category.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Category.java @@ -4,26 +4,15 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy; +package org.hibernate.orm.test.namingstrategy; -import java.io.Serializable; -import java.util.HashMap; import java.util.HashSet; -import java.util.Locale; -import java.util.Map; import java.util.Set; -import jakarta.persistence.Basic; -import jakarta.persistence.CollectionTable; -import jakarta.persistence.ElementCollection; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToMany; -import jakarta.persistence.MapKeyColumn; - -import org.hibernate.test.namingstrategy.Item; @Entity public class Category { diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Customers.hbm.xml b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Customers.hbm.xml similarity index 91% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Customers.hbm.xml rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Customers.hbm.xml index 168a654390..205886f504 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Customers.hbm.xml +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Customers.hbm.xml @@ -9,7 +9,7 @@ "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> + package="org.hibernate.orm.test.namingstrategy"> diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Customers.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Customers.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Customers.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Customers.java index f34b27a6b0..3f740e3d87 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Customers.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Customers.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy; +package org.hibernate.orm.test.namingstrategy; /** diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/FullyQualifiedEntityNameNamingStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/FullyQualifiedEntityNameNamingStrategyTest.java similarity index 92% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/FullyQualifiedEntityNameNamingStrategyTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/FullyQualifiedEntityNameNamingStrategyTest.java index 63a5e487e3..3a861aac9b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/FullyQualifiedEntityNameNamingStrategyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/FullyQualifiedEntityNameNamingStrategyTest.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy; +package org.hibernate.orm.test.namingstrategy; import java.util.Iterator; @@ -21,20 +21,21 @@ import org.hibernate.mapping.Collection; import org.hibernate.mapping.ForeignKey; import org.hibernate.mapping.PersistentClass; -import org.hibernate.testing.AfterClassOnce; -import org.hibernate.testing.BeforeClassOnce; import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.Test; +import org.hibernate.testing.orm.junit.BaseUnitTest; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class FullyQualifiedEntityNameNamingStrategyTest extends BaseUnitTestCase { +@BaseUnitTest +public class FullyQualifiedEntityNameNamingStrategyTest { private StandardServiceRegistry ssr; private MetadataImplementor metadata; - @BeforeClassOnce + @BeforeAll public void setUp() { ssr = new StandardServiceRegistryBuilder().build(); metadata = (MetadataImplementor) new MetadataSources( ssr ) @@ -46,7 +47,7 @@ public class FullyQualifiedEntityNameNamingStrategyTest extends BaseUnitTestCase .build(); } - @AfterClassOnce + @AfterAll public void tearDown() { if ( ssr != null ) { StandardServiceRegistryBuilder.destroy( ssr ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Item.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Item.java similarity index 98% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Item.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Item.java index 79d99896ee..f6fb50ccc9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Item.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Item.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy; +package org.hibernate.orm.test.namingstrategy; import java.io.Serializable; import jakarta.persistence.Column; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/LocalizedEmbeddable.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/LocalizedEmbeddable.java similarity index 97% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/LocalizedEmbeddable.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/LocalizedEmbeddable.java index a990a448ff..9c90aac915 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/LocalizedEmbeddable.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/LocalizedEmbeddable.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy; +package org.hibernate.orm.test.namingstrategy; import java.io.Serializable; import jakarta.persistence.Column; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/NamingStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/NamingStrategyTest.java new file mode 100644 index 0000000000..18efccc023 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/NamingStrategyTest.java @@ -0,0 +1,63 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.orm.test.namingstrategy; + +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.PersistentClass; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * @author Emmanuel Bernard + * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) + */ +public class NamingStrategyTest extends BaseSessionFactoryFunctionalTest { + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { + Item.class + }; + } + + @Override + protected String[] getOrmXmlFiles() { + return new String[] { + "org/hibernate/orm/test/namingstrategy/Customers.hbm.xml" + }; + } + + @Override + protected void applySettings(StandardServiceRegistryBuilder builder) { + builder.applySetting( AvailableSettings.IMPLICIT_NAMING_STRATEGY, TestNamingStrategy.class.getName() ); + builder.applySetting( AvailableSettings.PHYSICAL_NAMING_STRATEGY, TestNamingStrategy.class.getName() ); + } + + + @Test + public void testDatabaseColumnNames() { + PersistentClass classMapping = getMetadata().getEntityBinding( Customers.class.getName() ); + Column stateColumn = (Column) classMapping.getProperty( "specified_column" ).getColumnIterator().next(); + assertEquals( "CN_specified_column", stateColumn.getName() ); + } + + @Test + @TestForIssue(jiraKey = "HHH-5848") + public void testDatabaseTableNames() { + PersistentClass classMapping = getMetadata().getEntityBinding( Item.class.getName() ); + Column secTabColumn = (Column) classMapping.getProperty( "specialPrice" ).getColumnIterator().next(); + assertEquals( "TAB_ITEMS_SEC", secTabColumn.getValue().getTable().getName() ); + Column tabColumn = (Column) classMapping.getProperty( "price" ).getColumnIterator().next(); + assertEquals( "TAB_ITEMS", tabColumn.getValue().getTable().getName() ); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/TestNamingStrategy.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/TestNamingStrategy.java similarity index 97% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/TestNamingStrategy.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/TestNamingStrategy.java index 4ed350cf5f..590653d943 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/TestNamingStrategy.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/TestNamingStrategy.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy; +package org.hibernate.orm.test.namingstrategy; import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.naming.ImplicitBasicColumnNameSource; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Workflow.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Workflow.java similarity index 97% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Workflow.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Workflow.java index d3d1421484..5318900316 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/Workflow.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/Workflow.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy; +package org.hibernate.orm.test.namingstrategy; import java.io.Serializable; import java.util.HashMap; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/collectionJoinTableNaming/CollectionJoinTableNamingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/collectionJoinTableNaming/CollectionJoinTableNamingTest.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/collectionJoinTableNaming/CollectionJoinTableNamingTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/collectionJoinTableNaming/CollectionJoinTableNamingTest.java index 5c657c0f41..4cd8db2cb2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/collectionJoinTableNaming/CollectionJoinTableNamingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/collectionJoinTableNaming/CollectionJoinTableNamingTest.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.test.namingstrategy.collectionJoinTableNaming; +package org.hibernate.orm.test.namingstrategy.collectionJoinTableNaming; import java.io.Serializable; import java.util.EnumSet; @@ -51,18 +51,19 @@ import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.schema.TargetType; import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.Test; +import org.hibernate.testing.orm.junit.BaseUnitTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * @author Steve Ebersole * @author Alessandro Polverini */ -public class CollectionJoinTableNamingTest extends BaseUnitTestCase { +@BaseUnitTest +public class CollectionJoinTableNamingTest { @Test @TestForIssue( jiraKey = "HHH-9908" ) @@ -165,7 +166,7 @@ public class CollectionJoinTableNamingTest extends BaseUnitTestCase { Collection inputs2Mapping = metadata.getCollectionBinding( Ptx.class.getName() + ".inputs2" ); assertEquals( "ptx_input", inputs2Mapping.getCollectionTable().getName() ); - assertSame( inputs1Mapping.getCollectionTable(), inputs2Mapping.getCollectionTable() ); + Assertions.assertSame( inputs1Mapping.getCollectionTable(), inputs2Mapping.getCollectionTable() ); // NOTE : here so that tester can more easily see the produced table. It is only dumped to stdout new SchemaExport().create( EnumSet.of( TargetType.STDOUT ), metadata ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/ComponentNamingStrategyForJoinColumnTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/ComponentNamingStrategyForJoinColumnTest.java similarity index 94% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/ComponentNamingStrategyForJoinColumnTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/ComponentNamingStrategyForJoinColumnTest.java index 68aab14977..777871ea05 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/ComponentNamingStrategyForJoinColumnTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/ComponentNamingStrategyForJoinColumnTest.java @@ -4,11 +4,22 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy.components; +package org.hibernate.orm.test.namingstrategy.components; import java.util.ArrayList; import java.util.List; -import jakarta.persistence.Basic; + +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl; +import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.orm.junit.BaseUnitTest; + +import org.junit.jupiter.api.Test; + import jakarta.persistence.ElementCollection; import jakarta.persistence.Embeddable; import jakarta.persistence.Embedded; @@ -19,23 +30,15 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; -import org.hibernate.boot.Metadata; -import org.hibernate.boot.MetadataSources; -import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl; -import org.hibernate.boot.registry.StandardServiceRegistry; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; /** * @author Cai Chun */ @TestForIssue(jiraKey = "HHH-11826") -public class ComponentNamingStrategyForJoinColumnTest extends BaseUnitTestCase { +@BaseUnitTest +public class ComponentNamingStrategyForJoinColumnTest { @Test public void testNamingComponentPath() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/ComponentNamingStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/ComponentNamingStrategyTest.java similarity index 89% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/ComponentNamingStrategyTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/ComponentNamingStrategyTest.java index 1c112e8e90..a7f560f584 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/ComponentNamingStrategyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/ComponentNamingStrategyTest.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy.components; +package org.hibernate.orm.test.namingstrategy.components; import org.hibernate.boot.Metadata; import org.hibernate.boot.MetadataSources; @@ -19,16 +19,19 @@ import org.hibernate.mapping.Property; import org.hibernate.mapping.SimpleValue; import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.Test; +import org.hibernate.testing.orm.junit.BaseUnitTest; +import org.junit.jupiter.api.Test; + +import static org.hibernate.testing.orm.junit.ExtraAssertions.assertTyping; +import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping; -import static org.junit.Assert.assertEquals; /** * @author Steve Ebersole */ -public class ComponentNamingStrategyTest extends BaseUnitTestCase { +@BaseUnitTest +public class ComponentNamingStrategyTest { + @Test public void testDefaultNamingStrategy() { final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/Container.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/Container.java similarity index 89% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/Container.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/Container.java index f7fbcbfbf4..a795d23498 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/Container.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/Container.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy.components; +package org.hibernate.orm.test.namingstrategy.components; import java.util.List; import jakarta.persistence.ElementCollection; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/Item.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/Item.java similarity index 86% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/Item.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/Item.java index ae8ded0cc7..086ab24767 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/components/Item.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/components/Item.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy.components; +package org.hibernate.orm.test.namingstrategy.components; import jakarta.persistence.Embeddable; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/ejb3joincolumn/Language.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Language.java similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/ejb3joincolumn/Language.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Language.java index cb26d31ce2..596347a1af 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/ejb3joincolumn/Language.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Language.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy.ejb3joincolumn; +package org.hibernate.orm.test.namingstrategy.ejb3joincolumn; import jakarta.persistence.Access; import jakarta.persistence.AccessType; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/ejb3joincolumn/PhysicalNamingStrategyImpl.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/PhysicalNamingStrategyImpl.java similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/ejb3joincolumn/PhysicalNamingStrategyImpl.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/PhysicalNamingStrategyImpl.java index 179663c254..b1d207947b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/ejb3joincolumn/PhysicalNamingStrategyImpl.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/PhysicalNamingStrategyImpl.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy.ejb3joincolumn; +package org.hibernate.orm.test.namingstrategy.ejb3joincolumn; import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/ejb3joincolumn/Tests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Tests.java similarity index 83% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/ejb3joincolumn/Tests.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Tests.java index 98a99bc2ad..0a658ba56a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/ejb3joincolumn/Tests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Tests.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy.ejb3joincolumn; +package org.hibernate.orm.test.namingstrategy.ejb3joincolumn; import java.util.Iterator; import java.util.Locale; @@ -22,12 +22,12 @@ import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.Test; +import org.hibernate.testing.orm.junit.BaseUnitTest; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests {@link org.hibernate.cfg.Ejb3JoinColumn} and {@link org.hibernate.boot.model.naming.PhysicalNamingStrategy} @@ -36,9 +36,11 @@ import static org.junit.Assert.assertTrue; * @author Anton Wimmer * @author Steve Ebersole */ -public class Tests extends BaseUnitTestCase { +@BaseUnitTest +public class Tests { + @Test - @TestForIssue( jiraKey = "HHH-9961" ) + @TestForIssue(jiraKey = "HHH-9961") public void testJpaJoinColumnPhysicalNaming() { final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder() .applySettings( Environment.getProperties() ) @@ -52,7 +54,7 @@ public class Tests extends BaseUnitTestCase { metadataBuilder.applyPhysicalNamingStrategy( PhysicalNamingStrategyImpl.INSTANCE ); final Metadata metadata = metadataBuilder.build(); - ( ( MetadataImplementor) metadata ).validate(); + ( (MetadataImplementor) metadata ).validate(); final PersistentClass languageBinding = metadata.getEntityBinding( Language.class.getName() ); final Property property = languageBinding.getProperty( "fallBack" ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/synchronizedTables/DynamicEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/synchronizedTables/DynamicEntity.java similarity index 88% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/synchronizedTables/DynamicEntity.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/synchronizedTables/DynamicEntity.java index d361d976e3..a2ca71aa35 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/synchronizedTables/DynamicEntity.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/synchronizedTables/DynamicEntity.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy.synchronizedTables; +package org.hibernate.orm.test.namingstrategy.synchronizedTables; import jakarta.persistence.Entity; import jakarta.persistence.Id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/synchronizedTables/SynchronizeTableNamingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/synchronizedTables/SynchronizeTableNamingTest.java similarity index 86% rename from hibernate-core/src/test/java/org/hibernate/test/namingstrategy/synchronizedTables/SynchronizeTableNamingTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/synchronizedTables/SynchronizeTableNamingTest.java index 2127c47110..41153d3816 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/synchronizedTables/SynchronizeTableNamingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/synchronizedTables/SynchronizeTableNamingTest.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.namingstrategy.synchronizedTables; +package org.hibernate.orm.test.namingstrategy.synchronizedTables; import org.hibernate.boot.Metadata; import org.hibernate.boot.MetadataSources; @@ -15,25 +15,26 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; import org.hibernate.mapping.PersistentClass; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.hibernate.testing.orm.junit.BaseUnitTest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Steve Ebersole */ -public class SynchronizeTableNamingTest extends BaseUnitTestCase { +@BaseUnitTest +public class SynchronizeTableNamingTest { private StandardServiceRegistry ssr; - @Before + @BeforeEach public void before() { ssr = new StandardServiceRegistryBuilder().build(); } - @After + @AfterEach public void after() { if ( ssr != null ) { StandardServiceRegistryBuilder.destroy( ssr ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/Customer.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/Customer.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/subclassfilter/Customer.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/Customer.java index 603f7f3ca1..3cf19793a5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/Customer.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/Customer.java @@ -6,7 +6,7 @@ */ // $Id: Customer.java 5899 2005-02-24 20:08:04Z steveebersole $ -package org.hibernate.test.subclassfilter; +package org.hibernate.orm.test.subclassfilter; /** diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/DiscrimSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/DiscrimSubclassFilterTest.java new file mode 100644 index 0000000000..659a5b2d78 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/DiscrimSubclassFilterTest.java @@ -0,0 +1,135 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.orm.test.subclassfilter; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import org.hibernate.Session; + +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + + +/** + * @author Steve Ebersole + */ +@DomainModel( + xmlMappings = "org/hibernate/orm/test/subclassfilter/discrim-subclass.hbm.xml" +) +@SessionFactory +public class DiscrimSubclassFilterTest { + + @Test + @SuppressWarnings({ "unchecked" }) + public void testFiltersWithSubclass(SessionFactoryScope scope) { + scope.inTransaction( + s -> { + s.enableFilter( "region" ).setParameter( "userRegion", "US" ); + + prepareTestData( s ); + s.clear(); + + List results; + Iterator itr; + + results = s.createQuery( "from Person" ).list(); + assertEquals( 4, results.size(), "Incorrect qry result count" ); + s.clear(); + + results = s.createQuery( "from Employee" ).list(); + assertEquals( 2, results.size(), "Incorrect qry result count" ); + s.clear(); + + results = new ArrayList( new HashSet( s.createQuery( "from Person as p left join fetch p.minions" ) + .list() ) ); + assertEquals( 4, results.size(), "Incorrect qry result count" ); + itr = results.iterator(); + while ( itr.hasNext() ) { + // find john + final Person p = (Person) itr.next(); + if ( p.getName().equals( "John Doe" ) ) { + Employee john = (Employee) p; + assertEquals( 1, john.getMinions().size(), "Incorrect fecthed minions count" ); + break; + } + } + s.clear(); + + results = new ArrayList( new HashSet( s.createQuery( "from Employee as p left join fetch p.minions" ) + .list() ) ); + assertEquals( 2, results.size(), "Incorrect qry result count" ); + itr = results.iterator(); + while ( itr.hasNext() ) { + // find john + final Person p = (Person) itr.next(); + if ( p.getName().equals( "John Doe" ) ) { + Employee john = (Employee) p; + assertEquals( 1, john.getMinions().size(), "Incorrect fecthed minions count" ); + break; + } + } + + } + ); + + scope.inTransaction( + s -> { + s.createQuery( "delete Customer where contactOwner is not null" ).executeUpdate(); + s.createQuery( "delete Employee where manager is not null" ).executeUpdate(); + s.createQuery( "delete Person" ).executeUpdate(); + } + ); + } + + @SuppressWarnings({ "unchecked" }) + private void prepareTestData(Session s) { + Employee john = new Employee( "John Doe" ); + john.setCompany( "JBoss" ); + john.setDepartment( "hr" ); + john.setTitle( "hr guru" ); + john.setRegion( "US" ); + + Employee polli = new Employee( "Polli Wog" ); + polli.setCompany( "JBoss" ); + polli.setDepartment( "hr" ); + polli.setTitle( "hr novice" ); + polli.setRegion( "US" ); + polli.setManager( john ); + john.getMinions().add( polli ); + + Employee suzie = new Employee( "Suzie Q" ); + suzie.setCompany( "JBoss" ); + suzie.setDepartment( "hr" ); + suzie.setTitle( "hr novice" ); + suzie.setRegion( "EMEA" ); + suzie.setManager( john ); + john.getMinions().add( suzie ); + + Customer cust = new Customer( "John Q Public" ); + cust.setCompany( "Acme" ); + cust.setRegion( "US" ); + cust.setContactOwner( john ); + + Person ups = new Person( "UPS guy" ); + ups.setCompany( "UPS" ); + ups.setRegion( "US" ); + + s.save( john ); + s.save( cust ); + s.save( ups ); + + s.flush(); + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/Employee.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/Employee.java similarity index 96% rename from hibernate-core/src/test/java/org/hibernate/test/subclassfilter/Employee.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/Employee.java index 873f11fb2a..a55d9668fd 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/Employee.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/Employee.java @@ -6,7 +6,7 @@ */ // $Id: Employee.java 5899 2005-02-24 20:08:04Z steveebersole $ -package org.hibernate.test.subclassfilter; +package org.hibernate.orm.test.subclassfilter; import jakarta.persistence.Column; import java.util.HashSet; import java.util.Set; diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/Person.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/Person.java similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/test/subclassfilter/Person.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/Person.java index 4422419152..a9d5343fe8 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/Person.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/Person.java @@ -6,7 +6,7 @@ */ // $Id: Person.java 5899 2005-02-24 20:08:04Z steveebersole $ -package org.hibernate.test.subclassfilter; +package org.hibernate.orm.test.subclassfilter; /** diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/UnionSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/UnionSubclassFilterTest.java new file mode 100644 index 0000000000..020cb34e56 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/UnionSubclassFilterTest.java @@ -0,0 +1,135 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.orm.test.subclassfilter; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import org.hibernate.Session; + +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * @author Steve Ebersole + */ +@DomainModel( + xmlMappings = "org/hibernate/orm/test/subclassfilter/union-subclass.hbm.xml" +) +@SessionFactory +public class UnionSubclassFilterTest { + + @Test + @SuppressWarnings({ "unchecked" }) + public void testFiltersWithUnionSubclass(SessionFactoryScope scope) { + + scope.inTransaction( + s -> { + s.enableFilter( "region" ).setParameter( "userRegion", "US" ); + + prepareTestData( s ); + s.clear(); + + List results; + Iterator itr; + + results = s.createQuery( "from Person" ).list(); + assertEquals( 4, results.size(), "Incorrect qry result count" ); + s.clear(); + + results = s.createQuery( "from Employee" ).list(); + assertEquals( 2, results.size(), "Incorrect qry result count" ); + s.clear(); + + results = new ArrayList( new HashSet( s.createQuery( "from Person as p left join fetch p.minions" ) + .list() ) ); + assertEquals( 4, results.size(), "Incorrect qry result count" ); + itr = results.iterator(); + while ( itr.hasNext() ) { + // find john + final Person p = (Person) itr.next(); + if ( p.getName().equals( "John Doe" ) ) { + Employee john = (Employee) p; + assertEquals( 1, john.getMinions().size(), "Incorrect fecthed minions count" ); + break; + } + } + s.clear(); + + results = new ArrayList( new HashSet( s.createQuery( "from Employee as p left join fetch p.minions" ) + .list() ) ); + assertEquals( 2, results.size(), "Incorrect qry result count" ); + itr = results.iterator(); + while ( itr.hasNext() ) { + // find john + final Person p = (Person) itr.next(); + if ( p.getName().equals( "John Doe" ) ) { + Employee john = (Employee) p; + assertEquals( 1, john.getMinions().size(), "Incorrect fecthed minions count" ); + break; + } + } + } + ); + + + scope.inTransaction( + s -> { + for ( Object entity : s.createQuery( "from Person" ).list() ) { + s.delete( entity ); + } + } + ); + + } + + @SuppressWarnings({ "unchecked" }) + private void prepareTestData(Session s) { + Employee john = new Employee( "John Doe" ); + john.setCompany( "JBoss" ); + john.setDepartment( "hr" ); + john.setTitle( "hr guru" ); + john.setRegion( "US" ); + + Employee polli = new Employee( "Polli Wog" ); + polli.setCompany( "JBoss" ); + polli.setDepartment( "hr" ); + polli.setTitle( "hr novice" ); + polli.setRegion( "US" ); + polli.setManager( john ); + john.getMinions().add( polli ); + + Employee suzie = new Employee( "Suzie Q" ); + suzie.setCompany( "JBoss" ); + suzie.setDepartment( "hr" ); + suzie.setTitle( "hr novice" ); + suzie.setRegion( "EMEA" ); + suzie.setManager( john ); + john.getMinions().add( suzie ); + + Customer cust = new Customer( "John Q Public" ); + cust.setCompany( "Acme" ); + cust.setRegion( "US" ); + cust.setContactOwner( john ); + + Person ups = new Person( "UPS guy" ); + ups.setCompany( "UPS" ); + ups.setRegion( "US" ); + + s.save( john ); + s.save( cust ); + s.save( ups ); + + s.flush(); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/discrim-subclass.hbm.xml b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/discrim-subclass.hbm.xml similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/test/subclassfilter/discrim-subclass.hbm.xml rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/discrim-subclass.hbm.xml index da8199922c..6307622412 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/discrim-subclass.hbm.xml +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/discrim-subclass.hbm.xml @@ -9,7 +9,7 @@ "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - + diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/union-subclass.hbm.xml b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/union-subclass.hbm.xml similarity index 95% rename from hibernate-core/src/test/java/org/hibernate/test/subclassfilter/union-subclass.hbm.xml rename to hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/union-subclass.hbm.xml index bf99eb23b7..584f601fa9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/union-subclass.hbm.xml +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassfilter/union-subclass.hbm.xml @@ -9,7 +9,7 @@ "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - + diff --git a/hibernate-core/src/test/java/org/hibernate/test/tenantid/Account.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tenantid/Account.java similarity index 94% rename from hibernate-core/src/test/java/org/hibernate/test/tenantid/Account.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/tenantid/Account.java index aeaaa9b5ca..ad7a89679e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/tenantid/Account.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tenantid/Account.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.tenantid; +package org.hibernate.orm.test.tenantid; import org.hibernate.annotations.TenantId; diff --git a/hibernate-core/src/test/java/org/hibernate/test/tenantid/Client.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tenantid/Client.java similarity index 94% rename from hibernate-core/src/test/java/org/hibernate/test/tenantid/Client.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/tenantid/Client.java index 6bcc965af5..a25d337168 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/tenantid/Client.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tenantid/Client.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.tenantid; +package org.hibernate.orm.test.tenantid; import org.hibernate.annotations.TenantId; diff --git a/hibernate-core/src/test/java/org/hibernate/test/tenantid/TenantIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tenantid/TenantIdTest.java similarity index 99% rename from hibernate-core/src/test/java/org/hibernate/test/tenantid/TenantIdTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/tenantid/TenantIdTest.java index 74d6dbba42..6e8735724d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/tenantid/TenantIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tenantid/TenantIdTest.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -package org.hibernate.test.tenantid; +package org.hibernate.orm.test.tenantid; import org.hibernate.PropertyValueException; import org.hibernate.boot.SessionFactoryBuilder; diff --git a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/NamingStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/NamingStrategyTest.java deleted file mode 100644 index 82e151e087..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/namingstrategy/NamingStrategyTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.test.namingstrategy; - -import org.hibernate.boot.MetadataBuilder; -import org.hibernate.boot.model.naming.ImplicitNamingStrategy; -import org.hibernate.boot.model.naming.PhysicalNamingStrategy; -import org.hibernate.mapping.Column; -import org.hibernate.mapping.PersistentClass; - -import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * @author Emmanuel Bernard - * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) - */ -public class NamingStrategyTest extends BaseNonConfigCoreFunctionalTestCase { - @Override - protected void configureMetadataBuilder(MetadataBuilder metadataBuilder) { - metadataBuilder.applyImplicitNamingStrategy( (ImplicitNamingStrategy) TestNamingStrategy.INSTANCE ); - metadataBuilder.applyPhysicalNamingStrategy( (PhysicalNamingStrategy) TestNamingStrategy.INSTANCE ); - } - - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { - Item.class - }; - } - - @Override - public String[] getMappings() { - return new String[] { - "namingstrategy/Customers.hbm.xml" - }; - } - - @Test - public void testDatabaseColumnNames() { - PersistentClass classMapping = metadata().getEntityBinding( Customers.class.getName() ); - Column stateColumn = (Column) classMapping.getProperty( "specified_column" ).getColumnIterator().next(); - assertEquals( "CN_specified_column", stateColumn.getName() ); - } - - @Test - @TestForIssue(jiraKey = "HHH-5848") - public void testDatabaseTableNames() { - PersistentClass classMapping = metadata().getEntityBinding( Item.class.getName() ); - Column secTabColumn = (Column) classMapping.getProperty( "specialPrice" ).getColumnIterator().next(); - assertEquals( "TAB_ITEMS_SEC", secTabColumn.getValue().getTable().getName() ); - Column tabColumn = (Column) classMapping.getProperty( "price" ).getColumnIterator().next(); - assertEquals( "TAB_ITEMS", tabColumn.getValue().getTable().getName() ); - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java deleted file mode 100644 index b38ea499c0..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.test.subclassfilter; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -import org.junit.Test; - -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; - -/** - * @author Steve Ebersole - */ -public class DiscrimSubclassFilterTest extends BaseCoreFunctionalTestCase { - public final String[] getMappings() { - return new String[] { "subclassfilter/discrim-subclass.hbm.xml" }; - } - - @Test - @SuppressWarnings( {"unchecked"}) - public void testFiltersWithSubclass() { - Session s = openSession(); - s.enableFilter( "region" ).setParameter( "userRegion", "US" ); - Transaction t = s.beginTransaction(); - - prepareTestData( s ); - s.clear(); - - List results; - Iterator itr; - - results = s.createQuery( "from Person" ).list(); - assertEquals( "Incorrect qry result count", 4, results.size() ); - s.clear(); - - results = s.createQuery( "from Employee" ).list(); - assertEquals( "Incorrect qry result count", 2, results.size() ); - s.clear(); - - results = new ArrayList( new HashSet( s.createQuery( "from Person as p left join fetch p.minions" ).list() ) ); - assertEquals( "Incorrect qry result count", 4, results.size() ); - itr = results.iterator(); - while ( itr.hasNext() ) { - // find john - final Person p = ( Person ) itr.next(); - if ( p.getName().equals( "John Doe" ) ) { - Employee john = ( Employee ) p; - assertEquals( "Incorrect fecthed minions count", 1, john.getMinions().size() ); - break; - } - } - s.clear(); - - results = new ArrayList( new HashSet( s.createQuery( "from Employee as p left join fetch p.minions" ).list() ) ); - assertEquals( "Incorrect qry result count", 2, results.size() ); - itr = results.iterator(); - while ( itr.hasNext() ) { - // find john - final Person p = ( Person ) itr.next(); - if ( p.getName().equals( "John Doe" ) ) { - Employee john = ( Employee ) p; - assertEquals( "Incorrect fecthed minions count", 1, john.getMinions().size() ); - break; - } - } - - t.commit(); - s.close(); - - s = openSession(); - t = s.beginTransaction(); - s.createQuery( "delete Customer where contactOwner is not null" ).executeUpdate(); - s.createQuery( "delete Employee where manager is not null" ).executeUpdate(); - s.createQuery( "delete Person" ).executeUpdate(); - t.commit(); - s.close(); - } - - @SuppressWarnings( {"unchecked"}) - private void prepareTestData(Session s) { - Employee john = new Employee("John Doe"); - john.setCompany( "JBoss" ); - john.setDepartment( "hr" ); - john.setTitle( "hr guru" ); - john.setRegion( "US" ); - - Employee polli = new Employee("Polli Wog"); - polli.setCompany( "JBoss" ); - polli.setDepartment( "hr" ); - polli.setTitle( "hr novice" ); - polli.setRegion( "US" ); - polli.setManager( john ); - john.getMinions().add( polli ); - - Employee suzie = new Employee( "Suzie Q" ); - suzie.setCompany( "JBoss" ); - suzie.setDepartment( "hr" ); - suzie.setTitle( "hr novice" ); - suzie.setRegion( "EMEA" ); - suzie.setManager( john ); - john.getMinions().add( suzie ); - - Customer cust = new Customer( "John Q Public" ); - cust.setCompany( "Acme" ); - cust.setRegion( "US" ); - cust.setContactOwner( john ); - - Person ups = new Person( "UPS guy" ); - ups.setCompany( "UPS" ); - ups.setRegion( "US" ); - - s.save( john ); - s.save( cust ); - s.save( ups ); - - s.flush(); - } - -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java index eb48b091b8..19ef9773f9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java @@ -17,6 +17,10 @@ import org.junit.Test; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.orm.test.subclassfilter.Customer; +import org.hibernate.orm.test.subclassfilter.Employee; +import org.hibernate.orm.test.subclassfilter.Person; + import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java deleted file mode 100644 index 8b574485ce..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.test.subclassfilter; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -import org.junit.Test; - -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; - -/** - * @author Steve Ebersole - */ -public class UnionSubclassFilterTest extends BaseCoreFunctionalTestCase { - public final String[] getMappings() { - return new String[] { "subclassfilter/union-subclass.hbm.xml" }; - } - - @Test - @SuppressWarnings( {"unchecked"}) - public void testFiltersWithUnionSubclass() { - Session s = openSession(); - s.enableFilter( "region" ).setParameter( "userRegion", "US" ); - Transaction t = s.beginTransaction(); - - prepareTestData( s ); - s.clear(); - - List results; - Iterator itr; - - results = s.createQuery( "from Person" ).list(); - assertEquals( "Incorrect qry result count", 4, results.size() ); - s.clear(); - - results = s.createQuery( "from Employee" ).list(); - assertEquals( "Incorrect qry result count", 2, results.size() ); - s.clear(); - - results = new ArrayList( new HashSet( s.createQuery( "from Person as p left join fetch p.minions" ).list() ) ); - assertEquals( "Incorrect qry result count", 4, results.size() ); - itr = results.iterator(); - while ( itr.hasNext() ) { - // find john - final Person p = ( Person ) itr.next(); - if ( p.getName().equals( "John Doe" ) ) { - Employee john = ( Employee ) p; - assertEquals( "Incorrect fecthed minions count", 1, john.getMinions().size() ); - break; - } - } - s.clear(); - - results = new ArrayList( new HashSet( s.createQuery( "from Employee as p left join fetch p.minions" ).list() ) ); - assertEquals( "Incorrect qry result count", 2, results.size() ); - itr = results.iterator(); - while ( itr.hasNext() ) { - // find john - final Person p = ( Person ) itr.next(); - if ( p.getName().equals( "John Doe" ) ) { - Employee john = ( Employee ) p; - assertEquals( "Incorrect fecthed minions count", 1, john.getMinions().size() ); - break; - } - } - - t.commit(); - s.close(); - - s = openSession(); - t = s.beginTransaction(); - for ( Object entity : s.createQuery( "from Person" ).list() ) { - s.delete( entity ); - } - t.commit(); - s.close(); - - } - - @SuppressWarnings( {"unchecked"}) - private void prepareTestData(Session s) { - Employee john = new Employee( "John Doe" ); - john.setCompany( "JBoss" ); - john.setDepartment( "hr" ); - john.setTitle( "hr guru" ); - john.setRegion( "US" ); - - Employee polli = new Employee( "Polli Wog" ); - polli.setCompany( "JBoss" ); - polli.setDepartment( "hr" ); - polli.setTitle( "hr novice" ); - polli.setRegion( "US" ); - polli.setManager( john ); - john.getMinions().add( polli ); - - Employee suzie = new Employee( "Suzie Q" ); - suzie.setCompany( "JBoss" ); - suzie.setDepartment( "hr" ); - suzie.setTitle( "hr novice" ); - suzie.setRegion( "EMEA" ); - suzie.setManager( john ); - john.getMinions().add( suzie ); - - Customer cust = new Customer( "John Q Public" ); - cust.setCompany( "Acme" ); - cust.setRegion( "US" ); - cust.setContactOwner( john ); - - Person ups = new Person( "UPS guy" ); - ups.setCompany( "UPS" ); - ups.setRegion( "US" ); - - s.save( john ); - s.save( cust ); - s.save( ups ); - - s.flush(); - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/joined-subclass.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/joined-subclass.hbm.xml index e2d51bbfab..ca1efc62a2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/joined-subclass.hbm.xml +++ b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/joined-subclass.hbm.xml @@ -9,7 +9,7 @@ "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - + diff --git a/hibernate-core/src/test/resources/org/hibernate/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.hbm.xml similarity index 92% rename from hibernate-core/src/test/resources/org/hibernate/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.hbm.xml rename to hibernate-core/src/test/resources/org/hibernate/orm/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.hbm.xml index fc5317d20d..a1cda1242d 100644 --- a/hibernate-core/src/test/resources/org/hibernate/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.hbm.xml +++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.hbm.xml @@ -8,7 +8,7 @@ diff --git a/hibernate-core/src/test/resources/org/hibernate/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.orm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.orm.xml similarity index 96% rename from hibernate-core/src/test/resources/org/hibernate/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.orm.xml rename to hibernate-core/src/test/resources/org/hibernate/orm/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.orm.xml index cff6d97f8b..980a164eb1 100644 --- a/hibernate-core/src/test/resources/org/hibernate/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.orm.xml +++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/boot/database/qualfiedTableNaming/implicit-file-level-catalog-and-schema.orm.xml @@ -10,7 +10,7 @@ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd" version="2.1"> - org.hibernate.test.boot.database.qualfiedTableNaming + org.hibernate.orm.test.boot.database.qualfiedTableNaming someImplicitFileLevelSchema someImplicitFileLevelCatalog - +