Permalink
Browse files

Added test for SchemaExport

  • Loading branch information...
1 parent 9aa711c commit ec623198d8516b1d3a17d8f80bccd692553f51f0 Dmitry Geraskov committed Dec 27, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java
@@ -31,6 +31,7 @@
import org.hibernate.tool.hbm2ddl.SchemaExport;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author Gail Badner
@@ -90,6 +91,27 @@ public void testBothType() {
}
@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
public void testCreateAndDrop() {
Configuration cfg = new Configuration();
cfg.addResource( MAPPING );

0 comments on commit ec62319

Please sign in to comment.