You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jason Horman <Ja...@pantero.com> on 2003/11/13 17:36:12 UTC
[jxpath] extension function bug
There seems to be a bug with ExtensionFunctions and collections as
parameters.
Example:
List list = new ArrayList();
list.add("foo");
list.add("bar");
context.getVariables().declareVariable("myList", list); Collection
values = context.getValue("test:getItems($myList)");
* Values returns: [bar, bar] not [foo, bar]
Extension Function:
public static Collection getItems(Collection items) {
return items;
}
It seems that the iterator building the collection is always returning
the last element. Since the existing unit test
(ExtensionFunctionTest.testCollectionMethodCall) is only testing the
size, the test passes. I added a test to check the actual values passed
to the extension function.
Diff of ExtensionFunctionTest.java
270a271,282
> public void testCollectionMethodCall2() {
> List list = new ArrayList();
> list.add("foo");
> list.add("bar");
> context.getVariables().declareVariable("myList", list);
>
> assertXPathValue(
> context,
> "test:getItems($myList)",
> list);
> }
>
Diff of TestFunctions.java
168c168,172
<
---
>
> public static Collection getItems(Collection items) {
> return items;
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [jxpath] extension function bug
Posted by Dmitri Plotnikov <dm...@apache.org>.
Jason,
Thank you very much for reporting this problem. It is now fixed.
- Dmitri
----- Original Message -----
From: "Jason Horman" <Ja...@pantero.com>
To: <co...@jakarta.apache.org>
Sent: Thursday, November 13, 2003 11:36 AM
Subject: [jxpath] extension function bug
There seems to be a bug with ExtensionFunctions and collections as
parameters.
Example:
List list = new ArrayList();
list.add("foo");
list.add("bar");
context.getVariables().declareVariable("myList", list); Collection
values = context.getValue("test:getItems($myList)");
* Values returns: [bar, bar] not [foo, bar]
Extension Function:
public static Collection getItems(Collection items) {
return items;
}
It seems that the iterator building the collection is always returning
the last element. Since the existing unit test
(ExtensionFunctionTest.testCollectionMethodCall) is only testing the
size, the test passes. I added a test to check the actual values passed
to the extension function.
Diff of ExtensionFunctionTest.java
270a271,282
> public void testCollectionMethodCall2() {
> List list = new ArrayList();
> list.add("foo");
> list.add("bar");
> context.getVariables().declareVariable("myList", list);
>
> assertXPathValue(
> context,
> "test:getItems($myList)",
> list);
> }
>
Diff of TestFunctions.java
168c168,172
<
---
>
> public static Collection getItems(Collection items) {
> return items;
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org