db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r630717 [3/3] - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/alteration/ java/org/apache/ddlutils/dynabean/ java/org/apache/ddlutils/io/ java/org/apache/ddlutils/io/converters/ java/org/apache/ddlutils/model/ java/org/apache/ddlutils...
Date Mon, 25 Feb 2008 02:18:05 GMT
Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java Sun Feb
24 18:17:57 2008
@@ -35,16 +35,6 @@
  */
 public class TestMSSqlPlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n"
+
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -58,7 +48,7 @@
      */
     public void testColumnTypes() throws Exception
     {
-        String sql = createTestDatabase(COLUMN_TEST_SCHEMA);
+        String sql = getColumnTestDatabaseCreationSql();
 
         // Since we have no way of knowing the auto-generated variables in the SQL,
         // we simply try to extract it from the SQL
@@ -136,7 +126,7 @@
      */
     public void testColumnConstraints() throws Exception
     {
-        String sql = createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA);
+        String sql = getConstraintTestDatabaseCreationSql();
 
         // Since we have no way of knowing the auto-generated variables in the SQL,
         // we simply try to extract it from the SQL
@@ -190,7 +180,7 @@
      */
     public void testTableConstraints() throws Exception
     {
-        String sql = createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA);
+        String sql = getTableConstraintTestDatabaseCreationSql();
 
         // Since we have no way of knowing the auto-generated variables in the SQL,
         // we simply try to extract it from the SQL
@@ -303,11 +293,11 @@
     }
 
     /**
-     * Tests the proper escaping of character sequences where Cloudscape requires it.
+     * Tests the proper escaping of character sequences where Sql Server requires it.
      */
     public void testCharacterEscaping() throws Exception
     {
-        String sql = createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE);
+        String sql = getCharEscapingTestDatabaseCreationSql();
 
         // Since we have no way of knowing the auto-generated variables in the SQL,
         // we simply try to extract it from the SQL

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java Sun Feb
24 18:17:57 2008
@@ -78,7 +78,7 @@
             "    \"COL_VARBINARY\"       VARCHAR(15) BYTE,\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -98,7 +98,7 @@
             "    \"COL_AUTO_INCR\"        FIXED(38,0) DEFAULT SERIAL(1),\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -138,7 +138,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_COL_FK_2_table1\" FOREIGN
KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES
\"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -154,6 +154,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(TestSapDbPlatform.COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java Sun Feb
24 18:17:57 2008
@@ -29,52 +29,6 @@
  */
 public class TestMcKoiPlatform extends TestPlatformBase
 {
-    /** The database schema for testing table constraints, ie. foreign keys and indices.
-        This schema is adapted for McKoi which does not support non-unique indices. */
-    public static final String TABLE_CONSTRAINT_TEST_SCHEMA =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='tableconstraintstest'>\n" +
-        "  <table name='table1'>\n" +
-        "    <column name='COL_PK_1' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"
+
-        "    <column name='COL_PK_2' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_INDEX_1' type='BINARY' size='100' required='true'/>\n"
+
-        "    <column name='COL_INDEX_2' type='DOUBLE' required='true'/>\n" +
-        "    <column name='COL_INDEX_3' type='CHAR' size='4'/>\n" +
-        "    <unique name='testindex1'>\n" +
-        "      <unique-column name='COL_INDEX_2'/>\n" +
-        "    </unique>\n" +
-        "    <unique name='testindex2'>\n" +
-        "      <unique-column name='COL_INDEX_3'/>\n" +
-        "      <unique-column name='COL_INDEX_1'/>\n" +
-        "    </unique>\n" +
-        "  </table>\n" +
-        "  <table name='table2'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_FK_1' type='INTEGER'/>\n" +
-        "    <column name='COL_FK_2' type='VARCHAR' size='32' required='true'/>\n"
+
-        "    <foreign-key foreignTable='table1'>\n" +
-        "      <reference local='COL_FK_1' foreign='COL_PK_2'/>\n" +
-        "      <reference local='COL_FK_2' foreign='COL_PK_1'/>\n" +
-        "    </foreign-key>\n" +
-        "  </table>\n" +
-        "  <table name='table3'>\n" +
-        "    <column name='COL_PK' type='VARCHAR' size='16' primaryKey='true'/>\n"
+
-        "    <column name='COL_FK' type='INTEGER' required='true'/>\n" +
-        "    <foreign-key name='testfk' foreignTable='table2'>\n" +
-        "      <reference local='COL_FK' foreign='COL_PK'/>\n" +
-        "    </foreign-key>\n" +
-        "  </table>\n" +
-        "</database>";
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39; \\'/>\n"
+
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -124,7 +78,7 @@
             "    \"COL_VARBINARY\"       VARBINARY(15),\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -150,7 +104,7 @@
             "    \"COL_AUTO_INCR\"        BIGINT DEFAULT NEXTVAL('seq_constraints_COL_AUTO_INCR'),\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -158,6 +112,43 @@
      */
     public void testTableConstraints() throws Exception
     {
+        // The database schema for testing table constraints, ie. foreign keys and indices.
+        // This schema is adapted for McKoi which does not support non-unique indices
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='tableconstraintstest'>\n" +
+            "  <table name='table1'>\n" +
+            "    <column name='COL_PK_1' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n"
+
+            "    <column name='COL_PK_2' type='INTEGER' primaryKey='true'/>\n" +
+            "    <column name='COL_INDEX_1' type='BINARY' size='100' required='true'/>\n"
+
+            "    <column name='COL_INDEX_2' type='DOUBLE' required='true'/>\n" +
+            "    <column name='COL_INDEX_3' type='CHAR' size='4'/>\n" +
+            "    <unique name='testindex1'>\n" +
+            "      <unique-column name='COL_INDEX_2'/>\n" +
+            "    </unique>\n" +
+            "    <unique name='testindex2'>\n" +
+            "      <unique-column name='COL_INDEX_3'/>\n" +
+            "      <unique-column name='COL_INDEX_1'/>\n" +
+            "    </unique>\n" +
+            "  </table>\n" +
+            "  <table name='table2'>\n" +
+            "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+            "    <column name='COL_FK_1' type='INTEGER'/>\n" +
+            "    <column name='COL_FK_2' type='VARCHAR' size='32' required='true'/>\n"
+
+            "    <foreign-key foreignTable='table1'>\n" +
+            "      <reference local='COL_FK_1' foreign='COL_PK_2'/>\n" +
+            "      <reference local='COL_FK_2' foreign='COL_PK_1'/>\n" +
+            "    </foreign-key>\n" +
+            "  </table>\n" +
+            "  <table name='table3'>\n" +
+            "    <column name='COL_PK' type='VARCHAR' size='16' primaryKey='true'/>\n"
+
+            "    <column name='COL_FK' type='INTEGER' required='true'/>\n" +
+            "    <foreign-key name='testfk' foreignTable='table2'>\n" +
+            "      <reference local='COL_FK' foreign='COL_PK'/>\n" +
+            "    </foreign-key>\n" +
+            "  </table>\n" +
+            "</database>";
+
         assertEqualsIgnoringWhitespaces(
             "ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+
             "ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\";\n"+
@@ -188,7 +179,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\"
FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES
\"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getDatabaseCreationSql(schema));
     }
 
     /**
@@ -196,6 +187,16 @@
      */
     public void testCharacterEscaping() throws Exception
     {
+        // McKoi-specific schema
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='escapetest'>\n" +
+            "  <table name='escapedcharacters'>\n" +
+            "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+            "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;
\\'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
         assertEqualsIgnoringWhitespaces(
             "DROP TABLE IF EXISTS \"escapedcharacters\";\n"+
             "CREATE TABLE \"escapedcharacters\"\n"+
@@ -204,6 +205,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\\\' \\\\',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getDatabaseCreationSql(schema));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java Sun Feb
24 18:17:57 2008
@@ -78,7 +78,7 @@
             "    `COL_VARBINARY`       VARBINARY(15) NULL,\n"+
             "    `COL_VARCHAR`         VARCHAR(15) NULL\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -86,12 +86,19 @@
      */
     public void testColumnConstraints() throws Exception
     {
-        Database           testDb = parseDatabaseFromString(COLUMN_CONSTRAINT_TEST_SCHEMA);
-        testDb.findTable("constraints").findColumn("COL_AUTO_INCR").setAutoIncrement(false);
-        testDb.findTable("constraints").findColumn("COL_PK_AUTO_INCR").setAutoIncrement(false);
-
-        getPlatform().setSqlCommentsOn(false);
-        getPlatform().getSqlBuilder().createTables(testDb, true);
+        // MySql-specfic schema
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='columnconstraintstest'>\n" +
+            "  <table name='constraints'>\n" +
+            "    <column name='COL_PK' type='VARCHAR' size='32' primaryKey='true'/>\n"
+
+            "    <column name='COL_PK_AUTO_INCR' type='INTEGER' primaryKey='true'/>\n"
+
+            "    <column name='COL_NOT_NULL' type='BINARY' size='100' required='true'/>\n"
+
+            "    <column name='COL_NOT_NULL_DEFAULT' type='DOUBLE' required='true' default='-2.0'/>\n"
+
+            "    <column name='COL_DEFAULT' type='CHAR' size='4' default='test'/>\n"
+
+            "    <column name='COL_AUTO_INCR' type='BIGINT'/>\n" +
+            "  </table>\n" +
+            "</database>";
 
         assertEqualsIgnoringWhitespaces(
             "DROP TABLE IF EXISTS `constraints`;\n" +
@@ -105,7 +112,7 @@
             "    `COL_AUTO_INCR`        BIGINT,\n"+
             "    PRIMARY KEY (`COL_PK`, `COL_PK_AUTO_INCR`)\n"+
             ");\n",
-            getBuilderOutput());
+            getDatabaseCreationSql(schema));
     }
 
     /**
@@ -145,7 +152,7 @@
             ");\n"+
             "ALTER TABLE `table2` ADD CONSTRAINT `table2_FK_COL_FK_1_COL_FK_2_table1` FOREIGN
KEY (`COL_FK_1`, `COL_FK_2`) REFERENCES `table1` (`COL_PK_2`, `COL_PK_1`);\n"+
             "ALTER TABLE `table3` ADD CONSTRAINT `testfk` FOREIGN KEY (`COL_FK`) REFERENCES
`table2` (`COL_PK`);\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -153,9 +160,21 @@
      */
     public void testCreationParameters1() throws Exception
     {
-        Database           testDb = parseDatabaseFromString(COLUMN_CONSTRAINT_TEST_SCHEMA);
-        testDb.findTable("constraints").findColumn("COL_AUTO_INCR").setAutoIncrement(false);
-        testDb.findTable("constraints").findColumn("COL_PK_AUTO_INCR").setAutoIncrement(false);
+        // MySql-specfic schema
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='columnconstraintstest'>\n" +
+            "  <table name='constraints'>\n" +
+            "    <column name='COL_PK' type='VARCHAR' size='32' primaryKey='true'/>\n"
+
+            "    <column name='COL_PK_AUTO_INCR' type='INTEGER' primaryKey='true'/>\n"
+
+            "    <column name='COL_NOT_NULL' type='BINARY' size='100' required='true'/>\n"
+
+            "    <column name='COL_NOT_NULL_DEFAULT' type='DOUBLE' required='true' default='-2.0'/>\n"
+
+            "    <column name='COL_DEFAULT' type='CHAR' size='4' default='test'/>\n"
+
+            "    <column name='COL_AUTO_INCR' type='BIGINT'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
+        Database           testDb = parseDatabaseFromString(schema);
         CreationParameters params = new CreationParameters();
 
         params.addParameter(testDb.getTable(0),
@@ -188,6 +207,16 @@
      */
     public void testCharacterEscaping() throws Exception
     {
+        // MySql-specific schema
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='escapetest'>\n" +
+            "  <table name='escapedcharacters'>\n" +
+            "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+            "    <column name='COL_TEXT' type='VARCHAR' size='128' default='_ &#39;
\" &#10; &#13; &#09; \\ &#37;'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
         assertEqualsIgnoringWhitespaces(
             "DROP TABLE IF EXISTS `escapedcharacters`;\n"+
             "CREATE TABLE `escapedcharacters`\n"+
@@ -196,6 +225,6 @@
             "    `COL_TEXT` VARCHAR(128) DEFAULT '\\_ \\\' \\\" \\n \\r \\t \\\\ \\%' NULL,\n"+
             "    PRIMARY KEY (`COL_PK`)\n"+
             ");\n",
-            createTestDatabase(TestMySqlPlatform.COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getDatabaseCreationSql(schema));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java Sun Feb
24 18:17:57 2008
@@ -30,16 +30,6 @@
  */
 public class TestMySqlPlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='_ &#39; \"
&#10; &#13; &#09; \\ &#37;'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -89,7 +79,7 @@
             "    `COL_VARBINARY`       VARBINARY(15) NULL,\n"+
             "    `COL_VARCHAR`         VARCHAR(15) NULL\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -97,13 +87,20 @@
      */
     public void testColumnConstraints() throws Exception
     {
-        Database testDb = parseDatabaseFromString(COLUMN_CONSTRAINT_TEST_SCHEMA);
-
-        testDb.findTable("constraints").findColumn("COL_AUTO_INCR").setAutoIncrement(false);
-        testDb.findTable("constraints").findColumn("COL_PK_AUTO_INCR").setAutoIncrement(false);
+        // MySql-specfic schema
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='columnconstraintstest'>\n" +
+            "  <table name='constraints'>\n" +
+            "    <column name='COL_PK' type='VARCHAR' size='32' primaryKey='true'/>\n"
+
+            "    <column name='COL_PK_AUTO_INCR' type='INTEGER' primaryKey='true'/>\n"
+
+            "    <column name='COL_NOT_NULL' type='BINARY' size='100' required='true'/>\n"
+
+            "    <column name='COL_NOT_NULL_DEFAULT' type='DOUBLE' required='true' default='-2.0'/>\n"
+
+            "    <column name='COL_DEFAULT' type='CHAR' size='4' default='test'/>\n"
+
+            "    <column name='COL_AUTO_INCR' type='BIGINT'/>\n" +
+            "  </table>\n" +
+            "</database>";
 
-        getPlatform().setSqlCommentsOn(false);
-        getPlatform().getSqlBuilder().createTables(testDb, true);
 
         assertEqualsIgnoringWhitespaces(
             "DROP TABLE IF EXISTS `constraints`;\n" +
@@ -117,7 +114,7 @@
             "    `COL_AUTO_INCR`        BIGINT,\n"+
             "    PRIMARY KEY (`COL_PK`, `COL_PK_AUTO_INCR`)\n"+
             ");\n",
-            getBuilderOutput());
+            getDatabaseCreationSql(schema));
     }
 
     /**
@@ -157,7 +154,7 @@
             ");\n"+
             "ALTER TABLE `table2` ADD CONSTRAINT `table2_FK_COL_FK_1_COL_FK_2_table1` FOREIGN
KEY (`COL_FK_1`, `COL_FK_2`) REFERENCES `table1` (`COL_PK_2`, `COL_PK_1`);\n"+
             "ALTER TABLE `table3` ADD CONSTRAINT `testfk` FOREIGN KEY (`COL_FK`) REFERENCES
`table2` (`COL_PK`);\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -165,11 +162,21 @@
      */
     public void testCreationParameters1() throws Exception
     {
-        Database testDb = parseDatabaseFromString(COLUMN_CONSTRAINT_TEST_SCHEMA);
-
-        testDb.findTable("constraints").findColumn("COL_AUTO_INCR").setAutoIncrement(false);
-        testDb.findTable("constraints").findColumn("COL_PK_AUTO_INCR").setAutoIncrement(false);
+        // MySql-specfic schema
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='columnconstraintstest'>\n" +
+            "  <table name='constraints'>\n" +
+            "    <column name='COL_PK' type='VARCHAR' size='32' primaryKey='true'/>\n"
+
+            "    <column name='COL_PK_AUTO_INCR' type='INTEGER' primaryKey='true'/>\n"
+
+            "    <column name='COL_NOT_NULL' type='BINARY' size='100' required='true'/>\n"
+
+            "    <column name='COL_NOT_NULL_DEFAULT' type='DOUBLE' required='true' default='-2.0'/>\n"
+
+            "    <column name='COL_DEFAULT' type='CHAR' size='4' default='test'/>\n"
+
+            "    <column name='COL_AUTO_INCR' type='BIGINT'/>\n" +
+            "  </table>\n" +
+            "</database>";
 
+        Database           testDb = parseDatabaseFromString(schema);
         CreationParameters params = new CreationParameters();
 
         params.addParameter(testDb.getTable(0),
@@ -202,6 +209,16 @@
      */
     public void testCharacterEscaping() throws Exception
     {
+        // MySql-specific schema
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='escapetest'>\n" +
+            "  <table name='escapedcharacters'>\n" +
+            "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+            "    <column name='COL_TEXT' type='VARCHAR' size='128' default='_ &#39;
\" &#10; &#13; &#09; \\ &#37;'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
         assertEqualsIgnoringWhitespaces(
             "DROP TABLE IF EXISTS `escapedcharacters`;\n"+
             "CREATE TABLE `escapedcharacters`\n"+
@@ -210,6 +227,6 @@
             "    `COL_TEXT` VARCHAR(128) DEFAULT '\\_ \\\' \\\" \\n \\r \\t \\\\ \\%' NULL,\n"+
             "    PRIMARY KEY (`COL_PK`)\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getDatabaseCreationSql(schema));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java Sun Feb
24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestOracle8Platform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n"
+
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -88,7 +78,7 @@
             "    \"COL_VARBINARY\"       RAW(15),\n"+
             "    \"COL_VARCHAR\"         VARCHAR2(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -118,7 +108,7 @@
             "BEGIN SELECT \"seq_constraints_L_PK_AUTO_INCR\".nextval INTO :new.\"COL_PK_AUTO_INCR\"
FROM dual; END;;\n"+
             "CREATE OR REPLACE TRIGGER \"trg_constraints_COL_AUTO_INCR\" BEFORE INSERT ON
\"constraints\" FOR EACH ROW WHEN (new.\"COL_AUTO_INCR\" IS NULL)\n"+
             "BEGIN SELECT \"seq_constraints_COL_AUTO_INCR\".nextval INTO :new.\"COL_AUTO_INCR\"
FROM dual; END;;\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -156,7 +146,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_OL_FK_2_table1\" FOREIGN
KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES
\"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -172,6 +162,6 @@
             "    \"COL_TEXT\" VARCHAR2(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java Sun Feb
24 18:17:57 2008
@@ -78,7 +78,7 @@
             "    \"COL_VARBINARY\"       RAW(15),\n"+
             "    \"COL_VARCHAR\"         VARCHAR2(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -108,7 +108,7 @@
             "BEGIN SELECT \"seq_constraints_L_PK_AUTO_INCR\".nextval INTO :new.\"COL_PK_AUTO_INCR\"
FROM dual; END;;\n"+
             "CREATE OR REPLACE TRIGGER \"trg_constraints_COL_AUTO_INCR\" BEFORE INSERT ON
\"constraints\" FOR EACH ROW WHEN (new.\"COL_AUTO_INCR\" IS NULL)\n"+
             "BEGIN SELECT \"seq_constraints_COL_AUTO_INCR\".nextval INTO :new.\"COL_AUTO_INCR\"
FROM dual; END;;\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -146,7 +146,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_OL_FK_2_table1\" FOREIGN
KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES
\"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -162,6 +162,6 @@
             "    \"COL_TEXT\" VARCHAR2(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(TestOracle8Platform.COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPlatformImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPlatformImplBase.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPlatformImplBase.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPlatformImplBase.java Sun
Feb 24 18:17:57 2008
@@ -22,7 +22,7 @@
 import java.util.Map;
 
 import org.apache.commons.beanutils.DynaBean;
-import org.apache.ddlutils.TestPlatformBase;
+import org.apache.ddlutils.TestBase;
 import org.apache.ddlutils.dynabean.SqlDynaBean;
 import org.apache.ddlutils.dynabean.SqlDynaClass;
 import org.apache.ddlutils.model.Database;
@@ -33,39 +33,23 @@
  * 
  * @version $Revision: 279421 $
  */
-public class TestPlatformImplBase extends TestPlatformBase 
+public class TestPlatformImplBase extends TestBase 
 {
-    /** The tested model. */
-    private static final String TESTED_MODEL =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
-        "<database name='ddlutils'>\n"+
-        "  <table name='TestTable'>\n"+
-        "    <column name='id' autoIncrement='true' type='INTEGER' primaryKey='true'/>\n"+
-        "    <column name='name' type='VARCHAR' size='15'/>\n"+
-        "  </table>\n"+
-        "</database>";
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setUp()
-    {
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected String getDatabaseName()
-    {
-        return null;
-    }
-
     /**
      * Test the toColumnValues method.
      */
     public void testToColumnValues()
     {
-        Database         database = parseDatabaseFromString(TESTED_MODEL);
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
+            "<database name='ddlutils'>\n"+
+            "  <table name='TestTable'>\n"+
+            "    <column name='id' autoIncrement='true' type='INTEGER' primaryKey='true'/>\n"+
+            "    <column name='name' type='VARCHAR' size='15'/>\n"+
+            "  </table>\n"+
+            "</database>";
+
+        Database         database = parseDatabaseFromString(schema);
         PlatformImplBase platform = new TestPlatform();
         Table            table    = database.getTable(0);
         SqlDynaClass     clz      = SqlDynaClass.newInstance(table);

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java Sun
Feb 24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestPostgresqlPlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39; &#09;
&#10; &#13; \\'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -88,7 +78,7 @@
             "    \"COL_VARBINARY\"       BYTEA,\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -112,7 +102,7 @@
             "    \"COL_AUTO_INCR\"        BIGINT UNIQUE DEFAULT nextval('constraints_COL_AUTO_INCR_seq'),\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -152,7 +142,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_COL_FK_2_table1\" FOREIGN
KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES
\"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -160,6 +150,16 @@
      */
     public void testCharacterEscaping() throws Exception
     {
+        // PostgreSql specific database schema for testing escaping of character sequences
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='escapetest'>\n" +
+            "  <table name='escapedcharacters'>\n" +
+            "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+            "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;
&#09; &#10; &#13; \\'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
         assertEqualsIgnoringWhitespaces(
             "DROP TABLE \"escapedcharacters\" CASCADE;\n"+
             "CREATE TABLE \"escapedcharacters\"\n"+
@@ -168,6 +168,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\\\' \\t \\n \\r \\\\',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getDatabaseCreationSql(schema));
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java Sun Feb
24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestSapDbPlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n"
+
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -88,7 +78,7 @@
             "    \"COL_VARBINARY\"       VARCHAR(15) BYTE,\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -108,7 +98,7 @@
             "    \"COL_AUTO_INCR\"        FIXED(38,0) DEFAULT SERIAL(1),\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -148,7 +138,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD FOREIGN KEY \"table2_FK_COL_FK_COL_FK_2_table1\"
(\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD FOREIGN KEY \"testfk\" (\"COL_FK\") REFERENCES \"table2\"
(\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -164,6 +154,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java Sun Feb
24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestSybasePlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n"
+
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -94,7 +84,7 @@
             "    \"COL_VARBINARY\"       VARBINARY(15) NULL,\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15) NULL\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -121,7 +111,7 @@
             "    \"COL_AUTO_INCR\"        DECIMAL(19,0) IDENTITY,\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -181,7 +171,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_L_FK_2_table1\" FOREIGN
KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES
\"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -203,6 +193,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'' NULL,\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }



Mime
View raw message