db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcai...@apache.org
Subject svn commit: r345613 - /incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/
Date Sat, 19 Nov 2005 00:49:46 GMT
Author: mcaisse
Date: Fri Nov 18 16:49:40 2005
New Revision: 345613

URL: http://svn.apache.org/viewcvs?rev=345613&view=rev
Log:
JDO-218

Modified:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringValueCollections.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestUtil.java

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=345613&r1=345612&r2=345613&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
Fri Nov 18 16:49:40 2005
@@ -169,22 +169,31 @@
             else if (! expected.equals(actual)) {
                 if (TestUtil.getFieldSpecsForMap(
                             HashMapStringValueCollections.fieldSpecs[i]
-                            ).get(1).equals("BigDecimal")) {
-                    Set keys = expected.keySet();
-                    Iterator iter = keys.iterator();
-                    while (iter.hasNext()) {
-                        Object nextKey = iter.next();
-                        BigDecimal expectedMapValue = 
-                                (BigDecimal)expected.get(nextKey);
-                        BigDecimal actualMapValue = 
-                                (BigDecimal)actual.get(nextKey);
-                        if ((expectedMapValue.compareTo(actualMapValue) != 0)) {
-                            sbuf.append("\nFor element " + i + "(" 
-                                    + (String)nextKey +
-                                    "), expected = " + expectedMapValue +
-                                    ", actual = " + actualMapValue + " . ");
+                            ).get(0).equals("BigDecimal")) {
+                    Set expectedKeySet = expected.keySet();
+                    Set actualKeySet = actual.keySet();
+                    Iterator expectedIter = expectedKeySet.iterator();
+                    while (expectedIter.hasNext()) {
+                        BigDecimal expectedKey = (BigDecimal) expectedIter.next();
+                        // compare keys
+                        if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) {
+                            sbuf.append("\nFor element " + i +
+                                    " expected key = " + expectedKey +
+                                    " not found in actual Map.  Actual keyset is "
+                                    + actualKeySet.toString());
+                        // compare values
+                        } else {
+                            String expectedVal = (String) expected.get(expectedKey);
+                            String actualValue = (String)
+                               actual.get(TestUtil.getBigDecimalKey(expectedKey,
+                                                                    actualKeySet));
+                            if (!expectedVal.equals(actualValue)) {
+                                sbuf.append("\nFor element " + i +
+                                    " expected value = " + expectedVal +
+                                    " actual Value = " + actualValue);
+                           }
+                       }
                     }
-                }
             }
             else {
                 sbuf.append("\nFor element " + i + ", expected = " +

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=345613&r1=345612&r2=345613&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
Fri Nov 18 16:49:40 2005
@@ -168,22 +168,31 @@
             else if (! expected.equals(actual)) {
                 if (TestUtil.getFieldSpecsForMap(
                             HashtableStringValueCollections.fieldSpecs[i]
-                            ).get(1).equals("BigDecimal")) {
-                    Set keys = expected.keySet();
-                    Iterator iter = keys.iterator();
-                    while (iter.hasNext()) {
-                        Object nextKey = iter.next();
-                        BigDecimal expectedMapValue = 
-                                (BigDecimal)expected.get(nextKey);
-                        BigDecimal actualMapValue = 
-                                (BigDecimal)actual.get(nextKey);
-                        if ((expectedMapValue.compareTo(actualMapValue) != 0)) {
-                            sbuf.append("\nFor element " + i + "(" 
-                                    + (String)nextKey +
-                                    "), expected = " + expectedMapValue +
-                                    ", actual = " + actualMapValue + " . ");
+                            ).get(0).equals("BigDecimal")) {
+                    Set expectedKeySet = expected.keySet();
+                    Set actualKeySet = actual.keySet();
+                    Iterator expectedIter = expectedKeySet.iterator();
+                    while (expectedIter.hasNext()) {
+                        BigDecimal expectedKey = (BigDecimal) expectedIter.next();
+                        // compare keys
+                        if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) {
+                            sbuf.append("\nFor element " + i +
+                                    " expected key = " + expectedKey +
+                                    " not found in actual Map.  Actual keyset is "
+                                    + actualKeySet.toString());
+                        // compare values
+                        } else {
+                            String expectedVal = (String) expected.get(expectedKey);
+                            String actualValue = (String)
+                               actual.get(TestUtil.getBigDecimalKey(expectedKey,
+                                                                    actualKeySet));
+                            if (!expectedVal.equals(actualValue)) {
+                                sbuf.append("\nFor element " + i +
+                                    " expected value = " + expectedVal +
+                                    " actual Value = " + actualValue);
+                           }
+                       }
                     }
-                }
             }
             else {
                 sbuf.append("\nFor element " + i + ", expected = " +

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java?rev=345613&r1=345612&r2=345613&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java
Fri Nov 18 16:49:40 2005
@@ -173,22 +173,31 @@
             else if (! expected.equals(actual)) {
                 if (TestUtil.getFieldSpecsForMap(
                             MapStringValueCollections.fieldSpecs[i]
-                            ).get(1).equals("BigDecimal")) {
-                    Set keys = expected.keySet();
-                    Iterator iter = keys.iterator();
-                    while (iter.hasNext()) {
-                        Object nextKey = iter.next();
-                        BigDecimal expectedMapValue = 
-                                (BigDecimal)expected.get(nextKey);
-                        BigDecimal actualMapValue = 
-                                (BigDecimal)actual.get(nextKey);
-                        if ((expectedMapValue.compareTo(actualMapValue) != 0)) {
-                            sbuf.append("\nFor element " + i + "(" 
-                                    + (String)nextKey +
-                                    "), expected = " + expectedMapValue +
-                                    ", actual = " + actualMapValue + " . ");
+                            ).get(0).equals("BigDecimal")) {
+                    Set expectedKeySet = expected.keySet();
+                    Set actualKeySet = actual.keySet();
+                    Iterator expectedIter = expectedKeySet.iterator();
+                    while (expectedIter.hasNext()) {
+                        BigDecimal expectedKey = (BigDecimal) expectedIter.next();
+                        // compare keys
+                        if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) {
+                            sbuf.append("\nFor element " + i +
+                                    " expected key = " + expectedKey +
+                                    " not found in actual Map.  Actual keyset is "
+                                    + actualKeySet.toString());
+                        // compare values
+                        } else {
+                            String expectedVal = (String) expected.get(expectedKey);
+                            String actualValue = (String)
+                               actual.get(TestUtil.getBigDecimalKey(expectedKey,
+                                                                    actualKeySet));
+                            if (!expectedVal.equals(actualValue)) {
+                                sbuf.append("\nFor element " + i +
+                                    " expected value = " + expectedVal +
+                                    " actual Value = " + actualValue);
+                           }
+                       }
                     }
-                }
             }
             else {
                 sbuf.append("\nFor element " + i + ", expected = " +

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringValueCollections.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringValueCollections.java?rev=345613&r1=345612&r2=345613&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringValueCollections.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringValueCollections.java
Fri Nov 18 16:49:40 2005
@@ -166,28 +166,37 @@
             else if (! expected.equals(actual)) {
                 if (TestUtil.getFieldSpecsForMap(
                             TreeMapStringValueCollections.fieldSpecs[i]
-                            ).get(1).equals("BigDecimal")) {
-                    Set keys = expected.keySet();
-                    Iterator iter = keys.iterator();
-                    while (iter.hasNext()) {
-                        Object nextKey = iter.next();
-                        BigDecimal expectedMapValue = 
-                                (BigDecimal)expected.get(nextKey);
-                        BigDecimal actualMapValue = 
-                                (BigDecimal)actual.get(nextKey);
-                        if ((expectedMapValue.compareTo(actualMapValue) != 0)) {
-                            sbuf.append("\nFor element " + i + "(" 
-                                    + (String)nextKey +
-                                    "), expected = " + expectedMapValue +
-                                    ", actual = " + actualMapValue + " . ");
+                            ).get(0).equals("BigDecimal")) {
+                    Set expectedKeySet = expected.keySet();
+                    Set actualKeySet = actual.keySet();
+                    Iterator expectedIter = expectedKeySet.iterator();
+                    while (expectedIter.hasNext()) {
+                        BigDecimal expectedKey = (BigDecimal) expectedIter.next();
+                        // compare keys
+                        if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) {
+                            sbuf.append("\nFor element " + i +
+                                    " expected key = " + expectedKey +
+                                    " not found in actual Map.  Actual keyset is "
+                                    + actualKeySet.toString());
+                        // compare values
+                        } else {
+                            String expectedVal = (String) expected.get(expectedKey);
+                            String actualValue = (String)
+                               actual.get(TestUtil.getBigDecimalKey(expectedKey,
+                                                                    actualKeySet));
+                            if (!expectedVal.equals(actualValue)) {
+                                sbuf.append("\nFor element " + i +
+                                    " expected value = " + expectedVal +
+                                    " actual Value = " + actualValue);
+                           }
+                       }
                     }
                 }
-            }
-            else {
+                else {
                 sbuf.append("\nFor element " + i + ", expected = " +
                     expected + ", actual = " + actual + " . ");
+                }
             }
-          }
         }
         if (sbuf.length() > 0) {
             fail(ASSERTION_FAILED,

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestUtil.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestUtil.java?rev=345613&r1=345612&r2=345613&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestUtil.java
(original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/models/fieldtypes/TestUtil.java
Fri Nov 18 16:49:40 2005
@@ -319,5 +319,31 @@
           default:
                throw new IndexOutOfBoundsException();
           }
-      }
+    }
+
+    protected static boolean containsBigDecimalKey(BigDecimal keyValue,
+                                                Set bigDecimalKeySet)
+    {
+        Iterator iter = bigDecimalKeySet.iterator();
+        while (iter.hasNext()) {
+            BigDecimal nextVal = (BigDecimal) iter.next();
+            if (keyValue.compareTo(nextVal) == 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    protected static BigDecimal getBigDecimalKey(BigDecimal keyValue,
+                                                Set bigDecimalKeySet)
+    {
+        Iterator iter = bigDecimalKeySet.iterator();
+        while (iter.hasNext()) {
+            BigDecimal nextVal = (BigDecimal) iter.next();
+            if (keyValue.compareTo(nextVal) == 0) {
+                return nextVal;
+            }
+        }
+        return null;
+    }
 }



Mime
View raw message