db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1148920 - /db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java
Date Wed, 20 Jul 2011 19:49:31 GMT
Author: tfischer
Date: Wed Jul 20 19:49:30 2011
New Revision: 1148920

URL: http://svn.apache.org/viewvc?rev=1148920&view=rev
Log:
TORQUE-164: adjust test cases for: Fix foreign key storage in database map

Modified:
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java?rev=1148920&r1=1148919&r2=1148920&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java
(original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java
Wed Jul 20 19:49:30 2011
@@ -19,6 +19,8 @@ package org.apache.torque.map;
  * under the License.
  */
 
+import java.util.List;
+
 import org.apache.torque.BaseRuntimeTestCase;
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
@@ -56,7 +58,7 @@ public class DatabaseMapTest extends Bas
      * (bookstore)<br> This table has not been used by any other test prior to
      * this test.<br> </ul>
      */
-    public void testDatabaseMapInitialize() throws TorqueException
+    public void testDatabaseMapInitialize() throws Exception
     {
         // Get default schema DB
         DatabaseMap map = Torque.getDatabaseMap();
@@ -65,16 +67,7 @@ public class DatabaseMapTest extends Bas
                 "Did not expect to find NotUsedBeforeMapInit table before " + 
                 "initialize!",
                 tMap == null);
-        try
-        {
-            map.initialize();
-        }
-        catch (Exception e)
-        {
-            fail("The following error occured while initializing the " + 
-                    "database map, msg='"
-                    + e.getMessage() + "'");
-        }
+        map.initialize();
         tMap = map.getTable(TABLE_NAME1);
         assertTrue(
                 "Did not find table named NotUsedBeforeMapInit after " +
@@ -240,12 +233,28 @@ public class DatabaseMapTest extends Bas
         }
         assertTrue("Column position attribute != 4", 
                     column.getPosition() == 4);
-        assertTrue("Column isForeignKey attribute was false instead of true!",
-                column.isForeignKey());
-        validateAttribute("Column relatedTableName", "CIRCULAR_REFERENCE_A",
-                column.getRelatedTableName());
-        validateAttribute("Column relatedColumnName",
-                "CIRCULAR_REFERENCE_A_ID", column.getRelatedColumnName());
+    }
+
+    /**
+     * Test that the foreign key properties get set correctly from the XML
+     */
+    public void testForeignKeyAttributes() throws TorqueException
+    {
+        DatabaseMap map = Torque.getDatabaseMap(DATABASE_NAME);
+        map.initialize();
+        TableMap table = map.getTable(TABLE_NAME1);
+        List<ForeignKeyMap> foreignKeys = table.getForeignKeys();
+        assertEquals(1, foreignKeys.size());
+        ForeignKeyMap foreignKey = foreignKeys.get(0);
+        assertEquals("CIRCULAR_REFERENCE_A", foreignKey.getForeignTableName());
+        assertEquals(1, foreignKey.getColumns().size());
+        ForeignKeyMap.ColumnPair columnPair = foreignKey.getColumns().get(0);
+        assertEquals(
+                "three",
+                columnPair.getLocal().getColumnName());
+        assertEquals(
+                "CIRCULAR_REFERENCE_A_ID",
+                columnPair.getForeign().getColumnName());
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message