01: /*
02: * Copyright 1999-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
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: // Existing scalar property
56: assertXPathPointer(context, "//.[name = 'three']",
57: "/first/first/second");
58: }
59: }
|