commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Horman" <Jason.Hor...@pantero.com>
Subject [jxpath] extension function bug
Date Thu, 13 Nov 2003 16:36:12 GMT
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


Mime
View raw message