You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by "Michelle Caisse (JIRA)" <ji...@apache.org> on 2005/11/17 22:50:41 UTC

[jira] Updated: (JDO-218) checkValues() method of *MapStringValueCollections doesn't work

     [ http://issues.apache.org/jira/browse/JDO-218?page=all ]

Michelle Caisse updated JDO-218:
--------------------------------

    Attachment: JDO-218.patch

The attached patch fixes the BigDecimal comparison problem. All *MapStringValueCollections tests pass using application identity with this patch applied.
The relevant new code (taking TestMapStringKeyCollections.java as an example)  is:

            else if (! expected.equals(actual)) {
                if (TestUtil.getFieldSpecsForMap(
                            MapStringValueCollections.fieldSpecs[i]
                            ).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);
                           }
                       }
                    }
            }
Two new static functions were added to TestUtil.java. boolean containsBigDecimalKey(BigDecimal expectedKey, Set actualKeySet) and BigDecimal getBigDecimalKey(BigDecimal expectedKey, Set actualKeySet) use BigDecimal.compareTo to determine equality of two keys.

> checkValues() method of *MapStringValueCollections doesn't work
> ---------------------------------------------------------------
>
>          Key: JDO-218
>          URL: http://issues.apache.org/jira/browse/JDO-218
>      Project: JDO
>         Type: Bug
>   Components: tck20
>     Reporter: Michelle Caisse
>     Assignee: Michelle Caisse
>  Attachments: JDO-218.patch
>
> No map fields with BigDecimal values compare okay.  There are several problems.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira