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.Filter;
|
||||||
import org.hibernate.annotations.FilterDef;
|
import org.hibernate.annotations.FilterDef;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="ZOOLOGY_MAMMAL")
|
@Table(name="ZOOLOGY_MAMMAL")
|
||||||
|
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
|
||||||
public class Mammal extends Animal{
|
public class Mammal extends Animal{
|
||||||
|
|
||||||
@Column(name="IS_PREGNANT")
|
@Column(name="IS_PREGNANT")
|
||||||
|
@Type( type="numeric_boolean" )
|
||||||
private boolean isPregnant;
|
private boolean isPregnant;
|
||||||
|
|
||||||
public boolean isPregnant() {
|
public boolean isPregnant() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.Filter;
|
import org.hibernate.annotations.Filter;
|
||||||
import org.hibernate.annotations.FilterDef;
|
import org.hibernate.annotations.FilterDef;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="ZOOLOGY_MAMMAL")
|
@Table(name="ZOOLOGY_MAMMAL")
|
||||||
|
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
|
||||||
public class Mammal extends Animal{
|
public class Mammal extends Animal{
|
||||||
|
|
||||||
@Column(name="IS_PREGNANT")
|
@Column(name="IS_PREGNANT")
|
||||||
|
@Type( type="numeric_boolean" )
|
||||||
private boolean isPregnant;
|
private boolean isPregnant;
|
||||||
|
|
||||||
public boolean isPregnant() {
|
public boolean isPregnant() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.Filter;
|
import org.hibernate.annotations.Filter;
|
||||||
import org.hibernate.annotations.FilterDef;
|
import org.hibernate.annotations.FilterDef;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="ZOOLOGY_MAMMAL")
|
@Table(name="ZOOLOGY_MAMMAL")
|
||||||
|
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
|
||||||
public class Mammal extends Animal{
|
public class Mammal extends Animal{
|
||||||
|
|
||||||
@Column(name="IS_PREGNANT")
|
@Column(name="IS_PREGNANT")
|
||||||
|
@Type( type="numeric_boolean" )
|
||||||
private boolean isPregnant;
|
private boolean isPregnant;
|
||||||
|
|
||||||
public boolean isPregnant() {
|
public boolean isPregnant() {
|
||||||
|
|
|
@ -37,19 +37,6 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
*/
|
*/
|
||||||
public class SchemaExportSuppliedConnectionTest extends SchemaExportTest {
|
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
|
@Override
|
||||||
protected SchemaExport createSchemaExport(Configuration cfg) {
|
protected SchemaExport createSchemaExport(Configuration cfg) {
|
||||||
return new SchemaExport( serviceRegistry, cfg );
|
return new SchemaExport( serviceRegistry, cfg );
|
||||||
|
|
|
@ -23,10 +23,15 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.schemaupdate;
|
package org.hibernate.test.schemaupdate;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
|
|
||||||
|
@ -44,6 +49,22 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
||||||
return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect()
|
return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect()
|
||||||
.supportsIfExistsBeforeTableName();
|
.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
|
@Test
|
||||||
public void testCreateAndDropOnlyType() {
|
public void testCreateAndDropOnlyType() {
|
||||||
|
@ -52,12 +73,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
||||||
SchemaExport schemaExport = createSchemaExport( cfg );
|
SchemaExport schemaExport = createSchemaExport( cfg );
|
||||||
// create w/o dropping first; (OK because tables don't exist yet
|
// create w/o dropping first; (OK because tables don't exist yet
|
||||||
schemaExport.execute( false, true, false, true );
|
schemaExport.execute( false, true, false, true );
|
||||||
if ( doesDialectSupportDropTableIfExist() ) {
|
// if ( doesDialectSupportDropTableIfExist() ) {
|
||||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
assertEquals( 2, schemaExport.getExceptions().size() );
|
// assertEquals( 2, schemaExport.getExceptions().size() );
|
||||||
}
|
// }
|
||||||
// create w/o dropping again; should be an exception for each table
|
// create w/o dropping again; should be an exception for each table
|
||||||
// (2 total) because the tables exist already
|
// (2 total) because the tables exist already
|
||||||
// assertEquals( 0, schemaExport.getExceptions().size() );
|
// assertEquals( 0, schemaExport.getExceptions().size() );
|
||||||
|
@ -96,7 +117,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
||||||
SchemaExport schemaExport = createSchemaExport( cfg );
|
SchemaExport schemaExport = createSchemaExport( cfg );
|
||||||
// should drop before creating, but tables don't exist yet
|
// should drop before creating, but tables don't exist yet
|
||||||
schemaExport.create( true, true );
|
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
|
// call create again; it should drop tables before re-creating
|
||||||
schemaExport.create( true, true );
|
schemaExport.create( true, true );
|
||||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||||
|
|
Loading…
Reference in New Issue