diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index 143455c307..6e7016e0d2 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -296,5 +296,6 @@ tasks.withType( Test.class ).each { test -> // widen the overall 6.0 filter to include various package-protected tests test.include 'org/hibernate/bytecode/internal/bytebuddy/**' test.include 'org/hibernate/event/service/internal/**' + test.include 'org/hibernate/tool/schema/internal/**' } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/Customer.hbm.xml b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/Customer.hbm.xml index 94acb2c8fc..074919cab5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/Customer.hbm.xml +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/Customer.hbm.xml @@ -5,7 +5,7 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/Customer.java b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/Customer.java index ad05e476a8..d13a5eb6f0 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/Customer.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/Customer.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.refresh; +package org.hibernate.orm.test.refresh; /** * @author Andrea Boriero diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshDetachedInstanceWhenIsAllowedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshDetachedInstanceWhenIsAllowedTest.java index 929db9f4ec..9328db6313 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshDetachedInstanceWhenIsAllowedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshDetachedInstanceWhenIsAllowedTest.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.refresh; +package org.hibernate.orm.test.refresh; import org.hibernate.orm.test.jpa.refresh.TestEntity; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshDetachedInstanceWhenIsNotAllowedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshDetachedInstanceWhenIsNotAllowedTest.java index 5a64e8ae31..cc341028b3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshDetachedInstanceWhenIsNotAllowedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshDetachedInstanceWhenIsNotAllowedTest.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.refresh; +package org.hibernate.orm.test.refresh; import org.hibernate.cfg.AvailableSettings; import org.hibernate.orm.test.jpa.refresh.TestEntity; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshUsingEntityNameTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshUsingEntityNameTest.java index 00f89ce79a..bab068d825 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshUsingEntityNameTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshUsingEntityNameTest.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.refresh; +package org.hibernate.orm.test.refresh; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.orm.junit.DomainModel; @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test; */ @TestForIssue(jiraKey = "HHH-11217") @DomainModel( - xmlMappings = "org/hibernate/test/refresh/Customer.hbm.xml" + xmlMappings = "org/hibernate/orm/test/refresh/Customer.hbm.xml" ) @SessionFactory public class RefreshUsingEntityNameTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/TestEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/TestEntity.java index 9f87667775..908b7df52c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/TestEntity.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/refresh/TestEntity.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.refresh; +package org.hibernate.orm.test.refresh; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaCreationToOutputScriptTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaCreationToOutputScriptTest.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaCreationToOutputScriptTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaCreationToOutputScriptTest.java index 584dde20f4..ab6f917778 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaCreationToOutputScriptTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaCreationToOutputScriptTest.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.schemaupdate; +package org.hibernate.orm.test.schemaupdate; import java.io.BufferedWriter; import java.io.File; @@ -26,13 +26,14 @@ import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.service.ServiceRegistry; import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator; -import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.TestForIssue; -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.hibernate.testing.orm.junit.RequiresDialect; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -40,7 +41,8 @@ import static org.hamcrest.core.StringContains.containsString; @TestForIssue(jiraKey = "HHH-11817") @RequiresDialect(H2Dialect.class) -public class SchemaCreationToOutputScriptTest extends BaseUnitTestCase { +@BaseUnitTest +public class SchemaCreationToOutputScriptTest { private final String createTableMyEntity = "create table MyEntity"; private final String createTableMySecondEntity = "create table MySecondEntity"; @@ -49,7 +51,7 @@ public class SchemaCreationToOutputScriptTest extends BaseUnitTestCase { private ServiceRegistry serviceRegistry; private MetadataImplementor metadata; - @Before + @BeforeEach public void setUp() throws Exception { output = File.createTempFile( "creation_script", ".sql" ); output.deleteOnExit(); @@ -92,7 +94,7 @@ public class SchemaCreationToOutputScriptTest extends BaseUnitTestCase { metadata.validate(); } - @After + @AfterEach public void tearDown() { ServiceRegistryBuilder.destroy( serviceRegistry ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaDropToOutputScriptTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaDropToOutputScriptTest.java similarity index 93% rename from hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaDropToOutputScriptTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaDropToOutputScriptTest.java index d5de59440a..38f5bcb865 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaDropToOutputScriptTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaDropToOutputScriptTest.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.schemaupdate; +package org.hibernate.orm.test.schemaupdate; import java.io.BufferedWriter; import java.io.File; @@ -26,13 +26,14 @@ import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.service.ServiceRegistry; import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator; -import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.TestForIssue; -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.hibernate.testing.orm.junit.RequiresDialect; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; @@ -40,7 +41,8 @@ import static org.hamcrest.MatcherAssert.assertThat; @TestForIssue(jiraKey = "HHH-11817") @RequiresDialect(H2Dialect.class) -public class SchemaDropToOutputScriptTest extends BaseUnitTestCase { +@BaseUnitTest +public class SchemaDropToOutputScriptTest { private File output; private ServiceRegistry serviceRegistry; @@ -49,7 +51,7 @@ public class SchemaDropToOutputScriptTest extends BaseUnitTestCase { private final String dropMySecondEntityTable = "drop table if exists MySecondEntity"; - @Before + @BeforeEach public void setUp() throws Exception { output = File.createTempFile( "creation_script", ".sql" ); output.deleteOnExit(); @@ -92,7 +94,7 @@ public class SchemaDropToOutputScriptTest extends BaseUnitTestCase { metadata.validate(); } - @After + @AfterEach public void tearDown() { ServiceRegistryBuilder.destroy( serviceRegistry ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaMigrationToOutputScriptTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaMigrationToOutputScriptTest.java similarity index 94% rename from hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaMigrationToOutputScriptTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaMigrationToOutputScriptTest.java index 88d85f12ca..df3b57ca8f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaMigrationToOutputScriptTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaMigrationToOutputScriptTest.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.schemaupdate; +package org.hibernate.orm.test.schemaupdate; import java.io.BufferedWriter; import java.io.File; @@ -27,13 +27,14 @@ import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.service.ServiceRegistry; import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator; -import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.TestForIssue; -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.hibernate.testing.orm.junit.RequiresDialect; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; @@ -41,7 +42,8 @@ import static org.hamcrest.MatcherAssert.assertThat; @TestForIssue(jiraKey = "HHH-11817") @RequiresDialect(H2Dialect.class) -public class SchemaMigrationToOutputScriptTest extends BaseUnitTestCase { +@BaseUnitTest +public class SchemaMigrationToOutputScriptTest { private final String createTableMySecondEntity = "create table MySecondEntity"; @@ -49,7 +51,7 @@ public class SchemaMigrationToOutputScriptTest extends BaseUnitTestCase { private ServiceRegistry serviceRegistry; private MetadataImplementor metadata; - @Before + @BeforeEach public void setUp() throws Exception { output = File.createTempFile( "creation_script", ".sql" ); output.deleteOnExit(); @@ -105,7 +107,7 @@ public class SchemaMigrationToOutputScriptTest extends BaseUnitTestCase { metadata.validate(); } - @After + @AfterEach public void tearDown() { ServiceRegistryBuilder.destroy( serviceRegistry ); serviceRegistry = new StandardServiceRegistryBuilder().applySetting( AvailableSettings.HBM2DDL_AUTO, "drop" ) diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.java similarity index 88% rename from hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.java index a41cf20036..4b4378729b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest.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.schemaupdate; +package org.hibernate.orm.test.schemaupdate; import java.io.File; import java.io.IOException; @@ -29,36 +29,22 @@ import org.hibernate.tool.schema.JdbcMetadaAccessStrategy; import org.hibernate.tool.schema.TargetType; import org.hibernate.testing.TestForIssue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @TestForIssue(jiraKey = "HHH-13788") -@RunWith(Parameterized.class) public class SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest { - @Parameterized.Parameters - public static String[] parameters() { - return new String[] { - JdbcMetadaAccessStrategy.GROUPED.toString(), - JdbcMetadaAccessStrategy.INDIVIDUALLY.toString() - }; - } - - @Parameterized.Parameter - public String jdbcMetadataExtractorStrategy; private File updateOutputFile; private File createOutputFile; private StandardServiceRegistry ssr; private MetadataImplementor metadata; - @Before - public void setUp() throws IOException { + public void setUp(String jdbcMetadataExtractorStrategy) throws IOException { createOutputFile = File.createTempFile( "create_script", ".sql" ); createOutputFile.deleteOnExit(); updateOutputFile = File.createTempFile( "update_script", ".sql" ); @@ -79,7 +65,7 @@ public class SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameT metadata.validate(); } - @After + @AfterEach public void tearDown() { new SchemaExport().setHaltOnError( true ) .setFormat( false ) @@ -87,9 +73,12 @@ public class SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameT StandardServiceRegistryBuilder.destroy( ssr ); } - @Test - public void testSchemaUpdateDoesNotTryToRecreateExistingTables() + @ParameterizedTest + @EnumSource(JdbcMetadaAccessStrategy.class) + public void testSchemaUpdateDoesNotTryToRecreateExistingTables(JdbcMetadaAccessStrategy strategy) throws Exception { + setUp( strategy.toString() ); + createSchema(); new SchemaUpdate().setHaltOnError( true ) diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest.java similarity index 87% rename from hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest.java index 3d3eedf777..b4a5378f6f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest.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.schemaupdate; +package org.hibernate.orm.test.schemaupdate; import java.io.File; import java.io.IOException; @@ -12,7 +12,6 @@ import java.nio.file.Files; import java.util.EnumSet; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @@ -28,11 +27,9 @@ import org.hibernate.tool.schema.JdbcMetadaAccessStrategy; import org.hibernate.tool.schema.TargetType; import org.hibernate.testing.TestForIssue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -41,27 +38,14 @@ import static org.junit.Assert.assertThat; * @author Andrea Boriero */ @TestForIssue(jiraKey = "HHH-13788") -@RunWith(Parameterized.class) public class SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest { - @Parameterized.Parameters - public static String[] parameters() { - return new String[] { - JdbcMetadaAccessStrategy.GROUPED.toString(), - JdbcMetadaAccessStrategy.INDIVIDUALLY.toString() - }; - } - - @Parameterized.Parameter - public String jdbcMetadataExtractorStrategy; - private File updateOutputFile; private File createOutputFile; private StandardServiceRegistry ssr; private MetadataImplementor metadata; - @Before - public void setUp() throws IOException { + public void setUp(String jdbcMetadataExtractorStrategy) throws IOException { createOutputFile = File.createTempFile( "create_script", ".sql" ); createOutputFile.deleteOnExit(); updateOutputFile = File.createTempFile( "update_script", ".sql" ); @@ -82,7 +66,7 @@ public class SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest { metadata.validate(); } - @After + @AfterEach public void tearDown() { new SchemaExport().setHaltOnError( true ) .setFormat( false ) @@ -90,9 +74,12 @@ public class SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest { StandardServiceRegistryBuilder.destroy( ssr ); } - @Test - public void testSchemaUpdateDoesNotTryToRecreateExistingTables() + @ParameterizedTest + @EnumSource(JdbcMetadaAccessStrategy.class) + public void testSchemaUpdateDoesNotTryToRecreateExistingTables(JdbcMetadaAccessStrategy strategy) throws Exception { + setUp( strategy.toString() ); + createSchema(); new SchemaUpdate().setHaltOnError( true )