commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Plotnikov" <dmi...@apache.org>
Subject Re: [jxpath] extension function bug
Date Sat, 24 Jan 2004 02:17:39 GMT
Jason,

Thank you very much for reporting this problem. It is now fixed.

- Dmitri

----- Original Message ----- 
From: "Jason Horman" <Jason.Horman@pantero.com>
To: <commons-dev@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


Mime
View raw message