HHH-7711 Added test for SchemaExport
This commit is contained in:
parent
eaa18d286b
commit
847bbc2a36
|
@ -36,6 +36,7 @@ import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
|
@ -110,6 +111,27 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
||||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGenerateDdlToFile() {
|
||||||
|
Configuration cfg = new Configuration();
|
||||||
|
cfg.addResource( MAPPING );
|
||||||
|
SchemaExport schemaExport = createSchemaExport( cfg );
|
||||||
|
java.io.File outFile = new java.io.File("schema.ddl");
|
||||||
|
schemaExport.setOutputFile(outFile.getPath());
|
||||||
|
// do not script to console or export to database
|
||||||
|
schemaExport.execute( false, false, false, true );
|
||||||
|
if ( doesDialectSupportDropTableIfExist() ) {
|
||||||
|
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assertEquals( 2, schemaExport.getExceptions().size() );
|
||||||
|
}
|
||||||
|
assertTrue( outFile.exists() );
|
||||||
|
//check file is not empty
|
||||||
|
assertTrue( outFile.length() > 0 );
|
||||||
|
outFile.delete();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateAndDrop() {
|
public void testCreateAndDrop() {
|
||||||
Configuration cfg = new Configuration();
|
Configuration cfg = new Configuration();
|
||||||
|
@ -130,4 +152,4 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
||||||
schemaExport.drop( true, true );
|
schemaExport.drop( true, true );
|
||||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue