Source code: org/hibernate/test/schemaupdate/MigrationTest.java
1 package org.hibernate.test.schemaupdate;
2
3 import junit.framework.Test;
4 import junit.framework.TestSuite;
5
6 import org.hibernate.cfg.Configuration;
7 import org.hibernate.test.TestCase;
8 import org.hibernate.tool.hbm2ddl.SchemaExport;
9 import org.hibernate.tool.hbm2ddl.SchemaUpdate;
10
11 /**
12 * @author Max Rydahl Andersen
13 */
14 public class MigrationTest extends TestCase {
15
16 public MigrationTest(String str) {
17 super(str);
18 }
19
20 public void testSimpleColumnAddition() {
21 Configuration v1cfg = new Configuration();
22 v1cfg.addResource(getBaseForMappings() + "/schemaupdate/1_Version.hbm.xml");
23
24 new SchemaExport(v1cfg).execute(false, true, true, false);
25
26 SchemaUpdate v1schemaUpdate = new SchemaUpdate(v1cfg);
27 v1schemaUpdate.execute(true, true);
28
29 assertEquals(0, v1schemaUpdate.getExceptions().size());
30
31 Configuration v2cfg = new Configuration();
32 v2cfg.addResource(getBaseForMappings() + "/schemaupdate/2_Version.hbm.xml");
33
34 SchemaUpdate v2schemaUpdate = new SchemaUpdate(v2cfg);
35 v2schemaUpdate.execute(true, true);
36 assertEquals(0, v2schemaUpdate.getExceptions().size());
37
38 }
39
40 protected String[] getMappings() {
41 return new String[] { };
42 }
43
44 public static Test suite() {
45 return new TestSuite(MigrationTest.class);
46 }
47
48 }
49