1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jxpath.ri.axes;
17
18 import org.apache.commons.jxpath.JXPathContext;
19 import org.apache.commons.jxpath.JXPathTestCase;
20
21 /***
22 * Test for the protection mechanism that stops infinite recursion
23 * in descent down a recursive graph.
24 */
25 public class RecursiveAxesTest extends JXPathTestCase {
26
27 private RecursiveBean bean;
28 private JXPathContext context;
29
30 public RecursiveAxesTest(String name) {
31 super(name);
32 }
33
34 public static void main(String[] args) {
35 junit.textui.TestRunner.run(RecursiveAxesTest.class);
36 }
37
38 /***
39 * @see TestCase#setUp()
40 */
41 protected void setUp() throws Exception {
42 bean = new RecursiveBean("zero");
43 RecursiveBean bean1 = new RecursiveBean("one");
44 RecursiveBean bean2 = new RecursiveBean("two");
45 RecursiveBean bean3 = new RecursiveBean("three");
46 bean.setFirst(bean1);
47 bean1.setFirst(bean2);
48 bean2.setFirst(bean1);
49 bean2.setSecond(bean3);
50
51 context = JXPathContext.newContext(null, bean);
52 }
53
54 public void testInfiniteDescent() {
55
56 assertXPathPointer(
57 context,
58 "//.[name = 'three']",
59 "/first/first/second");
60 }
61 }
62