db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r407556 - /db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java
Date Thu, 18 May 2006 14:18:14 GMT
Author: tomdz
Date: Thu May 18 07:18:13 2006
New Revision: 407556

URL: http://svn.apache.org/viewvc?rev=407556&view=rev
Log:
Enhanced the iterator used in query/fetch

Modified:
    db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java?rev=407556&r1=407555&r2=407556&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java Thu
May 18 07:18:13 2006
@@ -22,6 +22,7 @@
 import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.TestBase;
 import org.apache.ddlutils.model.Database;
+import org.apache.ddlutils.model.Table;
 
 /**
  * Tests the model comparison.
@@ -869,7 +870,6 @@
                      change.getNewPrimaryKeyColumns()[0].getName());
     }
 
-    
     /**
      * Tests the addition a column.
      */
@@ -902,6 +902,50 @@
 
         assertEquals("Col1",
                      change.getNewColumn().getName());
+    }
+
+    /**
+     * Tests the removal of a column.
+     */
+    public void testChangeColumnOrder()
+    {
+        final String MODEL1 = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='test'>\n" +
+            "  <table name='TableA'>\n" +
+            "    <column name='ColPK' type='INTEGER' primaryKey='true' required='true'/>\n"
+
+            "    <column name='Col1' type='DOUBLE'/>\n" +
+            "    <column name='Col2' type='INTEGER' required='true'/>\n" +
+            "    <column name='Col3' type='VARCHAR' size='32'/>\n" +
+            "  </table>\n" +
+            "</database>";
+        final String MODEL2 = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='test'>\n" +
+            "  <table name='TableA'>\n" +
+            "    <column name='ColPK' type='INTEGER' primaryKey='true' required='true'/>\n"
+
+            "    <column name='Col3' type='VARCHAR' size='32'/>\n" +
+            "    <column name='Col2' type='INTEGER' required='true'/>\n" +
+            "    <column name='Col1' type='DOUBLE'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
+        Database model1  = parseDatabaseFromString(MODEL1);
+        Database model2  = parseDatabaseFromString(MODEL2);
+        List     changes = createModelComparator(false).compare(model1, model2);
+
+        assertEquals(1,
+                     changes.size());
+
+        ColumnOrderChange change      = (ColumnOrderChange)changes.get(0);
+        Table             sourceTable = change.getChangedTable();
+
+        assertEquals(3,
+                     change.getNewPosition(sourceTable.getColumn(1)));
+        assertEquals(-1,
+                     change.getNewPosition(sourceTable.getColumn(2)));
+        assertEquals(1,
+                     change.getNewPosition(sourceTable.getColumn(3)));
     }
 
     /**



Mime
View raw message