db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r418870 - in /db/ddlutils/trunk/src/test/org/apache/ddlutils: dynabean/TestDynaSqlQueries.java io/TestAlteration.java io/TestConstraints.java
Date Mon, 03 Jul 2006 23:20:18 GMT
Author: tomdz
Date: Mon Jul  3 16:20:18 2006
New Revision: 418870

URL: http://svn.apache.org/viewvc?rev=418870&view=rev
Log:
Changed tests to handle the limitations of Sybase

Modified:
    db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestConstraints.java

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java?rev=418870&r1=418869&r2=418870&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java Mon Jul
 3 16:20:18 2006
@@ -22,6 +22,7 @@
 import org.apache.ddlutils.TestDatabaseWriterBase;
 import org.apache.ddlutils.model.Table;
 import org.apache.ddlutils.platform.ModelBasedResultSetIterator;
+import org.apache.ddlutils.platform.sybase.SybasePlatform;
 
 /**
  * Tests the sql querying.
@@ -155,14 +156,31 @@
      */
     public void testAutoIncrement() throws Exception
     {
-        createDatabase(
-            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-            "<database name='ddlutils'>\n"+
-            "  <table name='TestTable'>\n"+
-            "    <column name='TheId' type='INTEGER' primaryKey='true' required='true'
autoIncrement='true'/>\n"+
-            "    <column name='TheText' type='VARCHAR' size='15'/>\n"+
-            "  </table>\n"+
-            "</database>");
+        // we need special catering for Sybase which does not support identity for INTEGER
columns
+        final String modelXml; 
+
+        if (SybasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            modelXml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                       "<database name='ddlutils'>\n"+
+                       "  <table name='TestTable'>\n"+
+                       "    <column name='TheId' type='NUMERIC' size='12,0' primaryKey='true'
required='true' autoIncrement='true'/>\n"+
+                       "    <column name='TheText' type='VARCHAR' size='15'/>\n"+
+                       "  </table>\n"+
+                       "</database>";
+        }
+        else
+        {
+            modelXml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                       "<database name='ddlutils'>\n"+
+                       "  <table name='TestTable'>\n"+
+                       "    <column name='TheId' type='INTEGER' primaryKey='true' required='true'
autoIncrement='true'/>\n"+
+                       "    <column name='TheText' type='VARCHAR' size='15'/>\n"+
+                       "  </table>\n"+
+                       "</database>";
+        }
+
+        createDatabase(modelXml);
 
         // we're inserting the rows manually via beans since we do want to
         // check the back-reading of the auto-increment columns

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAlteration.java?rev=418870&r1=418869&r2=418870&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 Mon Jul  3 16:20:18
2006
@@ -16,12 +16,14 @@
  * limitations under the License.
  */
 
+import java.math.BigDecimal;
 import java.util.List;
 
-import org.apache.commons.beanutils.DynaBean;
-
 import junit.framework.Test;
 
+import org.apache.commons.beanutils.DynaBean;
+import org.apache.ddlutils.platform.sybase.SybasePlatform;
+
 /**
  * Performs tests for the alteration of databases.
  * 
@@ -339,8 +341,9 @@
         {
             return;
         }
-        
-        final String model1Xml = 
+
+        boolean isSybase  = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
+        String  model1Xml = 
             "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
             "<database name='roundtriptest'>\n"+
             "  <table name='roundtrip'>\n"+
@@ -348,17 +351,31 @@
             "    <column name='avalue' type='INTEGER'/>\n"+
             "  </table>\n"+
             "</database>";
+        String model2Xml;
+
         // since some databases require/automatically make the column required
         // we also make the column required in order to avoid problems when
         // comparing the model from the live database with our assumed one
-        final String model2Xml = 
-            "<?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' required='true'/>\n"+
-            "  </table>\n"+
-            "</database>";
+        if (isSybase)
+        {
+            model2Xml = "<?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='NUMERIC' size='12,0' autoIncrement='true'
required='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+        else
+        {
+            model2Xml = "<?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'
required='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
 
         createDatabase(model1Xml);
 
@@ -371,7 +388,14 @@
 
         List beans = getRows("roundtrip");
 
-        assertEquals(new Integer(2), beans.get(0), "avalue");
+        if (isSybase)
+        {
+            assertEquals(new BigDecimal(2), beans.get(0), "avalue");
+        }
+        else
+        {
+            assertEquals(new Integer(2), beans.get(0), "avalue");
+        }
     }
 
     /**
@@ -383,23 +407,45 @@
         {
             return;
         }
-        
-        final String model1Xml = 
-            "<?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>";
-        final String model2Xml = 
-            "<?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='false'/>\n"+
-            "  </table>\n"+
-            "</database>";
+
+        boolean isSybase = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
+        String  model1Xml; 
+        String  model2Xml;
+
+        if (isSybase)
+        {
+            model1Xml = "<?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='NUMERIC' size='12,0' required='true'
autoIncrement='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+            model2Xml = "<?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='NUMERIC' size='12,0' required='true'
autoIncrement='false'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+        else
+        {
+            model1Xml = "<?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>";
+            model2Xml = "<?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='false'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
 
         createDatabase(model1Xml);
 
@@ -412,7 +458,14 @@
 
         List beans = getRows("roundtrip");
 
-        assertEquals(new Integer(1), beans.get(0), "avalue");
+        if (isSybase)
+        {
+            assertEquals(new BigDecimal(1), beans.get(0), "avalue");
+        }
+        else
+        {
+            assertEquals(new Integer(1), beans.get(0), "avalue");
+        }
     }
 
     /**
@@ -460,21 +513,37 @@
     		return;
     	}
 
-    	final String model1Xml = 
+        // we need special catering for Sybase which does not support identity for INTEGER
columns
+        boolean isSybase  = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
+        String  model1Xml = 
             "<?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>";
-        final String model2Xml = 
-            "<?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' required='true'/>\n"+
-            "  </table>\n"+
-            "</database>";
+        String model2Xml;
+
+        if (isSybase)
+        {
+            model2Xml = "<?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='NUMERIC' size='12,0' autoIncrement='true'
required='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+        else
+        {
+            model2Xml = "<?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'
required='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
 
         createDatabase(model1Xml);
 
@@ -487,7 +556,14 @@
 
         List beans = getRows("roundtrip");
 
-        assertEquals(new Integer(1), beans.get(0), "avalue");
+        if (isSybase)
+        {
+            assertEquals(new BigDecimal(1), beans.get(0), "avalue");
+        }
+        else
+        {
+            assertEquals(new Integer(1), beans.get(0), "avalue");
+        }
     }
 
     /**
@@ -750,22 +826,37 @@
             return;
         }
 
-        final String model1Xml = 
-            "<?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>";
-        final String model2Xml = 
+        boolean isSybase = SybasePlatform.DATABASENAME.equals(getPlatform().getName());
+        String model2Xml = 
             "<?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>";
+        String model1Xml; 
 
+        if (isSybase)
+        {
+            model1Xml = "<?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='NUMERIC' size='12,0' required='true'
autoIncrement='true'/>\n"+
+                        "  </table>\n"+
+                        "</database>";
+        }
+        else
+        {
+            model1Xml = "<?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>";
+        }
+        
         createDatabase(model1Xml);
 
         insertRow("roundtrip", new Object[] { new Integer(1) });

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestConstraints.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestConstraints.java?rev=418870&r1=418869&r2=418870&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestConstraints.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestConstraints.java Mon Jul  3 16:20:18
2006
@@ -17,6 +17,7 @@
  */
 
 import org.apache.ddlutils.model.Database;
+import org.apache.ddlutils.platform.sybase.SybasePlatform;
 
 import junit.framework.Test;
 
@@ -28,154 +29,6 @@
  */
 public class TestConstraints extends RoundtripTestBase
 {
-    /** Test model with a nullable column. */
-    protected static final String TEST_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='false'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with a not-nullable column. */
-    protected static final String TEST_NOT_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='VARCHAR' required='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with a auto-increment INTEGER column. */
-    protected static final String TEST_AUTO_INCREMENT_INTEGER_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' autoIncrement='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with a auto-increment DOUBLE column. */
-    protected static final String TEST_AUTO_INCREMENT_DOUBLE_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' required='true' autoIncrement='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with a auto-increment primary key column. */
-    protected static final String TEST_PRIMARY_KEY_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' autoIncrement='true'/>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with a simple index. */
-    protected static final String TEST_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='DOUBLE'/>\n"+
-        "    <index name='TEST_INDEX'>\n"+
-        "      <index-column name='avalue'/>\n"+
-        "    </index>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with an unique index with two columns. */
-    protected static final String TEST_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='value_1' type='DOUBLE'/>\n"+
-        "    <column name='value_2' type='VARCHAR' size='32'/>\n"+
-        "    <unique name='test_index'>\n"+
-        "      <unique-column name='value_2'/>\n"+
-        "      <unique-column name='value_1'/>\n"+
-        "    </unique>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with an index with two columns, one of which a pk field. */
-    protected static final String TEST_PRIMARY_KEY_INDEX_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip'>\n"+
-        "    <column name='pk_1' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='pk_2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='DOUBLE'/>\n"+
-        "    <index name='test_index'>\n"+
-        "      <index-column name='avalue'/>\n"+
-        "      <index-column name='pk_1'/>\n"+
-        "    </index>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with two tables and a simple foreign key relationship between them. */
-    protected static final String TEST_SIMPLE_FOREIGN_KEY_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip_1'>\n"+
-        "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "  <table name='roundtrip_2'>\n"+
-        "    <column name='pk' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
-        "    <column name='avalue' type='INTEGER' required='true'/>\n"+
-        "    <foreign-key foreignTable='roundtrip_1'>\n"+
-        "      <reference local='avalue' foreign='pk'/>\n"+
-        "    </foreign-key>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with two tables and overlapping foreign keys between them. */
-    protected static final String TEST_OVERLAPPING_FOREIGN_KEYS_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip_1'>\n"+
-        "    <column name='pk_1' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='pk_2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
-        "  </table>\n"+
-        "  <table name='roundtrip_2'>\n"+
-        "    <column name='pk' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
-        "    <column name='value_1' type='INTEGER' required='true'/>\n"+
-        "    <column name='value_2' type='INTEGER'/>\n"+
-        "    <column name='value_3' type='VARCHAR' size='32'/>\n"+
-        "    <foreign-key name='fk_1' foreignTable='roundtrip_1'>\n"+
-        "      <reference local='value_1' foreign='pk_1'/>\n"+
-        "      <reference local='value_3' foreign='pk_2'/>\n"+
-        "    </foreign-key>\n"+
-        "    <foreign-key foreignTable='roundtrip_1'>\n"+
-        "      <reference local='value_2' foreign='pk_1'/>\n"+
-        "      <reference local='value_3' foreign='pk_2'/>\n"+
-        "    </foreign-key>\n"+
-        "  </table>\n"+
-        "</database>";
-    /** Test model with two tables and circular foreign key relationships between them. */
-    protected static final String TEST_CIRCULAR_FOREIGN_KEYS_MODEL = 
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='roundtriptest'>\n"+
-        "  <table name='roundtrip_1'>\n"+
-        "    <column name='pk_1' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='pk_2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
-        "    <column name='value_1' type='INTEGER'/>\n"+
-        "    <column name='value_2' type='VARCHAR' size='32'/>\n"+
-        "    <foreign-key foreignTable='roundtrip_2'>\n"+
-        "      <reference local='value_1' foreign='pk_1'/>\n"+
-        "      <reference local='value_2' foreign='pk_2'/>\n"+
-        "    </foreign-key>\n"+
-        "  </table>\n"+
-        "  <table name='roundtrip_2'>\n"+
-        "    <column name='pk_1' type='INTEGER' primaryKey='true' required='true'/>\n"+
-        "    <column name='pk_2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
-        "    <column name='value_1' type='VARCHAR' size='32' required='true'/>\n"+
-        "    <column name='value_2' type='INTEGER' required='true'/>\n"+
-        "    <foreign-key foreignTable='roundtrip_1'>\n"+
-        "      <reference local='value_2' foreign='pk_1'/>\n"+
-        "      <reference local='value_1' foreign='pk_2'/>\n"+
-        "    </foreign-key>\n"+
-        "  </table>\n"+
-        "</database>";
-
     /**
      * Parameterized test case pattern.
      * 
@@ -218,7 +71,16 @@
      */
     public void testNullableColumn()
     {
-        performConstraintsTest(TEST_NULL_MODEL, true);
+        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>";
+
+        performConstraintsTest(modelXml, true);
     }
 
     /**
@@ -226,7 +88,16 @@
      */
     public void testNotNullableColumn()
     {
-        performConstraintsTest(TEST_NOT_NULL_MODEL, true);
+        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' required='true'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        performConstraintsTest(modelXml, true);
     }
 
     /**
@@ -235,11 +106,37 @@
     public void testAutoIncrementIntegerColumn()
     {
         // only test this if the platform supports it
-        if (getPlatformInfo().isNonPKIdentityColumnsSupported())
+        if (!getPlatformInfo().isNonPKIdentityColumnsSupported())
+        {
+            return;
+        }
+
+        // we need special catering for Sybase which does not support identity for INTEGER
columns
+        final String modelXml; 
+
+        if (SybasePlatform.DATABASENAME.equals(getPlatform().getName()))
         {
-            performConstraintsTest(TEST_AUTO_INCREMENT_INTEGER_MODEL,
-            		               getPlatformInfo().getIdentityStatusReadingSupported());
+            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='NUMERIC' size='12,0' required='true'
autoIncrement='true'/>\n"+
+                       "  </table>\n"+
+                       "</database>";
         }
+        else
+        {
+            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' autoIncrement='true'/>\n"+
+                       "  </table>\n"+
+                       "</database>";
+        }
+
+        performConstraintsTest(modelXml,
+                               getPlatformInfo().getIdentityStatusReadingSupported());
     }
 
     /**
@@ -247,7 +144,29 @@
      */
     public void testPrimaryKeyAutoIncrementColumn()
     {
-        performConstraintsTest(TEST_PRIMARY_KEY_AUTO_INCREMENT_MODEL,
+        // we need special catering for Sybase which does not support identity for INTEGER
columns
+        final String modelXml; 
+
+        if (SybasePlatform.DATABASENAME.equals(getPlatform().getName()))
+        {
+            modelXml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+                       "<database name='roundtriptest'>\n"+
+                       "  <table name='roundtrip'>\n"+
+                       "    <column name='pk' type='NUMERIC' size='12,0' primaryKey='true'
required='true' autoIncrement='true'/>\n"+
+                       "  </table>\n"+
+                       "</database>";
+        }
+        else
+        {
+            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'
autoIncrement='true'/>\n"+
+                       "  </table>\n"+
+                       "</database>";
+        }
+
+        performConstraintsTest(modelXml,
 	                           getPlatformInfo().getIdentityStatusReadingSupported());
     }
 
@@ -256,10 +175,24 @@
      */
     public void testIndex()
     {
-        if (getPlatformInfo().isIndicesSupported())
+        if (!getPlatformInfo().isIndicesSupported())
         {
-            performConstraintsTest(TEST_INDEX_MODEL, true);
+            return;
         }
+
+        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"+
+            "    <index name='TEST_INDEX'>\n"+
+            "      <index-column name='avalue'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        performConstraintsTest(modelXml, true);
     }
 
     /**
@@ -267,10 +200,26 @@
      */
     public void testUniqueIndex()
     {
-        if (getPlatformInfo().isIndicesSupported())
+        if (!getPlatformInfo().isIndicesSupported())
         {
-            performConstraintsTest(TEST_UNIQUE_INDEX_MODEL, true);
+            return;
         }
+
+        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='value_1' type='DOUBLE'/>\n"+
+            "    <column name='value_2' type='VARCHAR' size='32'/>\n"+
+            "    <unique name='test_index'>\n"+
+            "      <unique-column name='value_2'/>\n"+
+            "      <unique-column name='value_1'/>\n"+
+            "    </unique>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        performConstraintsTest(modelXml, true);
     }
 
     /**
@@ -278,10 +227,26 @@
      */
     public void testPrimaryKeyIndex()
     {
-        if (getPlatformInfo().isIndicesSupported())
+        if (!getPlatformInfo().isIndicesSupported())
         {
-            performConstraintsTest(TEST_PRIMARY_KEY_INDEX_MODEL, true);
+            return;
         }
+
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip'>\n"+
+            "    <column name='pk_1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk_2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='DOUBLE'/>\n"+
+            "    <index name='test_index'>\n"+
+            "      <index-column name='avalue'/>\n"+
+            "      <index-column name='pk_1'/>\n"+
+            "    </index>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        performConstraintsTest(modelXml, true);
     }
 
     /**
@@ -289,7 +254,22 @@
      */
     public void testSimpleForeignKey()
     {
-        performConstraintsTest(TEST_SIMPLE_FOREIGN_KEY_MODEL, true);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip_1'>\n"+
+            "    <column name='pk' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip_2'>\n"+
+            "    <column name='pk' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='avalue' type='INTEGER' required='true'/>\n"+
+            "    <foreign-key foreignTable='roundtrip_1'>\n"+
+            "      <reference local='avalue' foreign='pk'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        performConstraintsTest(modelXml, true);
     }
 
     /**
@@ -297,7 +277,30 @@
      */
     public void testOverlappingForeignKeys()
     {
-        performConstraintsTest(TEST_OVERLAPPING_FOREIGN_KEYS_MODEL, true);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip_1'>\n"+
+            "    <column name='pk_1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk_2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip_2'>\n"+
+            "    <column name='pk' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='value_1' type='INTEGER' required='true'/>\n"+
+            "    <column name='value_2' type='INTEGER'/>\n"+
+            "    <column name='value_3' type='VARCHAR' size='32'/>\n"+
+            "    <foreign-key name='fk_1' foreignTable='roundtrip_1'>\n"+
+            "      <reference local='value_1' foreign='pk_1'/>\n"+
+            "      <reference local='value_3' foreign='pk_2'/>\n"+
+            "    </foreign-key>\n"+
+            "    <foreign-key foreignTable='roundtrip_1'>\n"+
+            "      <reference local='value_2' foreign='pk_1'/>\n"+
+            "      <reference local='value_3' foreign='pk_2'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        performConstraintsTest(modelXml, true);
     }
 
     /**
@@ -305,6 +308,31 @@
      */
     public void testCircularForeignKeys()
     {
-        performConstraintsTest(TEST_CIRCULAR_FOREIGN_KEYS_MODEL, true);
+        final String modelXml = 
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='roundtriptest'>\n"+
+            "  <table name='roundtrip_1'>\n"+
+            "    <column name='pk_1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk_2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='value_1' type='INTEGER'/>\n"+
+            "    <column name='value_2' type='VARCHAR' size='32'/>\n"+
+            "    <foreign-key foreignTable='roundtrip_2'>\n"+
+            "      <reference local='value_1' foreign='pk_1'/>\n"+
+            "      <reference local='value_2' foreign='pk_2'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "  <table name='roundtrip_2'>\n"+
+            "    <column name='pk_1' type='INTEGER' primaryKey='true' required='true'/>\n"+
+            "    <column name='pk_2' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"+
+            "    <column name='value_1' type='VARCHAR' size='32' required='true'/>\n"+
+            "    <column name='value_2' type='INTEGER' required='true'/>\n"+
+            "    <foreign-key foreignTable='roundtrip_1'>\n"+
+            "      <reference local='value_2' foreign='pk_1'/>\n"+
+            "      <reference local='value_1' foreign='pk_2'/>\n"+
+            "    </foreign-key>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        performConstraintsTest(modelXml, true);
     }
 }



Mime
View raw message