1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.jxpath.issues;
19
20 import static org.junit.jupiter.api.Assertions.assertEquals;
21
22 import java.util.Iterator;
23
24 import org.apache.commons.jxpath.JXPathContext;
25 import org.apache.commons.jxpath.Pointer;
26 import org.junit.jupiter.api.Test;
27
28
29
30
31 public class JXPath118Test {
32
33 public static class SomeChildClass {
34
35 private int foo = 1;
36 private int bar = 2;
37 private int baz = 3;
38
39 public int getBar() {
40 return bar;
41 }
42
43 public int getBaz() {
44 return baz;
45 }
46
47 public int getFoo() {
48 return foo;
49 }
50
51 public void setBar(final int bar) {
52 this.bar = bar;
53 }
54
55 public void setBaz(final int baz) {
56 this.baz = baz;
57 }
58
59 public void setFoo(final int foo) {
60 this.foo = foo;
61 }
62 }
63
64 @Test
65 public void testJXPATH118IssueWithAsPath() throws Exception {
66 final Object contextBean = new SomeChildClass();
67 final JXPathContext context = JXPathContext.newContext(contextBean);
68 final Iterator<Pointer> iteratePointers = context.iteratePointers("//*");
69 assertEquals("/bar", iteratePointers.next().asPath());
70 assertEquals("/baz", iteratePointers.next().asPath());
71 assertEquals("/foo", iteratePointers.next().asPath());
72 }
73 }