/**
* Test contributed by Kate Dvortsova
*/
public void testIteratePointerSetValue() {
JXPathContext context = JXPathContext.newContext(createContextBean());
assertXPathValue(context, "/beans[1]/name", "Name 1");
assertXPathValue(context, "/beans[2]/name", "Name 2");
// Test setting via context
context.setValue("/beans[2]/name", "Name 2 set");
assertXPathValue(context, "/beans[2]/name", "Name 2 set");
// Restore original value
context.setValue("/beans[2]/name", "Name 2");
assertXPathValue(context, "/beans[2]/name", "Name 2");
int iterCount = 0;
Iterator iter = context.iteratePointers("/beans/name");
while (iter.hasNext()) {
iterCount++;
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, iterCount);
assertXPathValue(context, "/beans[1]/name", "Name 1suffix");
assertXPathValue(context, "/beans[2]/name", "Name 2suffix");