db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r267206 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/model/Table.java test/org/apache/ddlutils/model/ test/org/apache/ddlutils/model/TestArrayAccessAtTable.java
Date Fri, 02 Sep 2005 14:18:42 GMT
Author: tomdz
Date: Fri Sep  2 07:18:37 2005
New Revision: 267206

URL: http://svn.apache.org/viewcvs?rev=267206&view=rev
Log:
Fix for DDLUTILS-6 as provided by Christoffer Hammarström

Added:
    db/ddlutils/trunk/src/test/org/apache/ddlutils/model/
    db/ddlutils/trunk/src/test/org/apache/ddlutils/model/TestArrayAccessAtTable.java
Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.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=267206&r1=267205&r2=267206&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 Fri Sep  2 07:18:37 2005
@@ -19,10 +19,10 @@
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
+import java.util.Collection;
 
 import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.list.PredicatedList;
+import org.apache.commons.collections.CollectionUtils;
 
 /**
  * Represents a table in the database model.
@@ -378,7 +378,7 @@
      */
     public Index[] getNonUniqueIndices()
     {
-        List nonUniqueIndices = PredicatedList.decorate(_indices, new Predicate() {
+        Collection nonUniqueIndices = CollectionUtils.select(_indices, new Predicate() {
             public boolean evaluate(Object input) {
                 return !((Index)input).isUnique();
             }
@@ -394,7 +394,7 @@
      */
     public Index[] getUniqueIndices()
     {
-        List uniqueIndices = PredicatedList.decorate(_indices, new Predicate() {
+        Collection uniqueIndices = CollectionUtils.select(_indices, new Predicate() {
             public boolean evaluate(Object input) {
                 return ((Index)input).isUnique();
             }
@@ -566,7 +566,7 @@
      */
     public Column[] getPrimaryKeyColumns()
     {
-        List pkColumns = PredicatedList.decorate(_columns, new Predicate() {
+        Collection pkColumns = CollectionUtils.select(_columns, new Predicate() {
             public boolean evaluate(Object input) {
                 return ((Column)input).isPrimaryKey();
             }

Added: db/ddlutils/trunk/src/test/org/apache/ddlutils/model/TestArrayAccessAtTable.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/test/org/apache/ddlutils/model/TestArrayAccessAtTable.java?rev=267206&view=auto
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/model/TestArrayAccessAtTable.java (added)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/model/TestArrayAccessAtTable.java Fri Sep
 2 07:18:37 2005
@@ -0,0 +1,84 @@
+package org.apache.ddlutils.model;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for DDLUTILS-6
+ * 
+ * @author Christoffer Hammarström
+ */
+public class TestArrayAccessAtTable extends TestCase
+{
+    private Table          _testedTable;
+    private Column         _column1;
+    private Column         _column2;
+    private UniqueIndex    _uniqueIndex;
+    private NonUniqueIndex _nonUniqueIndex;
+
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    public void setUp()
+    {
+        _testedTable = new Table();
+
+        _column1 = new Column();
+        _column1.setName("column1");
+        _column1.setPrimaryKey(true);
+
+        _column2 = new Column();
+        _column2.setName("column2");
+
+        _testedTable.addColumn(_column1);
+        _testedTable.addColumn(_column2);
+
+        _uniqueIndex = new UniqueIndex();
+        _testedTable.addIndex(_uniqueIndex);
+
+        _nonUniqueIndex = new NonUniqueIndex();
+        _testedTable.addIndex(_nonUniqueIndex);
+    }
+
+    public void testGetPrimaryKeyColumns()
+    {
+        Column[] primaryKeyColumns = _testedTable.getPrimaryKeyColumns();
+
+        assertEquals(1,
+                     primaryKeyColumns.length);
+        assertSame(_column1,
+                   primaryKeyColumns[0]);
+    }
+
+    public void testGetColumns()
+    {
+        Column[] columns = _testedTable.getColumns();
+
+        assertEquals(2,
+                     columns.length);
+        assertSame(_column1,
+                   columns[0]);
+        assertSame(_column2,
+                   columns[1]);
+    }
+
+    public void testGetNonUniqueIndices()
+    {
+        Index[] nonUniqueIndices = _testedTable.getNonUniqueIndices();
+
+        assertEquals(1,
+                     nonUniqueIndices.length);
+        assertSame(_nonUniqueIndex,
+                   nonUniqueIndices[0]);
+    }
+
+    public void testGetUniqueIndices()
+    {
+        Index[] uniqueIndices = _testedTable.getUniqueIndices();
+
+        assertEquals(1,
+                     uniqueIndices.length);
+        assertSame(_uniqueIndex,
+                   uniqueIndices[0]);
+    }
+
+}



Mime
View raw message