HHH-7498 some tests were targeting to the H2 only but now runs on db matrix
This commit is contained in:
parent
582fe1ad63
commit
b6b9bb8cad
|
@ -6,6 +6,7 @@ import javax.persistence.Table;
|
|||
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
@Entity
|
||||
@Table(name="ZOOLOGY_MAMMAL")
|
||||
|
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
|
|||
public class Mammal extends Animal{
|
||||
|
||||
@Column(name="IS_PREGNANT")
|
||||
@Type( type="numeric_boolean" )
|
||||
private boolean isPregnant;
|
||||
|
||||
public boolean isPregnant() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import javax.persistence.Table;
|
|||
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
@Entity
|
||||
@Table(name="ZOOLOGY_MAMMAL")
|
||||
|
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
|
|||
public class Mammal extends Animal{
|
||||
|
||||
@Column(name="IS_PREGNANT")
|
||||
@Type( type="numeric_boolean" )
|
||||
private boolean isPregnant;
|
||||
|
||||
public boolean isPregnant() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import javax.persistence.Table;
|
|||
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
@Entity
|
||||
@Table(name="ZOOLOGY_MAMMAL")
|
||||
|
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
|
|||
public class Mammal extends Animal{
|
||||
|
||||
@Column(name="IS_PREGNANT")
|
||||
@Type( type="numeric_boolean" )
|
||||
private boolean isPregnant;
|
||||
|
||||
public boolean isPregnant() {
|
||||
|
|
|
@ -37,19 +37,6 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
|
|||
*/
|
||||
public class SchemaExportSuppliedConnectionTest extends SchemaExportTest {
|
||||
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||
serviceRegistry = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SchemaExport createSchemaExport(Configuration cfg) {
|
||||
return new SchemaExport( serviceRegistry, cfg );
|
||||
|
|
|
@ -23,10 +23,15 @@
|
|||
*/
|
||||
package org.hibernate.test.schemaupdate;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
|
||||
|
@ -44,6 +49,22 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
|||
return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect()
|
||||
.supportsIfExistsBeforeTableName();
|
||||
}
|
||||
protected ServiceRegistry serviceRegistry;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||
Configuration cfg = new Configuration();
|
||||
cfg.addResource( MAPPING );
|
||||
SchemaExport schemaExport = createSchemaExport( cfg );
|
||||
schemaExport.drop( true, true );
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||
serviceRegistry = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndDropOnlyType() {
|
||||
|
@ -52,12 +73,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
|||
SchemaExport schemaExport = createSchemaExport( cfg );
|
||||
// create w/o dropping first; (OK because tables don't exist yet
|
||||
schemaExport.execute( false, true, false, true );
|
||||
if ( doesDialectSupportDropTableIfExist() ) {
|
||||
// if ( doesDialectSupportDropTableIfExist() ) {
|
||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
}
|
||||
else {
|
||||
assertEquals( 2, schemaExport.getExceptions().size() );
|
||||
}
|
||||
// }
|
||||
// else {
|
||||
// assertEquals( 2, schemaExport.getExceptions().size() );
|
||||
// }
|
||||
// create w/o dropping again; should be an exception for each table
|
||||
// (2 total) because the tables exist already
|
||||
// assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
|
@ -96,7 +117,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
|||
SchemaExport schemaExport = createSchemaExport( cfg );
|
||||
// should drop before creating, but tables don't exist yet
|
||||
schemaExport.create( true, true );
|
||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
if ( doesDialectSupportDropTableIfExist() ) {
|
||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
}
|
||||
else {
|
||||
assertEquals( 2, schemaExport.getExceptions().size() );
|
||||
}
|
||||
// call create again; it should drop tables before re-creating
|
||||
schemaExport.create( true, true );
|
||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
|
|
Loading…
Reference in New Issue