db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r330991 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/model/Table.java test/org/apache/ddlutils/io/TestDatabaseIO.java
Date Sat, 05 Nov 2005 11:31:09 GMT
Author: mvdb
Date: Sat Nov  5 03:31:01 2005
New Revision: 330991

URL: http://svn.apache.org/viewcvs?rev=330991&view=rev
Log:
Test for intended behaviour of getAutoIncrementColumn().
Also added a test that fails on reading the model, but have to check that behaviour with the
betwxit team.

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatabaseIO.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java?rev=330991&r1=330990&r2=330991&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java Sat Nov  5 03:31:01 2005
@@ -578,7 +578,8 @@
     }
 
     /**
-     * Returns the auto increment columns in this table.
+     * Returns the auto increment columns in this table. If no incrementcolumns
+     * are found, it will return an empty array.
      * 
      * @return The columns
      */

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatabaseIO.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatabaseIO.java?rev=330991&r1=330990&r2=330991&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatabaseIO.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatabaseIO.java Sat Nov  5 03:31:01
2005
@@ -19,6 +19,7 @@
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.sql.Types;
+import java.util.Arrays;
 
 import junit.framework.TestCase;
 
@@ -92,7 +93,7 @@
                      table.getName());
         assertEquals("Some table",
                      table.getDescription());
-        assertNull(table.getAutoIncrementColumn());
+        assertEquals(0, table.getAutoIncrementColumn().length);
         assertEquals(1,
                      table.getColumnCount());
         assertEquals(0,
@@ -163,7 +164,7 @@
                      someTable.getName());
         assertEquals("Some table",
                      someTable.getDescription());
-        assertNull(someTable.getAutoIncrementColumn());
+        assertEquals(0, someTable.getAutoIncrementColumn().length);
         assertEquals(1,
                      someTable.getColumnCount());
         assertEquals(0,
@@ -194,7 +195,7 @@
                      anotherTable.getName());
         assertEquals("And another table",
                      anotherTable.getDescription());
-        assertNull(anotherTable.getAutoIncrementColumn());
+        assertEquals(0, anotherTable.getAutoIncrementColumn().length);
         assertEquals(1,
                      anotherTable.getColumnCount());
         assertEquals(1,
@@ -292,7 +293,7 @@
         assertEquals("TableWidthIndex",
                      table.getName());
         assertNull(table.getDescription());
-        assertNull(table.getAutoIncrementColumn());
+        assertEquals(0, table.getAutoIncrementColumn().length);
         assertEquals(3,
                      table.getColumnCount());
         assertEquals(0,
@@ -450,9 +451,9 @@
         assertNull(column.getDefaultValue());
         assertNull(column.getDefaultValue());
         assertNull(column.getDescription());
-
-        assertEquals(column,
-                     table.getAutoIncrementColumn());
+        
+        assertEquals(1, table.getAutoIncrementColumn().length);
+        assertEquals(column, table.getAutoIncrementColumn()[0]);
 
         column = table.getColumn(1);
 
@@ -624,8 +625,9 @@
         assertNull(column.getDefaultValue());
         assertEquals("The primary key of table A",
                      column.getDescription());
+        assertEquals(1, table.getAutoIncrementColumn().length);
         assertEquals(column,
-                     table.getAutoIncrementColumn());
+                     table.getAutoIncrementColumn()[0]);
 
         column = table.getColumn(1);
 
@@ -707,7 +709,7 @@
                      table.getName());
         assertEquals("Table B",
                      table.getDescription());
-        assertNull(table.getAutoIncrementColumn());
+        assertEquals(0, table.getAutoIncrementColumn().length);
         assertEquals(3,
                      table.getColumnCount());
         assertEquals(2,
@@ -839,7 +841,7 @@
                      table.getName());
         assertEquals("Table C",
                      table.getDescription());
-        assertNull(table.getAutoIncrementColumn());
+        assertEquals(0, table.getAutoIncrementColumn().length);
         assertEquals(2,
                      table.getColumnCount());
         assertEquals(0,
@@ -1242,6 +1244,21 @@
         {}
     }
 
+    /**
+     * Need to check this with the betwixt team..
+     * This piece of xml will end up with a Database object with on Table named NotATable,
which
+     * is clearly wrong.
+     */
+    public void testFaultReadOfTable() 
+    {
+        Database database = readModel(
+                "<database name='db' >\n" +
+                "  <index name='NotATable'/>\n" +
+                "</database>");
+        
+        System.out.println("Table : " + Arrays.asList(database.getTables()));
+        assertEquals(0, database.getTableCount());
+    }
     // TODO: Tests that include:
     // * foreign key references undefined table
     // * foreign key references undefined local column



Mime
View raw message