From ed991e385ed86ca74af01fb95607e529ce9697dd Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 12 Apr 2016 11:16:41 +0100 Subject: [PATCH] HHH-10678 - Add test for issue --- .../test/schemaupdate/SchemaExportTest.java | 27 +++++++++++++++++++ .../test/schemaupdate/mapping2.hbm.xml | 21 +++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/schemaupdate/mapping2.hbm.xml diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java index 155b40a8eb..c38b25d392 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java @@ -6,6 +6,8 @@ */ package org.hibernate.test.schemaupdate; +import java.io.File; +import java.nio.file.Files; import java.util.EnumSet; import org.hibernate.boot.MetadataSources; @@ -16,13 +18,18 @@ import org.hibernate.service.ServiceRegistry; import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.schema.TargetType; +import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.RequiresDialectFeature; 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 static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** @@ -131,4 +138,24 @@ public class SchemaExportTest extends BaseUnitTestCase { schemaExport.drop( EnumSet.of( TargetType.DATABASE ), metadata ); assertEquals( 0, schemaExport.getExceptions().size() ); } + + @Test + @TestForIssue(jiraKey = "HHH-10678") + @RequiresDialectFeature( value = DialectChecks.SupportSchemaCreation.class) + public void testHibernateMappingSchemaPropertyIsNotIgnored() throws Exception { + File output = File.createTempFile( "update_script", ".sql" ); + output.deleteOnExit(); + + final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( serviceRegistry ) + .addResource( "org/hibernate/test/schemaupdate/mapping2.hbm.xml" ) + .buildMetadata(); + metadata.validate(); + + final SchemaExport schemaExport = new SchemaExport(); + schemaExport.setOutputFile( output.getAbsolutePath() ); + schemaExport.execute( EnumSet.of( TargetType.SCRIPT ), SchemaExport.Action.CREATE, metadata ); + + String fileContent = new String( Files.readAllBytes( output.toPath() ) ); + assertThat( fileContent, fileContent.toLowerCase().contains( "create table schema1.version" ), is( true ) ); + } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/mapping2.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/mapping2.hbm.xml new file mode 100644 index 0000000000..863a2b3f1e --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/mapping2.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file