commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giacomo Pati <giac...@apache.org>
Subject [jxpath] Bug in JXPathContext.removeAll() ?
Date Wed, 23 Nov 2005 13:42:39 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi all

I've tried to get my head around the JXPathContext.removeAll() not 
working as expected. I've written a TestCase:

     public void testRemoveAllFromCollection() {
         final Map map = new HashMap();
         final Collection list = new ArrayList();
         for(int i = 0; i < 20; i++) {
             list.add("" + i);
         }
         map.put( "list", list);
         JXPathContext context = JXPathContext.newContext(null, map);
         context.removeAll( "list" );
         assertEquals("not all items removed", 0, list.size() );
     }

After the test the list will still have 19 entries with the last one 
removed.

While this:


     public void testRemoveAllFromCollectionIterated() {
         final Map map = new HashMap();
         final Collection list = new ArrayList();
         for(int i = 0; i < 20; i++) {
             list.add("" + i);
         }
         map.put( "list", list);
         JXPathContext context = JXPathContext.newContext(null, map);
         for(int i = 0; i < 20; i++) {
             context.removePath("list[1]");
         }
         assertEquals("not all items removed", 0, list.size() );
     }

works as expected.

I've looked around in the code but am hopelessly lost what the issue 
could be to produce a patch. The only thing I've covered is that in 
DynamicPropertyPointer.remove() at #251 it always removes the last entry 
in the collection.

I will file a bug in Bugzilla for it.

Ciao

Giacomo

- -- 
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDhHHRLNdJvZjjVZARAtZxAKCJmx4oghf/xoat59pQYQT9dfTbxwCgsoC0
l29NM0u5F46SVKBsQV0ZsG8=
=2JMv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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