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:39:41 UTC
[jira] Created: (JDO-218) checkValues() method of *MapStringValueCollections doesn't work
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
Assigned to: Michelle Caisse
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
[jira] Closed: (JDO-218) checkValues() method of
*MapStringValueCollections doesn't work
Posted by "Michael Bouschen (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JDO-218?page=all ]
Michael Bouschen closed JDO-218:
--------------------------------
Fix Version: JDO 2 beta
Resolution: Fixed
> 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
> Fix For: JDO 2 beta
> 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
[jira] Commented: (JDO-218) checkValues() method of *MapStringValueCollections doesn't work
Posted by "Michelle Caisse (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JDO-218?page=comments#action_12358040 ]
Michelle Caisse commented on JDO-218:
-------------------------------------
The code expects only BigDecimal keys. It is for the tests where the values are all String and the keys can be any of a number of types, specifically TestMapStringValueCollections, TestHashMapStringValueCollections, TestHashtableStringValueCollections, and TestTreeMapStringValueCollections. The checkValues() method in the Test*MapStringKeyCollections is different, but in those tests there would be only String keys.
It would be great to be able to generalize this method and pull the code out of the fieldtypes tests, but it is tricky because the data type of the Collection appears in the test. There are also casting and polymorphism issues which vary among the Collection (not Map) tests when iterating through the BigDecimal fields and make this difficult.
> 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
[jira] Reopened: (JDO-218) checkValues() method of
*MapStringValueCollections doesn't work
Posted by "Michael Bouschen (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JDO-218?page=all ]
Michael Bouschen reopened JDO-218:
----------------------------------
> 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
[jira] Closed: (JDO-218) checkValues() method of *MapStringValueCollections doesn't work
Posted by "Michelle Caisse (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JDO-218?page=all ]
Michelle Caisse closed JDO-218:
-------------------------------
Resolution: Fixed
revision 345613
> 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
[jira] Updated: (JDO-218) checkValues() method of *MapStringValueCollections doesn't work
Posted by "Michelle Caisse (JIRA)" <ji...@apache.org>.
[ 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
[jira] Commented: (JDO-218) checkValues() method of *MapStringValueCollections doesn't work
Posted by "Craig Russell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JDO-218?page=comments#action_12358029 ]
Craig Russell commented on JDO-218:
-----------------------------------
It seems like this code has a similar problem in case there is a BigDecimal as a value.
+ 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);
+ }
Could it be rewritten to use compareTo instead:
+ String expectedVal = (String) expected.get(expectedKey);
+ String actualValue = (String)
+ actual.get(TestUtil.getBigDecimalKey(expectedKey,
+ actualKeySet));
+ if (expectedVal.equals(actualValue)) {continue;}
if (expectedVal instanceof Comparable && ((Comparable)expectedVal.compareTo(actualValue)) == 0) {continue;}
+ sbuf.append("\nFor element " + i +
+ " expected value = " + expectedVal +
+ " actual Value = " + actualValue);
+ }
> 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
[jira] Commented: (JDO-218) checkValues() method of *MapStringValueCollections doesn't work
Posted by "Craig Russell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JDO-218?page=comments#action_12358044 ]
Craig Russell commented on JDO-218:
-----------------------------------
I totally missed that the expectedVal and actualVal were cast as Strings! My comments would apply to a more general method but not to this case.
-20-
> 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