You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/10/07 21:25:54 UTC

DO NOT REPLY [Bug 13380] New: - pointers obtained from iteratePointers() fails to setValue()

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13380>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13380

pointers obtained from iteratePointers() fails to setValue()

           Summary: pointers obtained from iteratePointers() fails to
                    setValue()
           Product: Commons
           Version: Nightly Builds
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: JXPath
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: scott@schram.net


I'm trying to iterate pointers, and set values.  However any values I set using
this method are ignored.  This sounds similar to bug #9036

Note: It would be great if you like this test to add it to the suite.

Thanks!

To see the bug, add this function to NestedTestbean :

public void setName(String name) {
        this.name = name;
    }

Then, add this function to JXPathTestCase:

    public void testIteratePointerSetValue() {
        JXPathContext context = JXPathContext.newContext(bean);
        
        testGetValue(context, "/beans[1]/name", "Name 1"); 
        testGetValue(context, "/beans[2]/name", "Name 2");
        
        // Test setting via context
        context.setValue("/beans[2]/name", "Name 2 set");
        testGetValue(context, "/beans[2]/name", "Name 2 set");
        
        // Restore original value
        context.setValue("/beans[2]/name", "Name 2");
        testGetValue(context, "/beans[2]/name", "Name 2");
        
        int iter_count = 0;
        Iterator iter = context.iteratePointers("/beans/name");
        while (iter.hasNext()) {
            iter_count++;
            Pointer pointer = (Pointer) iter.next();
            String s = (String) pointer.getValue();
            s = s + "suffix";
            pointer.setValue(s);
            assertEquals("pointer.getValue", s, pointer.getValue());
            // fails right here, the value isn't getting set in the bean.
            assertEquals("context.getValue", s, context.getValue(pointer.asPath()));
        }
        assertEquals("Iteration count", 2, iter_count);
        
        testGetValue(context, "/beans[1]/name", "Name 1suffix"); 
        testGetValue(context, "/beans[2]/name", "Name 2suffix");
    }

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>