HHH-10678 - Add test for issue
This commit is contained in:
parent
251a19ef24
commit
ed991e385e
|
@ -6,6 +6,8 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.schemaupdate;
|
package org.hibernate.test.schemaupdate;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
|
@ -16,13 +18,18 @@ import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
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.ServiceRegistryBuilder;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.core.Is.is;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,4 +138,24 @@ public class SchemaExportTest extends BaseUnitTestCase {
|
||||||
schemaExport.drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
schemaExport.drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
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 ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
-->
|
||||||
|
<!DOCTYPE hibernate-mapping PUBLIC
|
||||||
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
|
<hibernate-mapping package="org.hibernate.test.schemaupdate" schema="schema1">
|
||||||
|
|
||||||
|
<class name="Version">
|
||||||
|
<id name="id">
|
||||||
|
<generator class="increment"/>
|
||||||
|
</id>
|
||||||
|
<property name="description"/>
|
||||||
|
</class>
|
||||||
|
|
||||||
|
</hibernate-mapping>
|
Loading…
Reference in New Issue