Uploaded image for project: 'Commons JXPath'
  1. Commons JXPath
  2. JXPATH-26

pointers obtained from iteratePointers() fails to setValue()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • Operating System: Linux
      Platform: PC

    • 13380

    Description

      I'm trying to iterate pointers, and set values. However any values I set using
      this method are ignored. This sounds similar to COM-72

      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");
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            scott@schram.net Scott Schram
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: