db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r399474 [2/2] - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/model/ test/org/apache/ddlutils/ test/org/apache/ddlutils/alteration/ test/org/apache/ddlutils/io/
Date Wed, 03 May 2006 22:42:59 GMT
Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java?rev=399474&r1=399473&r2=399474&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java Wed May  3 15:42:57 2006
@@ -17,6 +17,7 @@
  */
 
 import java.sql.Types;
+import java.util.List;
 
 import junit.framework.Test;
 
@@ -38,298 +39,6 @@
  */
 public class TestAlteration extends RoundtripTestBase
 {
-    /** Test model for the first datatype change test. */
-    protected static final String TEST_DATATYPE_MODEL_1 = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='INTEGER' required='false'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the second datatype change test. */
-    protected static final String TEST_DATATYPE_MODEL_2 = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='SMALLINT' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the change of the null constraint. */
-    protected static final String TEST_CHANGE_NULL_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='INTEGER' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the addition of a default value. */
-    protected static final String TEST_ADD_DEFAULT_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='DOUBLE'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the change of a default value. */
-    protected static final String TEST_CHANGE_DEFAULT_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='INTEGER' default='1'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the dropping of a default value. */
-    protected static final String TEST_DROP_DEFAULT_MODEL_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='VARCHAR' size='20' default='test'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the making a column auto-increment. */
-    protected static final String TEST_MAKE_AUTO_INCREMENT_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='INTEGER'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the dropping the auto-increment status of a column. */
-    protected static final String TEST_DROP_AUTO_INCREMENT_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='INTEGER' autoIncrement='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for adding a column. */
-    protected static final String TEST_ADD_COLUMN_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the dropping a column. */
-    protected static final String TEST_DROP_COLUMN_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='VARCHAR' size='50'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the making a column part of the pk. */
-    protected static final String TEST_ADD_COLUMN_TO_PK_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='VARCHAR' size='50' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the removing a column from the pk. */
-    protected static final String TEST_REMOVE_COLUMN_FROM_PK_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='VARCHAR' size='50' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the adding a pk column. */
-    protected static final String TEST_ADD_PK_COLUMN_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for the dropping a pk column. */
-    protected static final String TEST_DROP_PK_COLUMN_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='VARCHAR' size='50' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for adding an index. */
-    protected static final String TEST_ADD_INDEX_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue1' type='VARCHAR' size='50'/>\n"+
-        "    <column name='avalue2' type='INTEGER' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for adding an unique index. */
-    protected static final String TEST_ADD_UNIQUE_INDEX_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='INTEGER'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for removing an unique index. */
-    protected static final String TEST_DROP_UNIQUE_INDEX_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue1' type='DOUBLE'/>\n"+
-        "    <column name='avalue2' type='VARCHAR' size='50'/>\n"+
-        "    <unique name='test_index'>\n"+
-        "      <unique-column name='avalue2'/>\n"+
-        "      <unique-column name='avalue1'/>\n"+
-        "    </unique>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for adding a column to an index. */
-    protected static final String TEST_ADD_COLUMN_TO_INDEX_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue1' type='DOUBLE'/>\n"+
-        "    <column name='avalue2' type='VARCHAR' size='40'/>\n"+
-        "    <index name='test_index'>\n"+
-        "      <index-column name='avalue1'/>\n"+
-        "    </index>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for dropping a column from an unique index. */
-    protected static final String TEST_REMOVE_COLUMN_FROM_UNIQUE_INDEX_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue1' type='DOUBLE'/>\n"+
-        "    <column name='avalue2' type='INTEGER'/>\n"+
-        "    <unique name='test_index'>\n"+
-        "      <unique-column name='avalue1'/>\n"+
-        "      <unique-column name='avalue2'/>\n"+
-        "    </unique>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for adding a foreign key. */
-    protected static final String TEST_ADD_FK_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip1'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "  <table name='roundtrip2'>\n"+
-        "    <column name='pk' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='INTEGER' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for dropping a foreign key. */
-    protected static final String TEST_DROP_FK_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip1'>\n"+
-        "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='pk2' type='DOUBLE' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "  <table name='roundtrip2'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue1' type='DOUBLE' required='true'/>\n"+
-        "    <column name='avalue2' type='INTEGER' required='true'/>\n"+
-        "    <foreign-key foreignTable='roundtrip1'>\n"+
-        "      <reference local='avalue2' foreign='pk1'/>\n"+
-        "      <reference local='avalue1' foreign='pk2'/>\n"+
-        "    </foreign-key>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for adding a reference to a foreign key. */
-    protected static final String TEST_ADD_REFERENCE_TO_FK_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip1'>\n"+
-        "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "  <table name='roundtrip2'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue1' type='INTEGER' required='true'/>\n"+
-        "    <foreign-key foreignTable='roundtrip1'>\n"+
-        "      <reference local='avalue1' foreign='pk1'/>\n"+
-        "    </foreign-key>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for dropping a reference from a foreign key. */
-    protected static final String TEST_REMOVE_REFERENCE_FROM_FK_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip1'>\n"+
-        "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='pk2' type='VARCHAR' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "  <table name='roundtrip2'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue1' type='VARCHAR' required='true'/>\n"+
-        "    <column name='avalue2' type='INTEGER' required='true'/>\n"+
-        "    <foreign-key foreignTable='roundtrip1'>\n"+
-        "      <reference local='avalue2' foreign='pk1'/>\n"+
-        "      <reference local='avalue1' foreign='pk2'/>\n"+
-        "    </foreign-key>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for adding a table. */
-    protected static final String TEST_ADD_TABLE_MODEL_1 = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip1'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-       "</database>";
-    /** Test model for adding a table. */
-    protected static final String TEST_ADD_TABLE_MODEL_2 = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip1'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='VARCHAR' size='32' required='true'/>\n"+
-        "  </table>\n"+
-       "</database>";
-    /** Test model for removing a table. */
-    protected static final String TEST_REMOVE_TABLE_1 = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip1'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "  <table name='roundtrip2'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='DOUBLE' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model for removing a table. */
-    protected static final String TEST_REMOVE_TABLE_2 = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip1'>\n"+
-        "    <column name='pk' type='VARCHAR' size='20' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "  <table name='roundtrip2'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='VARCHAR' size='20' required='true'/>\n"+
-        "    <foreign-key foreignTable='roundtrip1'>\n"+
-        "      <reference local='avalue' foreign='pk'/>\n"+
-        "    </foreign-key>\n"+
-        "  </table>\n"+
-        "</database>";
-
     /**
      * Parameterized test case pattern.
      * 
@@ -345,7 +54,18 @@
      */
     public void testChangeDatatype1()
     {
-    	Database model = createDatabase(TEST_DATATYPE_MODEL_1);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' required='false'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
 
     	model.getTable(0).getColumn(1).setTypeCode(Types.DOUBLE);
 
@@ -355,6 +75,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Double(2.0), beans.get(0), "avalue");
     }
 
     /**
@@ -362,7 +86,18 @@
      */
     public void testChangeDatatype2()
     {
-    	Database model = createDatabase(TEST_DATATYPE_MODEL_2);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='SMALLINT' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Short((short)2) });
 
     	model.getTable(0).getColumn(1).setTypeCode(Types.VARCHAR);
     	model.getTable(0).getColumn(1).setSize("20");
@@ -373,6 +108,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)"2", beans.get(0), "avalue");
     }
 
     /**
@@ -380,7 +119,18 @@
      */
     public void testChangeNull()
     {
-    	Database model = createDatabase(TEST_CHANGE_NULL_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
 
     	model.getTable(0).getColumn(1).setRequired(false);
 
@@ -390,6 +140,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue");
     }
 
     /**
@@ -397,7 +151,18 @@
      */
     public void testAddDefault()
     {
-    	Database model = createDatabase(TEST_ADD_DEFAULT_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DOUBLE'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Double(2.0) });
 
     	model.getTable(0).getColumn(1).setDefaultValue("1.0");
 
@@ -407,6 +172,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Double(2.0), beans.get(0), "avalue");
     }
 
     /**
@@ -414,7 +183,18 @@
      */
     public void testChangeDefault()
     {
-    	Database model = createDatabase(TEST_CHANGE_DEFAULT_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' default='1'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
 
     	model.getTable(0).getColumn(1).setDefaultValue("20");
 
@@ -424,6 +204,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue");
     }
 
     /**
@@ -431,7 +215,18 @@
      */
     public void testDropDefault()
     {
-    	Database model = createDatabase(TEST_DROP_DEFAULT_MODEL_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='20' default='test'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
 
     	model.getTable(0).getColumn(1).setDefaultValue(null);
 
@@ -441,6 +236,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)"test", beans.get(0), "avalue");
     }
 
     /**
@@ -448,7 +247,18 @@
      */
     public void testMakeAutoIncrement()
     {
-    	Database model = createDatabase(TEST_MAKE_AUTO_INCREMENT_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
 
     	model.getTable(0).getColumn(1).setAutoIncrement(true);
 
@@ -458,6 +268,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue");
     }
 
     /**
@@ -465,7 +279,18 @@
      */
     public void testDropAutoIncrement()
     {
-    	Database model = createDatabase(TEST_DROP_AUTO_INCREMENT_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' autoIncrement='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
 
     	model.getTable(0).getColumn(1).setAutoIncrement(false);
 
@@ -475,6 +300,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "avalue");
     }
 
     /**
@@ -482,7 +311,17 @@
      */
     public void testAddColumn()
     {
-    	Database model = createDatabase(TEST_ADD_COLUMN_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
 
     	Column newColumn = new Column();
 
@@ -498,6 +337,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue");
     }
 
     /**
@@ -505,7 +348,18 @@
      */
     public void testDropColumn()
     {
-    	Database model = createDatabase(TEST_DROP_COLUMN_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='50'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), "test" });
 
     	model.getTable(0).removeColumn(1);
 
@@ -515,6 +369,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
     }
 
     /**
@@ -522,7 +380,18 @@
      */
     public void testAddColumnToPK()
     {
-    	Database model = createDatabase(TEST_ADD_COLUMN_TO_PK_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='50' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), "test" });
 
     	model.getTable(0).getColumn(1).setPrimaryKey(true);
 
@@ -532,6 +401,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)"test", beans.get(0), "avalue");
     }
 
     /**
@@ -539,7 +412,18 @@
      */
     public void testRemoveColumnFromPK()
     {
-    	Database model = createDatabase(TEST_REMOVE_COLUMN_FROM_PK_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='50' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), "test" });
 
     	model.getTable(0).getColumn(1).setPrimaryKey(false);
 
@@ -549,6 +433,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)"test", beans.get(0), "avalue");
     }
 
     /**
@@ -556,7 +444,17 @@
      */
     public void testAddPKColumn()
     {
-    	Database model = createDatabase(TEST_ADD_PK_COLUMN_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1) });
 
     	Column newColumn = new Column();
 
@@ -564,6 +462,7 @@
     	newColumn.setTypeCode(Types.INTEGER);
     	newColumn.setPrimaryKey(true);
     	newColumn.setRequired(true);
+        newColumn.setDefaultValue("0");
     	model.getTable(0).addColumn(newColumn);
 
     	alterDatabase(model);
@@ -572,14 +471,29 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(0), beans.get(0), "avalue");
     }
 
     /**
-     * Tests the dropping a pk column.
+     * Tests the dropping of a pk column.
      */
     public void testDropPKColumn()
     {
-    	Database model = createDatabase(TEST_DROP_PK_COLUMN_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='50' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), "test" });
 
     	model.getTable(0).removeColumn(1);
 
@@ -589,6 +503,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
     }
 
     /**
@@ -596,7 +514,19 @@
      */
     public void testAddIndex()
     {
-    	Database model = createDatabase(TEST_ADD_INDEX_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='VARCHAR' size='50'/>\n"+
+            "    <column name='avalue2' type='INTEGER' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), null, new Integer(2) });
 
     	Index newIndex = new NonUniqueIndex(); 
     	
@@ -612,6 +542,11 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals((Object)null, beans.get(0), "avalue1");
+        assertEquals(new Integer(2), beans.get(0), "avalue2");
     }
 
     /**
@@ -619,7 +554,18 @@
      */
     public void testAddUniqueIndex()
     {
-    	Database model = createDatabase(TEST_ADD_UNIQUE_INDEX_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Integer(2) });
 
     	Index newIndex = new UniqueIndex(); 
     	
@@ -634,6 +580,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Integer(2), beans.get(0), "avalue");
     }
 
     /**
@@ -641,7 +591,23 @@
      */
     public void testDropUniqueIndex()
     {
-    	Database model = createDatabase(TEST_DROP_UNIQUE_INDEX_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DOUBLE'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='50'/>\n"+
+            "    <unique name='test_index'>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Double(2.0), "test" });
 
     	model.getTable(0).removeIndex(0);
 
@@ -651,6 +617,11 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Double(2.0), beans.get(0), "avalue1");
+        assertEquals((Object)"test", beans.get(0), "avalue2");
     }
 
     /**
@@ -658,7 +629,22 @@
      */
     public void testAddColumnToIndex()
     {
-    	Database model = createDatabase(TEST_ADD_COLUMN_TO_INDEX_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DOUBLE'/>\n"+
+            "    <column name='avalue2' type='VARCHAR' size='40'/>\n"+
+            "    <index name='test_index'>\n"+
+            "      <index-column name='avalue1'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Double(2.0), "test" });
 
     	model.getTable(0).getIndex(0).addColumn(new IndexColumn(model.getTable(0).getColumn(2).getName()));
 
@@ -668,6 +654,11 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Double(2.0), beans.get(0), "avalue1");
+        assertEquals((Object)"test", beans.get(0), "avalue2");
     }
 
     /**
@@ -675,7 +666,23 @@
      */
     public void testRemoveColumnFromUniqueIndex()
     {
-    	Database model = createDatabase(TEST_REMOVE_COLUMN_FROM_UNIQUE_INDEX_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DOUBLE'/>\n"+
+            "    <column name='avalue2' type='INTEGER'/>\n"+
+            "    <unique name='test_index'>\n"+
+            "      <unique-column name='avalue1'/>\n"+
+            "      <unique-column name='avalue2'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip", new Object[] { new Integer(1), new Double(2.0), new Integer(3) });
 
     	model.getTable(0).getIndex(0).removeColumn(1);
 
@@ -685,6 +692,11 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip");
+
+        assertEquals(new Double(2.0), beans.get(0), "avalue1");
+        assertEquals(new Integer(3), beans.get(0), "avalue2");
     }
 
     /**
@@ -692,7 +704,22 @@
      */
     public void testAddFK()
     {
-    	Database model = createDatabase(TEST_ADD_FK_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip1", new Object[] { new Integer(1) });
+        insertRow("roundtrip2", new Object[] { "2", new Integer(1) });
 
     	ForeignKey newFk = new ForeignKey("test");
     	
@@ -706,6 +733,13 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans1 = getRows("roundtrip1");
+        List beans2 = getRows("roundtrip2");
+
+        assertEquals(new Integer(1), beans1.get(0), "pk");
+        assertEquals((Object)"2", beans2.get(0), "pk");
+        assertEquals(new Integer(1), beans2.get(0), "avalue");
     }
 
     /**
@@ -713,7 +747,28 @@
      */
     public void testDropFK()
     {
-    	Database model = createDatabase(TEST_DROP_FK_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk2' type='DOUBLE' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='DOUBLE' required='true'/>\n"+
+            "    <column name='avalue2' type='INTEGER' required='true'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='avalue2' foreign='pk1'/>\n"+
+            "      <reference local='avalue1' foreign='pk2'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip1", new Object[] { new Integer(1), new Double(2.0) });
+        insertRow("roundtrip2", new Object[] { new Integer(2), new Double(2.0), new Integer(1) });
 
     	model.getTable(1).removeForeignKey(0);
 
@@ -723,6 +778,15 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans1 = getRows("roundtrip1");
+        List beans2 = getRows("roundtrip2");
+
+        assertEquals(new Integer(1), beans1.get(0), "pk1");
+        assertEquals(new Double(2.0), beans1.get(0), "pk2");
+        assertEquals(new Integer(2), beans2.get(0), "pk");
+        assertEquals(new Double(2.0), beans2.get(0), "avalue1");
+        assertEquals(new Integer(1), beans2.get(0), "avalue2");
     }
 
     /**
@@ -730,7 +794,25 @@
      */
     public void testAddReferenceToFK()
     {
-    	Database model = createDatabase(TEST_ADD_REFERENCE_TO_FK_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='INTEGER' required='true'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='avalue1' foreign='pk1'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip1", new Object[] { new Integer(1) });
+        insertRow("roundtrip2", new Object[] { new Integer(2), new Integer(1) });
 
     	Column newPkColumn = new Column();
 
@@ -738,6 +820,7 @@
     	newPkColumn.setTypeCode(Types.DOUBLE);
     	newPkColumn.setPrimaryKey(true);
     	newPkColumn.setRequired(true);
+        newPkColumn.setDefaultValue("0.0");
     	model.getTable(0).addColumn(newPkColumn);
 
     	Column newFkColumn = new Column();
@@ -745,6 +828,7 @@
     	newFkColumn.setName("avalue2");
     	newFkColumn.setTypeCode(Types.DOUBLE);
     	newFkColumn.setRequired(true);
+        newFkColumn.setDefaultValue("0.0");
     	model.getTable(1).addColumn(newFkColumn);
 
     	model.getTable(1).getForeignKey(0).addReference(new Reference(newFkColumn, newPkColumn));
@@ -755,6 +839,15 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans1 = getRows("roundtrip1");
+        List beans2 = getRows("roundtrip2");
+
+        assertEquals(new Integer(1), beans1.get(0), "pk1");
+        assertEquals(new Double(0.0), beans1.get(0), "pk2");
+        assertEquals(new Integer(2), beans2.get(0), "pk");
+        assertEquals(new Integer(1), beans2.get(0), "avalue1");
+        assertEquals(new Double(0.0), beans2.get(0), "avalue2");
     }
 
     /**
@@ -762,7 +855,28 @@
      */
     public void testRemoveReferenceFromFK()
     {
-    	Database model = createDatabase(TEST_REMOVE_REFERENCE_FROM_FK_MODEL);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk2' type='VARCHAR' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue1' type='VARCHAR' required='true'/>\n"+
+            "    <column name='avalue2' type='INTEGER' required='true'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='avalue2' foreign='pk1'/>\n"+
+            "      <reference local='avalue1' foreign='pk2'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip1", new Object[] { new Integer(1), "test" });
+        insertRow("roundtrip2", new Object[] { new Integer(2), "test", new Integer(1) });
 
     	model.getTable(0).removeColumn(1);
     	model.getTable(1).removeColumn(1);
@@ -774,6 +888,13 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans1 = getRows("roundtrip1");
+        List beans2 = getRows("roundtrip2");
+
+        assertEquals(new Integer(1), beans1.get(0), "pk1");
+        assertEquals(new Integer(2), beans2.get(0), "pk");
+        assertEquals(new Integer(1), beans2.get(0), "avalue2");
     }
 
     /**
@@ -781,7 +902,17 @@
      */
     public void testAddTable1()
     {
-    	Database model = createDatabase(TEST_ADD_TABLE_MODEL_1);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+           "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip1", new Object[] { new Integer(1) });
 
     	Table      newTable    = new Table();
     	Column     newPkColumn = new Column();
@@ -809,6 +940,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip1");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
     }
 
     /**
@@ -816,7 +951,18 @@
      */
     public void testAddTable2()
     {
-    	Database model = createDatabase(TEST_ADD_TABLE_MODEL_2);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='32' required='true'/>\n"+
+            "  </table>\n"+
+           "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip1", new Object[] { new Integer(1), "test" });
 
     	Table  newTable    = new Table();
     	Column newPkColumn = new Column();
@@ -830,7 +976,14 @@
     	newTable.addColumn(newPkColumn);
     	model.addTable(newTable);
 
-    	ForeignKey newFk = new ForeignKey("test");
+        alterDatabase(model);
+
+        // note that we have to split the alteration because we can only add the foreign key if
+        // there is a corresponding row in the new table
+
+        insertRow("roundtrip2", new Object[] { "test" });
+        
+        ForeignKey newFk = new ForeignKey("test");
 
     	newFk.setForeignTable(newTable);
     	newFk.addReference(new Reference(model.getTable(0).getColumn(1), newPkColumn));
@@ -842,6 +995,13 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans1 = getRows("roundtrip1");
+        List beans2 = getRows("roundtrip2");
+
+        assertEquals(new Integer(1), beans1.get(0), "pk");
+        assertEquals((Object)"test", beans1.get(0), "avalue");
+        assertEquals((Object)"test", beans2.get(0), "pk");
     }
 
     /**
@@ -849,7 +1009,22 @@
      */
     public void testRemoveTable1()
     {
-    	Database model = createDatabase(TEST_REMOVE_TABLE_1);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DOUBLE' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip1", new Object[] { new Integer(1) });
+        insertRow("roundtrip2", new Object[] { new Integer(2), new Double(2.0) });
 
     	model.removeTable(1);
 
@@ -859,6 +1034,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip1");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
     }
 
     /**
@@ -866,7 +1045,25 @@
      */
     public void testRemoveTable2()
     {
-    	Database model = createDatabase(TEST_REMOVE_TABLE_2);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip1'>\n"+
+            "    <column name='pk' type='VARCHAR' size='20' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip2'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='VARCHAR' size='20' required='true'/>\n"+
+            "    <foreign-key foreignTable='roundtrip1'>\n"+
+            "      <reference local='avalue' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database model = createDatabase(modelXml);
+
+        insertRow("roundtrip1", new Object[] { "test" });
+        insertRow("roundtrip2", new Object[] { new Integer(1), "test" });
 
     	model.getTable(1).removeForeignKey(0);
     	model.removeTable(0);
@@ -877,5 +1074,10 @@
 
         assertEquals(getAdjustedModel(),
         		     modelFromDb);
+
+        List beans = getRows("roundtrip2");
+
+        assertEquals(new Integer(1), beans.get(0), "pk");
+        assertEquals((Object)"test", beans.get(0), "avalue");
     }
 }



Mime
View raw message