db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcai...@apache.org
Subject svn commit: r292259 [2/3] - /incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/
Date Wed, 28 Sep 2005 19:03:17 GMT
Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java Wed Sep 28 12:03:07 2005
@@ -71,64 +71,57 @@
     void runTest(PersistenceManager pm)
     {
         Transaction tx = pm.currentTransaction();
-        try { 
-            int i, n;
-            long value;
-            tx.begin();
-            FieldsOfPrimitivelong pi = new FieldsOfPrimitivelong();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for( i = 0, value = 10; i < n; ++i){
-                pi.set( i, value);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
+        int i, n;
+        long value;
+        tx.begin();
+        FieldsOfPrimitivelong pi = new FieldsOfPrimitivelong();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        n = pi.getLength();
+        // Provide initial set of values
+        for( i = 0, value = 10; i < n; ++i){
+            pi.set( i, value);
+        }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
 
-            pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true);
-            checkValues(oid, 10); // check if persistent fields have values set
+        tx.begin();
 
-            // Provide new set of values
-            for( i = 0, value = 67000; i < n; ++i){
-                pi.set(i, value);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
+        pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true);
+        checkValues(oid, 10); // check if persistent fields have values set
 
-            tx.begin();
-            // check new values
-            checkValues(oid, 67000);
-            pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+        // Provide new set of values
+        for( i = 0, value = 67000; i < n; ++i){
+            pi.set(i, value);
         }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        checkValues(oid, 67000);
+        tx.commit();
     }
 
     /** */
     private void checkValues(Object oid, long startValue){
         int i;
         long value;
-        FieldsOfPrimitivelong pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true);
+        FieldsOfPrimitivelong pi = (FieldsOfPrimitivelong)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
         for( i = 0; i < n; ++i){
             if( !FieldsOfPrimitivelong.isPersistent[i] ) continue;
             long val = pi.get(i);
             if( val != startValue ){
                 fail(ASSERTION_FAILED,
-                        "Incorrect value for " + FieldsOfPrimitivelong.fieldSpecs[i] +
+                        "Incorrect value for " +
+                        FieldsOfPrimitivelong.fieldSpecs[i] +
                         ", expected value " + startValue +
                         ", value is " + val);
             }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java Wed Sep 28 12:03:07 2005
@@ -70,63 +70,56 @@
     void runTest(PersistenceManager pm)
     {
         Transaction tx = pm.currentTransaction();
-        try { 
-            int i, n;
-            short value;
-            tx.begin();
-            FieldsOfPrimitiveshort pi = new FieldsOfPrimitiveshort();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for( i = 0, value = 10; i < n; ++i){
-                pi.set( i, value);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
+        int i, n;
+        short value;
+        tx.begin();
+        FieldsOfPrimitiveshort pi = new FieldsOfPrimitiveshort();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        n = pi.getLength();
+        // Provide initial set of values
+        for( i = 0, value = 10; i < n; ++i){
+            pi.set( i, value);
+        }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
 
-            pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true);
-            checkValues(oid, (short)10); // check if persistent fields have values set
+        tx.begin();
 
-            // Provide new set of values
-            for( i = 0, value = 32000; i < n; ++i){
-                pi.set(i, value);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
+        pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true);
+        checkValues(oid, (short)10);
 
-            tx.begin();
-            // check new values
-            checkValues(oid, (short)32000);
-            pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+        // Provide new set of values
+        for( i = 0, value = 32000; i < n; ++i){
+            pi.set(i, value);
         }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        checkValues(oid, (short)32000);
+        tx.commit();
     }
 
     /** */
     private void checkValues(Object oid, short startValue){
         int i;
-        FieldsOfPrimitiveshort pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true);
+        FieldsOfPrimitiveshort pi = (FieldsOfPrimitiveshort)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
         for( i = 0; i < n; ++i){
             if( !FieldsOfPrimitiveshort.isPersistent[i] ) continue;
             short val = pi.get(i);
             if( val != startValue ){
                 fail(ASSERTION_FAILED,
-                        "Incorrect value for " + FieldsOfPrimitiveshort.fieldSpecs[i] +
+                        "Incorrect value for " +
+                        FieldsOfPrimitiveshort.fieldSpecs[i] +
                         ", expected value " + startValue +
                         ", value is " + val);
             }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java Wed Sep 28 12:03:07 2005
@@ -73,51 +73,42 @@
     void runTest(PersistenceManager pm)
     {
         Transaction tx = pm.currentTransaction();
-        try { 
-            int i, n;
-            Short firstValue = new Short(Short.MIN_VALUE);
-            Short secondValue = new Short(Short.MAX_VALUE);
-            tx.begin();
-            FieldsOfShort pi = new FieldsOfShort();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for( i = 0; i < n; ++i){
-                pi.set( i, firstValue);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
+        int i, n;
+        Short firstValue = new Short(Short.MIN_VALUE);
+        Short secondValue = new Short(Short.MAX_VALUE);
+        tx.begin();
+        FieldsOfShort pi = new FieldsOfShort();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        n = pi.getLength();
+        // Provide initial set of values
+        for( i = 0; i < n; ++i){
+            pi.set( i, firstValue);
+        }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
 
-            pi = (FieldsOfShort) pm.getObjectById(oid, true);
-            checkValues(oid, firstValue); // check if persistent fields have values set
+        tx.begin();
 
-            // Provide new set of values
-            for( i = 0; i < n; ++i){
-                pi.set(i, secondValue);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
+        pi = (FieldsOfShort) pm.getObjectById(oid, true);
+        checkValues(oid, firstValue);
 
-            tx.begin();
-            // check new values
-            checkValues(oid, secondValue);
-            pi = (FieldsOfShort) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+        // Provide new set of values
+        for( i = 0; i < n; ++i){
+            pi.set(i, secondValue);
         }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        checkValues(oid, secondValue);
+        tx.commit();
     }
 
     /** */

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java Wed Sep 28 12:03:07 2005
@@ -72,64 +72,57 @@
     void runTest(PersistenceManager pm)
     {
         Transaction tx = pm.currentTransaction();
-        try { 
-            int i, n;
-            SimpleClass firstValue = new SimpleClass(100, "Hello");
-            SimpleClass secondValue = new SimpleClass(2000, "Hello World");
-            tx.begin();
-            FieldsOfSimpleClass pi = new FieldsOfSimpleClass();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for( i = 0; i < n; ++i){
-                pi.set( i, firstValue);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
+        int i, n;
+        SimpleClass firstValue = new SimpleClass(100, "Hello");
+        SimpleClass secondValue = new SimpleClass(2000, "Hello World");
+        tx.begin();
+        FieldsOfSimpleClass pi = new FieldsOfSimpleClass();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        n = pi.getLength();
+        // Provide initial set of values
+        for( i = 0; i < n; ++i){
+            pi.set( i, firstValue);
+        }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
 
-            pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true);
-            checkValues(oid, firstValue); // check if persistent fields have values set
+        tx.begin();
 
-            // Provide new set of values
-            for( i = 0; i < n; ++i){
-                pi.set(i, secondValue);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
+        pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true);
+        checkValues(oid, firstValue);
 
-            tx.begin();
-            // check new values
-            checkValues(oid, secondValue);
-            pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+        // Provide new set of values
+        for( i = 0; i < n; ++i){
+            pi.set(i, secondValue);
         }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        checkValues(oid, secondValue);
+        tx.commit();
     }
 
     /** */
     private void checkValues(Object oid, SimpleClass startValue){
         int i;
-        FieldsOfSimpleClass pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true);
+        FieldsOfSimpleClass pi = (FieldsOfSimpleClass)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
         for( i = 0; i < n; ++i){
             if( !FieldsOfSimpleClass.isPersistent[i] ) continue;
             SimpleClass val = pi.get(i);
             if(!val.equals(startValue) ){
                 fail(ASSERTION_FAILED,
-                        "Incorrect value for " + FieldsOfSimpleClass.fieldSpecs[i]);
+                        "Incorrect value for " +
+                        FieldsOfSimpleClass.fieldSpecs[i]);
             }
         }
     }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java Wed Sep 28 12:03:07 2005
@@ -74,64 +74,57 @@
     void runTest(PersistenceManager pm)
     {
         Transaction tx = pm.currentTransaction();
-        try { 
-            int i, n;
-            SimpleInterface firstValue = new SimpleClass(100, "Hello");
-            SimpleInterface secondValue = new SimpleClass(2000, "Hello World");
-            tx.begin();
-            FieldsOfSimpleInterface pi = new FieldsOfSimpleInterface();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for( i = 0; i < n; ++i){
-                pi.set( i, firstValue);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
+        int i, n;
+        SimpleInterface firstValue = new SimpleClass(100, "Hello");
+        SimpleInterface secondValue = new SimpleClass(2000, "Hello World");
+        tx.begin();
+        FieldsOfSimpleInterface pi = new FieldsOfSimpleInterface();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        n = pi.getLength();
+        // Provide initial set of values
+        for( i = 0; i < n; ++i){
+            pi.set( i, firstValue);
+        }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
 
-            pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true);
-            checkValues(oid, firstValue); // check if persistent fields have values set
+        tx.begin();
 
-            // Provide new set of values
-            for( i = 0; i < n; ++i){
-                pi.set(i, secondValue);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
+        pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true);
+        checkValues(oid, firstValue);
 
-            tx.begin();
-            // check new values
-            checkValues(oid, secondValue);
-            pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+        // Provide new set of values
+        for( i = 0; i < n; ++i){
+            pi.set(i, secondValue);
         }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        checkValues(oid, secondValue);
+        tx.commit();
     }
 
     /** */
     private void checkValues(Object oid, SimpleInterface startValue){
         int i;
-        FieldsOfSimpleInterface pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true);
+        FieldsOfSimpleInterface pi = (FieldsOfSimpleInterface)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
         for( i = 0; i < n; ++i){
             if( !FieldsOfSimpleInterface.isPersistent[i] ) continue;
             SimpleInterface val = pi.get(i);
             if(!val.equals(startValue)){
                 fail(ASSERTION_FAILED,
-                        "Incorrect value for " + FieldsOfSimpleInterface.fieldSpecs[i]); 
+                        "Incorrect value for " +
+                        FieldsOfSimpleInterface.fieldSpecs[i]); 
             }
         }
     }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java Wed Sep 28 12:03:07 2005
@@ -73,51 +73,42 @@
     void runTest(PersistenceManager pm)
     {
         Transaction tx = pm.currentTransaction();
-        try { 
-            int i, n;
-            String firstValue = new String("Hello");
-            String secondValue = new String("Hello World");
-            tx.begin();
-            FieldsOfString pi = new FieldsOfString();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for( i = 0; i < n; ++i){
-                pi.set( i, firstValue);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
+        int i, n;
+        String firstValue = new String("Hello");
+        String secondValue = new String("Hello World");
+        tx.begin();
+        FieldsOfString pi = new FieldsOfString();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        n = pi.getLength();
+        // Provide initial set of values
+        for( i = 0; i < n; ++i){
+            pi.set( i, firstValue);
+        }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
 
-            pi = (FieldsOfString) pm.getObjectById(oid, true);
-            checkValues(oid, firstValue); // check if persistent fields have values set
+        tx.begin();
 
-            // Provide new set of values
-            for( i = 0; i < n; ++i){
-                pi.set(i, secondValue);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
+        pi = (FieldsOfString) pm.getObjectById(oid, true);
+        checkValues(oid, firstValue);
 
-            tx.begin();
-            // check new values
-            checkValues(oid, secondValue);
-            pi = (FieldsOfString) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+        // Provide new set of values
+        for( i = 0; i < n; ++i){
+            pi.set(i, secondValue);
         }
+        tx.commit();
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        checkValues(oid, secondValue);
+        tx.commit();
     }
 
     /** */

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java Wed Sep 28 12:03:07 2005
@@ -78,127 +78,97 @@
     {
         if (!isHashMapSupported()) {
             if (debug)
-                logger.debug("JDO Implementation does not support the optional feature HashMap");
+                logger.debug("JDO Implementation does not support " +
+                        "the optional feature HashMap");
             return;
         }
         
         Transaction tx = pm.currentTransaction();
-        try {;
-            int i, j, n;
-            FirstSetOfTestValuesForCollection firstValue =
-                new FirstSetOfTestValuesForCollection();
-            SecondSetOfTestValuesForCollection secondValue =
-                new SecondSetOfTestValuesForCollection();
+        HashMapStringKeyCollections expectedValue =
+                new HashMapStringKeyCollections();
         
-            // turn on datastore transactions
-            tx.setOptimistic(false);
-            tx.begin();
-            HashMapStringKeyCollections pi = new HashMapStringKeyCollections();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashMapStringKeyCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                HashMap map = new HashMap();
-                Vector keys = (Vector) firstValue.get(fieldType);
-                Vector values = (Vector) secondValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
-
-                pi.set(i, map);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-
-            Hashtable firstSet = new Hashtable();
-            firstSet.put("keys", firstValue);
-            firstSet.put("values", secondValue);
-            pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true);
-
-            checkValues(oid, firstSet); // check if persistent fields have values set
-
-            // Provide new set of values     -- reverse the keys and values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashMapStringKeyCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                HashMap map = new HashMap();
-                Vector keys = (Vector) secondValue.get(fieldType);
-                Vector values = (Vector) firstValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
+        // turn on datastore transactions
+        tx.setOptimistic(false);
+        tx.begin();
+        HashMapStringKeyCollections pi = new HashMapStringKeyCollections();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        // Provide initial set of values
+        setValues(pi, 1);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        setValues(expectedValue, 1);
+        checkValues(oid, expectedValue);
+        pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true);
+        setValues(pi, 2);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        setValues(expectedValue, 2);
+        checkValues(oid, expectedValue);
+        tx.commit();
+    }
 
-                pi.set(i, map);
+    /** */
+    private void setValues(HashMapStringKeyCollections collect, int order)
+    {
+        int keyOrder = order;
+        int valueOrder = (order == 1) ? 2 : 1; // why??
+        int n = collect.getLength();
+        for (int i = 0; i < n; ++i) {
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                    HashMapStringKeyCollections.fieldSpecs[i]);
+            Vector key = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(0), keyOrder);
+            Vector value = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(1), valueOrder);
+
+            HashMap map = new HashMap();
+            for (int j = 0; j< key.size(); j++) {
+                map.put(key.get(j), value.get(j));
             }
-
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-            // check new values
-            Hashtable secondSet = new Hashtable();
-            secondSet.put("keys", secondValue);
-            secondSet.put("values", firstValue);
-
-            checkValues(oid, secondSet);
-            pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        catch (IndexOutOfBoundsException e) {
-                logger.error(e.getMessage());
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+            collect.set(i, map);
+            if (debug)
+                logger.debug("Set " + i + "th value to: " + map.toString());
         }
     }
 
     /** */
-    private void checkValues(Object oid, Hashtable startValue)
+    private void checkValues(Object oid,
+            HashMapStringKeyCollections expectedValue)
     {
-        int i, j;
-
-        HashMapStringKeyCollections pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true);
+        StringBuffer sbuf = new StringBuffer();
+        HashMapStringKeyCollections pi = (HashMapStringKeyCollections)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
-
-        Hashtable keySet = (Hashtable) startValue.get("keys");
-        Hashtable valueSet = (Hashtable) startValue.get("values");
-
-        for( i = 0; i < n; ++i){
-            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashMapStringKeyCollections.fieldSpecs[i]);
-            String fieldType = (String)fieldSpecs.get(0);
-            String valueType = (String)fieldSpecs.get(1);
-            HashMap compareWith = new HashMap();
-
-            Vector keys = (Vector) keySet.get(fieldType);
-            Vector values = (Vector) valueSet.get(valueType);
-            
-            for (j = 0; j< keys.size(); j++) {
-                compareWith.put(keys.get(j), values.get(j));
-            }
-
+        for (int i = 0; i < n; ++i) {
+            HashMap compareWith = expectedValue.get(i);
             HashMap val = pi.get(i);
-
-            if(!val.equals(compareWith)){
-                fail(ASSERTION_FAILED,
-                     "Incorrect value for " +HashMapStringKeyCollections.fieldSpecs[i]);
+            if (val.size() != compareWith.size()) {
+                sbuf.append("\nFor element " + i + ", expected size = " +
+                        compareWith.size() + ", actual size = " + val.size()
+                        + " . ");
+                continue;
             }
+            if (! val.equals(compareWith)) {
+                sbuf.append("\nFor element " + i + ", expected = " +
+                        compareWith + ", actual = " + val + " . ");
+            }
+        }
+        if (sbuf.length() > 0) {
+            fail(ASSERTION_FAILED,
+                 "Expected and observed do not match!!" + sbuf.toString());
         }
     }
 }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java Wed Sep 28 12:03:07 2005
@@ -77,133 +77,99 @@
     {
         if (!isHashMapSupported()) {
             if (debug)
-                logger.debug("JDO Implementation does not support the optional feature HashMap");
+                logger.debug("JDO Implementation does not support " +
+                        "the optional feature HashMap");
             return;
         }
         
         Transaction tx = pm.currentTransaction();
-        try { 
-            int i, j, n;
-            FirstSetOfTestValuesForCollection firstValue = 
-                    new FirstSetOfTestValuesForCollection();
-            SecondSetOfTestValuesForCollection secondValue = 
-                    new SecondSetOfTestValuesForCollection();
-
-            // turn on datastore transactions
-            tx.setOptimistic(false);
-            tx.begin();
-            HashMapStringValueCollections pi = new HashMapStringValueCollections();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
-                    HashMapStringValueCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                HashMap map = new HashMap();
-                Vector keys = (Vector) firstValue.get(fieldType);
-                Vector values = (Vector) secondValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
+        HashMapStringValueCollections expectedValue =
+                new HashMapStringValueCollections();
 
-                pi.set(i, map);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-
-            Hashtable firstSet = new Hashtable();
-            firstSet.put("keys", firstValue);
-            firstSet.put("values", secondValue);
-
-            checkValues(oid, firstSet); // check if persistent fields have values set
-            pi = (HashMapStringValueCollections) pm.getObjectById(oid, true);
-
-            // Provide new set of values     -- reverse the keys and values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
-                    HashMapStringValueCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                HashMap map = new HashMap();
-                Vector keys = (Vector) secondValue.get(fieldType);
-                Vector values = (Vector) firstValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
+        // turn on datastore transactions
+        tx.setOptimistic(false);
+        tx.begin();
+        HashMapStringValueCollections pi = new HashMapStringValueCollections();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        // Provide initial set of values
+        setValues(pi, 1);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        setValues(expectedValue, 1);
+        checkValues(oid, expectedValue);
+        pi = (HashMapStringValueCollections) pm.getObjectById(oid, true);
+        // Provide new set of values     -- reverse the keys and values
+        setValues(pi, 2);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        setValues(expectedValue, 2);
+        checkValues(oid, expectedValue);
+        pi = (HashMapStringValueCollections) pm.getObjectById(oid, true);
+        tx.commit();
+    }
 
-                pi.set(i, map);
+    /** */
+    private void setValues(HashMapStringValueCollections collect, int order)
+    {
+        int keyOrder = order;
+        int valueOrder = (order == 1) ? 2 : 1; // why??
+        int n = collect.getLength();
+        for (int i = 0; i < n; ++i) {
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                    HashMapStringValueCollections.fieldSpecs[i]);
+            Vector key = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(0), keyOrder);
+            Vector value = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(1), valueOrder);
+
+            HashMap map = new HashMap();
+            for (int j = 0; j< key.size(); j++) {
+                map.put(key.get(j), value.get(j));
             }
-
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-            // check new values
-            Hashtable secondSet = new Hashtable();
-            secondSet.put("keys", secondValue);
-            secondSet.put("values", firstValue);
-
-            checkValues(oid, secondSet);
-            pi = (HashMapStringValueCollections) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        catch (IndexOutOfBoundsException e) {
-            logger.error(e.getMessage());
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+            collect.set(i, map);
+            if (debug)
+                logger.debug("Set " + i + "th value to: " + map.toString());
         }
     }
 
     /** */
-    private void checkValues(Object oid, Hashtable startValue)
+    private void checkValues(Object oid,
+            HashMapStringValueCollections expectedValue)
     {
-        int ret = 0;
-        int i, j;
-
-        HashMapStringValueCollections pi = 
-            (HashMapStringValueCollections) pm.getObjectById(oid, true);
+        StringBuffer sbuf = new StringBuffer();
+        HashMapStringValueCollections pi = (HashMapStringValueCollections)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
-
-        Hashtable keySet = (Hashtable) startValue.get("keys");
-        Hashtable valueSet = (Hashtable) startValue.get("values");
-
-        for( i = 0; i < n; ++i){
-            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
-                HashMapStringValueCollections.fieldSpecs[i]);
-            String fieldType = (String)fieldSpecs.get(0);
-            String valueType = (String)fieldSpecs.get(1);
-            HashMap compareWith = new HashMap();
-
-            Vector keys = (Vector) keySet.get(fieldType);
-            Vector values = (Vector) valueSet.get(valueType);
-            
-            for (j = 0; j< keys.size(); j++) {
-                compareWith.put(keys.get(j), values.get(j));
-            }
-
+        for (int i = 0; i < n; ++i) {
+            HashMap compareWith = expectedValue.get(i);
             HashMap val = pi.get(i);
-
-            if(!val.equals(compareWith)){
-                fail(ASSERTION_FAILED,
-                     "Incorrect value for " + HashMapStringValueCollections.fieldSpecs[i]);
+            if (val.size() != compareWith.size()) {
+                sbuf.append("\nFor element " + i + ", expected size = " +
+                        compareWith.size() + ", actual size = " + val.size()
+                        + " . ");
+                continue;
+            }
+            if (! val.equals(compareWith)) {
+                sbuf.append("\nFor element " + i + ", expected = " +
+                        compareWith + ", actual = " + val + " . ");
             }
         }
+        if (sbuf.length() > 0) {
+            fail(ASSERTION_FAILED,
+                 "Expected and observed do not match!!" + sbuf.toString());
+        }
     }
-
 }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java Wed Sep 28 12:03:07 2005
@@ -18,7 +18,7 @@
 
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Hashtable;
+import java.util.Vector;
 
 import javax.jdo.PersistenceManager;
 import javax.jdo.Transaction;
@@ -77,75 +77,86 @@
     void runTest(PersistenceManager pm)
     {
         Transaction tx = pm.currentTransaction();
-        try {
-            int i, n;
-            FirstSetOfTestValuesForCollection firstValue = new FirstSetOfTestValuesForCollection();
-            SecondSetOfTestValuesForCollection secondValue = new SecondSetOfTestValuesForCollection();
-
-            // turn on datastore transactions
-            tx.setOptimistic(false);
-            tx.begin();
-            HashSetCollections pi = new HashSetCollections();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for(i = 0; i < n; ++i){
-                String valueType = TestUtil.getFieldSpecs(HashSetCollections.fieldSpecs[i]);
-                pi.set( i, new HashSet((Collection)firstValue.get(valueType)));
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-
-            checkValues(oid, firstValue); // check if persistent fields have values set
-            pi = (HashSetCollections) pm.getObjectById(oid, true);
-
-            // Provide new set of values
-            for( i = 0; i < n; ++i){
-                String valueType = TestUtil.getFieldSpecs(HashSetCollections.fieldSpecs[i]);
-                pi.set( i, new HashSet((Collection)secondValue.get(valueType)));
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-            // check new values
-            checkValues(oid, secondValue);
-            pi = (HashSetCollections) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+        HashSetCollections expectedValue = new HashSetCollections();
+
+        // turn on datastore transactions
+        tx.setOptimistic(false);
+        tx.begin();
+        HashSetCollections pi = new HashSetCollections();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        // Provide initial set of values
+        setValues(pi, 1);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        setValues(expectedValue, 1);
+        checkValues(oid, expectedValue);
+        pi = (HashSetCollections) pm.getObjectById(oid, true);
+        // Provide new set of values
+        setValues(pi, 2);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        setValues(expectedValue, 2);
+        checkValues(oid, expectedValue);
+        pi = (HashSetCollections) pm.getObjectById(oid, true);
+        tx.commit();
+    }
+
+    /** */
+    private void setValues(HashSetCollections collect, int order)
+    {
+        Collection value;
+        int n = collect.getLength();
+        for (int i = 0; i < n; ++i) {
+            String valueType = TestUtil.getFieldSpecs(
+                    HashSetCollections.fieldSpecs[i]);
+            value = (Collection)TestUtil.makeNewVectorInstance(
+                    valueType, order);
+            collect.set( i, (HashSet)value);
+            if (debug)
+                logger.debug("Set " + i + "th value to: " + value.toString());
         }
     }
 
-    private void checkValues(Object oid, Hashtable startValue)
+    /** */
+    private void checkValues(Object oid, HashSetCollections expectedValue)
     {
         int i;
-
-        HashSetCollections pi = (HashSetCollections) pm.getObjectById(oid, true);
+        StringBuffer sbuf = new StringBuffer();
+        HashSetCollections pi = (HashSetCollections)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
-        for( i = 0; i < n; ++i){
-            String valueType = TestUtil.getFieldSpecs(HashSetCollections.fieldSpecs[i]);
-            HashSet compareWith = new HashSet((Collection)startValue.get(valueType));
-
-            HashSet val = pi.get(i);
-
-            if(!val.equals(compareWith)){
-                fail(ASSERTION_FAILED,
-                     "Incorrect value for " + HashSetCollections.fieldSpecs[i]);
+        for (i = 0; i < n; ++i) {
+            Collection compareWith = expectedValue.get(i);
+            Collection val = pi.get(i);
+            if (val.size() != compareWith.size()) {
+                sbuf.append("\nFor element " + i + ", expected size = " +
+                        compareWith.size() + ", actual size = " + val.size()
+                        + " . ");
+                continue;
             }
+            if (! val.equals(compareWith)) {
+                sbuf.append("\nFor element " + i + ", expected = " +
+                        compareWith + ", actual = " + val + " . ");
+            }
+        }
+        if (sbuf.length() > 0) {
+            fail(ASSERTION_FAILED,
+                 "Expected and observed do not match!!" + sbuf.toString());
         }
     }
+
 
 }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java Wed Sep 28 12:03:07 2005
@@ -77,122 +77,99 @@
     {
         if (!isHashtableSupported()) {
             if (debug)
-                logger.debug("JDO Implementation does not support the optional feature Hashtable");
+                logger.debug("JDO Implementation does not support " +
+                        "the optional feature Hashtable");
             return;
         }
         
         Transaction tx = pm.currentTransaction();
-        try {
-            int i, j, n;
-            FirstSetOfTestValuesForCollection firstValue =
-                new FirstSetOfTestValuesForCollection();
-            SecondSetOfTestValuesForCollection secondValue =
-                new SecondSetOfTestValuesForCollection();
-
-            // turn on datastore transactions
-            tx.setOptimistic(false);
-            tx.begin();
-            HashtableStringKeyCollections pi = new HashtableStringKeyCollections();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringKeyCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                Hashtable map = new Hashtable();
-                Vector keys = (Vector) firstValue.get(fieldType);
-                Vector values = (Vector) secondValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
+        HashtableStringKeyCollections expectedValue =
+                new HashtableStringKeyCollections();
 
-                pi.set(i, map);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-
-            Hashtable firstSet = new Hashtable();
-            firstSet.put("keys", firstValue);
-            firstSet.put("values", secondValue);
-
-            checkValues(oid, firstSet); // check if persistent fields have values set
-            pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true);
-
-            // Provide new set of values     -- reverse the keys and values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringKeyCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                Hashtable map = new Hashtable();
-                Vector keys = (Vector) secondValue.get(fieldType);
-                Vector values = (Vector) firstValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
+        // turn on datastore transactions
+        tx.setOptimistic(false);
+        tx.begin();
+        HashtableStringKeyCollections pi =
+                new HashtableStringKeyCollections();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        // Provide initial set of values
+        setValues(pi, 1);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        setValues(expectedValue, 1);
+        checkValues(oid, expectedValue);
+        pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true);
+        // Provide new set of values     -- reverse the keys and values
+        setValues(pi, 2);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        setValues(expectedValue, 2);
+        // check new values
+        checkValues(oid, expectedValue);
+        tx.commit();
+    }
 
-                pi.set(i, map);
+    /** */
+    private void setValues(HashtableStringKeyCollections collect, int order)
+    {
+        int keyOrder = order;
+        int valueOrder = (order == 1) ? 2 : 1; // why??
+        int n = collect.getLength();
+        for (int i = 0; i < n; ++i) {
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                    HashtableStringKeyCollections.fieldSpecs[i]);
+            Vector key = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(0), keyOrder);
+            Vector value = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(1), valueOrder);
+
+            Hashtable map = new Hashtable();
+            for (int j = 0; j< key.size(); j++) {
+                map.put(key.get(j), value.get(j));
             }
-
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-            // check new values
-            Hashtable secondSet = new Hashtable();
-            secondSet.put("keys", secondValue);
-            secondSet.put("values", firstValue);
-
-            checkValues(oid, secondSet);
-            pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+            collect.set(i, map);
+            if (debug)
+                logger.debug("Set " + i + "th value to: " + map.toString());
         }
     }
 
-    private void checkValues(Object oid, Hashtable startValue){
-        int i, j;
-
-        HashtableStringKeyCollections pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true);
+    /** */
+    private void checkValues(Object oid,
+            HashtableStringKeyCollections expectedValue)
+    {
+        StringBuffer sbuf = new StringBuffer();
+        HashtableStringKeyCollections pi = (HashtableStringKeyCollections)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
-
-        Hashtable keySet = (Hashtable) startValue.get("keys");
-        Hashtable valueSet = (Hashtable) startValue.get("values");
-
-        for( i = 0; i < n; ++i){
-            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringKeyCollections.fieldSpecs[i]);
-            String fieldType = (String)fieldSpecs.get(0);
-            String valueType = (String)fieldSpecs.get(1);
-            Hashtable compareWith = new Hashtable();
-
-            Vector keys = (Vector) keySet.get(fieldType);
-            Vector values = (Vector) valueSet.get(valueType);
-            
-            for (j = 0; j< keys.size(); j++) {
-                compareWith.put(keys.get(j), values.get(j));
-            }
-
+        for (int i = 0; i < n; ++i) {
+            Hashtable compareWith = expectedValue.get(i);
             Hashtable val = pi.get(i);
-
-            if(!val.equals(compareWith)){
-                fail(ASSERTION_FAILED, 
-                     "Incorrect value for " + HashtableStringKeyCollections.fieldSpecs[i]);
+            if (val.size() != compareWith.size()) {
+                sbuf.append("\nFor element " + i + ", expected size = " +
+                        compareWith.size() + ", actual size = " + val.size()
+                        + " . ");
+                continue;
+            }
+            if (! val.equals(compareWith)) {
+                sbuf.append("\nFor element " + i + ", expected = " +
+                        compareWith + ", actual = " + val + " . ");
             }
+        }
+        if (sbuf.length() > 0) {
+            fail(ASSERTION_FAILED,
+                 "Expected and observed do not match!!" + sbuf.toString());
         }
     }
 }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java Wed Sep 28 12:03:07 2005
@@ -76,123 +76,98 @@
     void runTest(PersistenceManager pm) {
         if (!isHashtableSupported()) {
             if (debug)
-                logger.debug("JDO Implementation does not support the optional feature Hashtable");
+                logger.debug("JDO Implementation does not support " +
+                        "the optional feature Hashtable");
             return;
         }
         
         Transaction tx = pm.currentTransaction();
-        try {
-            int i, j, n;
-            FirstSetOfTestValuesForCollection firstValue =
-                new FirstSetOfTestValuesForCollection();
-            SecondSetOfTestValuesForCollection secondValue =
-                new SecondSetOfTestValuesForCollection();
-
-            // turn on datastore transactions
-            tx.setOptimistic(false);
-            tx.begin();
-            HashtableStringValueCollections pi = new HashtableStringValueCollections();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringValueCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                Hashtable map = new Hashtable();
-                Vector keys = (Vector) firstValue.get(fieldType);
-                Vector values = (Vector) secondValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
+        HashtableStringValueCollections expectedValue =
+                new HashtableStringValueCollections();
 
-                pi.set(i, map);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-
-            Hashtable firstSet = new Hashtable();
-            firstSet.put("keys", firstValue);
-            firstSet.put("values", secondValue);
-
-            checkValues(oid, firstSet); // check if persistent fields have values set
-            pi = (HashtableStringValueCollections) pm.getObjectById(oid, true);
-
-            // Provide new set of values     -- reverse the keys and values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringValueCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                Hashtable map = new Hashtable();
-                Vector keys = (Vector) secondValue.get(fieldType);
-                Vector values = (Vector) firstValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
+        // turn on datastore transactions
+        tx.setOptimistic(false);
+        tx.begin();
+        HashtableStringValueCollections pi = 
+                new HashtableStringValueCollections();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        // Provide initial set of values
+        setValues(pi, 1);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        setValues(expectedValue, 1);
+        checkValues(oid, expectedValue);
+        pi = (HashtableStringValueCollections) pm.getObjectById(oid, true);
+        setValues(pi, 2);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        setValues(expectedValue, 2);
+        checkValues(oid, expectedValue);
+        tx.commit();
+    }
 
-                pi.set(i, map);
+    /** */
+    private void setValues(HashtableStringValueCollections collect, int order)
+    {
+        int keyOrder = order;
+        int valueOrder = (order == 1) ? 2 : 1; // why??
+        int n = collect.getLength();
+        for (int i = 0; i < n; ++i) {
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                    HashtableStringValueCollections.fieldSpecs[i]);
+            Vector key = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(0), keyOrder);
+            Vector value = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(1), valueOrder);
+
+            Hashtable map = new Hashtable();
+            for (int j = 0; j< key.size(); j++) {
+                map.put(key.get(j), value.get(j));
             }
-
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-            // check new values
-            Hashtable secondSet = new Hashtable();
-            secondSet.put("keys", secondValue);
-            secondSet.put("values", firstValue);
-
-            checkValues(oid, secondSet);
-            pi = (HashtableStringValueCollections) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+            collect.set(i, map);
+            if (debug)
+                logger.debug("Set " + i + "th value to: " + map.toString());
         }
     }
 
-    private void checkValues(Object oid, Hashtable startValue)
+    /** */
+    private void checkValues(Object oid,
+            HashtableStringValueCollections expectedValue)
     {
-        int i, j;
-
-        HashtableStringValueCollections pi = (HashtableStringValueCollections) pm.getObjectById(oid, true);
+        StringBuffer sbuf = new StringBuffer();
+        HashtableStringValueCollections pi = (HashtableStringValueCollections)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
-
-        Hashtable keySet = (Hashtable) startValue.get("keys");
-        Hashtable valueSet = (Hashtable) startValue.get("values");
-
-        for( i = 0; i < n; ++i){
-            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringValueCollections.fieldSpecs[i]);
-            String fieldType = (String)fieldSpecs.get(0);
-            String valueType = (String)fieldSpecs.get(1);
-            Hashtable compareWith = new Hashtable();
-
-            Vector keys = (Vector) keySet.get(fieldType);
-            Vector values = (Vector) valueSet.get(valueType);
-            
-            for (j = 0; j< keys.size(); j++) {
-                compareWith.put(keys.get(j), values.get(j));
-            }
-
+        for (int i = 0; i < n; ++i) {
+            Hashtable compareWith = expectedValue.get(i);
             Hashtable val = pi.get(i);
-
-            if(!val.equals(compareWith)){
-                fail(ASSERTION_FAILED,
-                     "Incorrect value for " + HashtableStringValueCollections.fieldSpecs[i]);
+            if (val.size() != compareWith.size()) {
+                sbuf.append("\nFor element " + i + ", expected size = " +
+                        compareWith.size() + ", actual size = " + val.size()
+                        + " . ");
+                continue;
+            }
+            if (! val.equals(compareWith)) {
+                sbuf.append("\nFor element " + i + ", expected = " +
+                        compareWith + ", actual = " + val + " . ");
             }
+        }
+        if (sbuf.length() > 0) {
+            fail(ASSERTION_FAILED,
+                 "Expected and observed do not match!!" + sbuf.toString());
         }
     }
 }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java Wed Sep 28 12:03:07 2005
@@ -17,7 +17,7 @@
 package org.apache.jdo.tck.models.fieldtypes;
 
 import java.util.Collection;
-import java.util.Hashtable;
+import java.util.Vector;
 import java.util.LinkedList;
 
 import javax.jdo.PersistenceManager;
@@ -78,82 +78,90 @@
     {
         if (!isLinkedListSupported()) {
             if (debug)
-                logger.debug("JDO Implementation does not support the optional feature LinkedList");
+                logger.debug("JDO Implementation does not support " +
+                        "the optional feature LinkedList");
             return;
         }
         
         Transaction tx = pm.currentTransaction();
-        try {
-            int i, n;
-            FirstSetOfTestValuesForCollection firstValue =
-                new FirstSetOfTestValuesForCollection();
-            SecondSetOfTestValuesForCollection secondValue =
-                new SecondSetOfTestValuesForCollection();
-
-            // turn on datastore transactions
-            tx.setOptimistic(false);
-            tx.begin();
-            LinkedListCollections pi = new LinkedListCollections();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for(i = 0; i < n; ++i){
-                String valueType = TestUtil.getFieldSpecs(LinkedListCollections.fieldSpecs[i]);
-                pi.set( i, new LinkedList((Collection)firstValue.get(valueType)));
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-
-            checkValues(oid, firstValue); // check if persistent fields have values set
-            pi = (LinkedListCollections) pm.getObjectById(oid, true);
-
-            // Provide new set of values
-            for( i = 0; i < n; ++i){
-                String valueType = TestUtil.getFieldSpecs(LinkedListCollections.fieldSpecs[i]);
-                pi.set( i, new LinkedList((Collection)secondValue.get(valueType)));
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-            // check new values
-            checkValues(oid, secondValue);
-            pi = (LinkedListCollections) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+        LinkedListCollections expectedValue = new LinkedListCollections();
+
+        // turn on datastore transactions
+        tx.setOptimistic(false);
+        tx.begin();
+        LinkedListCollections pi = new LinkedListCollections();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        // Provide initial set of values
+        setValues(pi, 1);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+        
+        tx.begin();
+        setValues(expectedValue, 1);
+        // check if persistent fields have values set
+        checkValues(oid, expectedValue);
+        pi = (LinkedListCollections) pm.getObjectById(oid, true);
+        // Provide new set of values
+        setValues(pi, 2);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+        
+        tx.begin();
+        // check new values
+        setValues(expectedValue, 2);
+        checkValues(oid, expectedValue);
+        tx.commit();
+    }
+
+    /** */
+    private void setValues(LinkedListCollections collect, int order)
+    {
+        Collection value;
+        int n = collect.getLength();
+        for (int i = 0; i < n; ++i) {
+            String valueType = TestUtil.getFieldSpecs(
+                    LinkedListCollections.fieldSpecs[i]);
+            value = (Collection)TestUtil.makeNewVectorInstance(
+                    valueType, order);
+            collect.set( i, (LinkedList)value);
+            if (debug)
+                logger.debug("Set " + i + "th value to: " + value.toString());
         }
     }
 
-    private void checkValues(Object oid, Hashtable startValue)
+    /** */
+    private void checkValues(Object oid, LinkedListCollections expectedValue)
     {
         int i;
-
-        LinkedListCollections pi = (LinkedListCollections) pm.getObjectById(oid, true);
+        StringBuffer sbuf = new StringBuffer();
+        LinkedListCollections pi = (LinkedListCollections)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
-        for( i = 0; i < n; ++i){
-            String valueType = TestUtil.getFieldSpecs(LinkedListCollections.fieldSpecs[i]);
-            LinkedList compareWith = new LinkedList((Collection)startValue.get(valueType));
-
-            LinkedList val = pi.get(i);
-
-            if(!val.equals(compareWith)){
-                fail(ASSERTION_FAILED,
-                     "Incorrect value for " + LinkedListCollections.fieldSpecs[i]);
+        for (i = 0; i < n; ++i) {
+            Collection compareWith = expectedValue.get(i);
+            Collection val = pi.get(i);
+            if (val.size() != compareWith.size()) {
+                sbuf.append("\nFor element " + i + ", expected size = " +
+                        compareWith.size() + ", actual size = " + val.size()
+                        + " . ");
+                continue;
+            }
+            if (! val.equals(compareWith)) {
+                sbuf.append("\nFor element " + i + ", expected = " +
+                        compareWith + ", actual = " + val + " . ");
             }
         }
+        if (sbuf.length() > 0) {
+            fail(ASSERTION_FAILED,
+                 "Expected and observed do not match!!" + sbuf.toString());
+        }
     }
-
 }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java Wed Sep 28 12:03:07 2005
@@ -17,7 +17,7 @@
 package org.apache.jdo.tck.models.fieldtypes;
 
 import java.util.Collection;
-import java.util.Hashtable;
+import java.util.Vector;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -79,87 +79,97 @@
     void runTest(PersistenceManager pm) {
         if (!isListSupported()) {
             if (debug)
-                logger.debug("JDO Implementation does not support the optional feature List");
+                logger.debug("JDO Implementation does not support " +
+                        "the optional feature List");
             return;
         }
 
         if (!isLinkedListSupported() && !isArrayListSupported()) {
             fail(ASSERTION_FAILED,
-                 "JDO Implementation supports List, but neither ArrayList nor LinkedList.");
+                     "JDO Implementation supports List, but neither " +
+                     "ArrayList nor LinkedList.");
         }
-        
+
         Transaction tx = pm.currentTransaction();
-        try {
-            int i, n;
-            FirstSetOfTestValuesForCollection firstValue =
-                new FirstSetOfTestValuesForCollection();
-            SecondSetOfTestValuesForCollection secondValue =
-                new SecondSetOfTestValuesForCollection();
-
-            // turn on datastore transactions
-            tx.setOptimistic(false);
-            tx.begin();
-            ListCollections pi = new ListCollections();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for(i = 0; i < n; ++i){
-                String valueType = TestUtil.getFieldSpecs(ListCollections.fieldSpecs[i]);
-                pi.set( i, new LinkedList((Collection)firstValue.get(valueType)));
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-
-            checkValues(oid, firstValue); // check if persistent fields have values set
-            pi = (ListCollections) pm.getObjectById(oid, true);
-
-            // Provide new set of values
-            for( i = 0; i < n; ++i){
-                String valueType = TestUtil.getFieldSpecs(ListCollections.fieldSpecs[i]);
-                pi.set( i, new LinkedList((Collection)secondValue.get(valueType)));
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-            // check new values
-            checkValues(oid, secondValue);
-            pi = (ListCollections) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+        ListCollections expectedValue = new ListCollections();
+        
+        // turn on datastore transactions
+        tx.setOptimistic(false);
+        tx.begin();
+        ListCollections pi = new ListCollections();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        // Provide initial set of values
+        setValues(pi, 1);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+        
+        tx.begin();
+        setValues(expectedValue, 1);
+        // check if persistent fields have values set
+        checkValues(oid, expectedValue);
+        pi = (ListCollections) pm.getObjectById(oid, true);
+        // Provide new set of values
+        setValues(pi, 2);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+        
+        tx.begin();
+        // check new values
+        setValues(expectedValue, 2);
+        checkValues(oid, expectedValue);
+        tx.commit();
+    }
+
+    /** */
+    private void setValues(ListCollections collect, int order)
+    {
+        Vector value;
+        int n = collect.getLength();
+        for (int i = 0; i < n; ++i) {
+            String valueType = TestUtil.getFieldSpecs(
+                    ListCollections.fieldSpecs[i]);
+            value = TestUtil.makeNewVectorInstance(valueType, order);
+            collect.set( i, value);
+            if (debug)
+                logger.debug("Set " + i + "th value to: " + value.toString());
         }
     }
 
-    private void checkValues(Object oid, Hashtable startValue)
+    /** */
+    private void checkValues(Object oid, ListCollections expectedValue)
     {
         int i;
-
-        ListCollections pi = (ListCollections) pm.getObjectById(oid, true);
+        StringBuffer sbuf = new StringBuffer();
+        ListCollections pi = (ListCollections)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
-        for( i = 0; i < n; ++i){
-            String valueType = TestUtil.getFieldSpecs(ListCollections.fieldSpecs[i]);
-            List compareWith = new LinkedList((Collection)startValue.get(valueType));
-
-            List val = pi.get(i);
-
-            if(!val.equals(compareWith)){
-                fail(ASSERTION_FAILED,
-                     "Incorrect value for " + ListCollections.fieldSpecs[i]);
+        for (i = 0; i < n; ++i) {
+            Collection compareWith = expectedValue.get(i);
+            Collection val = pi.get(i);
+            if (val.size() != compareWith.size()) {
+                sbuf.append("\nFor element " + i + ", expected size = " +
+                        compareWith.size() + ", actual size = " + val.size()
+                        + " . ");
+                continue;
             }
+            if (! val.equals(compareWith)) {
+                sbuf.append("\nFor element " + i + ", expected = " +
+                        compareWith + ", actual = " + val + " . ");
+            }
+        }
+        if (sbuf.length() > 0) {
+            fail(ASSERTION_FAILED,
+                 "Expected and observed do not match!!" + sbuf.toString());
         }
     }
+
 
 }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java?rev=292259&r1=292258&r2=292259&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java Wed Sep 28 12:03:07 2005
@@ -17,7 +17,6 @@
 package org.apache.jdo.tck.models.fieldtypes;
 
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Map;
 import java.util.Vector;
 
@@ -77,127 +76,100 @@
     void runTest(PersistenceManager pm) {
         if (!isMapSupported()) {
             if (debug)
-                logger.debug("JDO Implementation does not support the optional feature Map");
+                logger.debug("JDO Implementation does not support " +
+                        "the optional feature Map");
             return;
         }
-        if (!isHashMapSupported() && !isTreeMapSupported()) {
+        if (!isMapSupported() && !isTreeMapSupported()) {
             fail(ASSERTION_FAILED,
-                 "JDO Implementation supports Map, but neither HashMap nor TreeMap.");
+                 "JDO Implementation supports Map, but neither " +
+                 "Map nor TreeMap.");
         }
-
         Transaction tx = pm.currentTransaction();
-        try {
-            int i, j, n;
-            FirstSetOfTestValuesForCollection firstValue =
-                new FirstSetOfTestValuesForCollection();
-            SecondSetOfTestValuesForCollection secondValue =
-                new SecondSetOfTestValuesForCollection();
-
-            // turn on datastore transactions
-            tx.setOptimistic(false);
-            tx.begin();
-            MapStringKeyCollections pi = new MapStringKeyCollections();
-            pi.identifier = 1;
-            pm.makePersistent(pi);
-            Object oid = pm.getObjectId(pi);
-            n = pi.getLength();
-            // Provide initial set of values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(MapStringKeyCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                Map map = new HashMap();
-                Vector keys = (Vector) firstValue.get(fieldType);
-                Vector values = (Vector) secondValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
-
-                pi.set(i, map);
-            }
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-
-            Hashtable firstSet = new Hashtable();
-            firstSet.put("keys", firstValue);
-            firstSet.put("values", secondValue);
-
-            checkValues(oid, firstSet); // check if persistent fields have values set
-            pi = (MapStringKeyCollections) pm.getObjectById(oid, true);
-
-            // Provide new set of values     -- reverse the keys and values
-            for(i = 0; i < n; ++i){
-                Vector fieldSpecs = TestUtil.getFieldSpecsForMap(MapStringKeyCollections.fieldSpecs[i]);
-                String fieldType = (String)fieldSpecs.get(0);
-                String valueType = (String)fieldSpecs.get(1);
-                Map map = new HashMap();
-                Vector keys = (Vector) secondValue.get(fieldType);
-                Vector values = (Vector) firstValue.get(valueType);
-
-                for (j = 0; j< keys.size(); j++) {
-                    map.put(keys.get(j), values.get(j));
-                }
+        MapStringKeyCollections expectedValue = new MapStringKeyCollections();
+        
+        // turn on datastore transactions
+        tx.setOptimistic(false);
+        tx.begin();
+        MapStringKeyCollections pi = new MapStringKeyCollections();
+        pi.identifier = 1;
+        pm.makePersistent(pi);
+        Object oid = pm.getObjectId(pi);
+        // Provide initial set of values
+        setValues(pi, 1);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        setValues(expectedValue, 1);
+        checkValues(oid, expectedValue);
+        pi = (MapStringKeyCollections) pm.getObjectById(oid, true);
+        setValues(pi, 2);
+        tx.commit();
+
+        // cache will be flushed
+        pi = null;
+        System.gc();
+
+        tx.begin();
+        // check new values
+        setValues(expectedValue, 2);
+        checkValues(oid, expectedValue);
+        tx.commit();
+    }
 
-                pi.set(i, map);
+    /** */
+    private void setValues(MapStringKeyCollections collect, int order)
+    {
+        int keyOrder = order;
+        int valueOrder = (order == 1) ? 2 : 1; // why??
+        int n = collect.getLength();
+        for (int i = 0; i < n; ++i) {
+            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(
+                    MapStringKeyCollections.fieldSpecs[i]);
+            Vector key = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(0), keyOrder);
+            Vector value = TestUtil.makeNewVectorInstance(
+                    (String)fieldSpecs.get(1), valueOrder);
+
+            HashMap map = new HashMap();
+            for (int j = 0; j< key.size(); j++) {
+                map.put(key.get(j), value.get(j));
             }
-
-            tx.commit();
-            // cache will be flushed
-            pi = null;
-            System.gc();
-
-            tx.begin();
-            // check new values
-            Hashtable secondSet = new Hashtable();
-            secondSet.put("keys", secondValue);
-            secondSet.put("values", firstValue);
-
-            checkValues(oid, secondSet);
-            pi = (MapStringKeyCollections) pm.getObjectById(oid, true);
-            pm.deletePersistent(pi);
-            tx.commit();
-            tx = null;
-        }
-        finally {
-            if ((tx != null) && tx.isActive())
-                tx.rollback();
+            collect.set(i, map);
+            if (debug)
+                logger.debug("Set " + i + "th value to: " + map.toString());
         }
     }
 
-    private void checkValues(Object oid, Hashtable startValue)
+    /** */
+    private void checkValues(Object oid,
+            MapStringKeyCollections expectedValue)
     {
-        int i, j;
-
-        MapStringKeyCollections pi = (MapStringKeyCollections) pm.getObjectById(oid, true);
+        StringBuffer sbuf = new StringBuffer();
+        MapStringKeyCollections pi = (MapStringKeyCollections)
+                pm.getObjectById(oid, true);
         int n = pi.getLength();
-
-        Hashtable keySet = (Hashtable) startValue.get("keys");
-        Hashtable valueSet = (Hashtable) startValue.get("values");
-
-        for( i = 0; i < n; ++i){
-            Vector fieldSpecs = TestUtil.getFieldSpecsForMap(MapStringKeyCollections.fieldSpecs[i]);
-            String fieldType = (String)fieldSpecs.get(0);
-            String valueType = (String)fieldSpecs.get(1);
-            Map compareWith = new HashMap();
-
-            Vector keys = (Vector) keySet.get(fieldType);
-            Vector values = (Vector) valueSet.get(valueType);
-            int sz = keys.size();
-            for (j = 0; j < sz; j++) {
-                compareWith.put(keys.get(j), values.get(j));
-            }
-
+        for (int i = 0; i < n; ++i) {
+            Map compareWith = expectedValue.get(i);
             Map val = pi.get(i);
-
-            if(!val.equals(compareWith)){
-                fail(ASSERTION_FAILED,
-                     "Incorrect value for " + MapStringKeyCollections.fieldSpecs[i]);
+            if (val.size() != compareWith.size()) {
+                sbuf.append("\nFor element " + i + ", expected size = " +
+                        compareWith.size() + ", actual size = " + val.size()
+                        + " . ");
+                continue;
+            }
+            if (! val.equals(compareWith)) {
+                sbuf.append("\nFor element " + i + ", expected = " +
+                        compareWith + ", actual = " + val + " . ");
             }
+        }
+        if (sbuf.length() > 0) {
+            fail(ASSERTION_FAILED,
+                 "Expected and observed do not match!!" + sbuf.toString());
         }
     }
 }



Mime
View raw message