KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jxpath > ri > axes > RecursiveAxesTest


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc name) {
31         super(name);
32     }
33
34     public static void main(String JavaDoc[] args) {
35         junit.textui.TestRunner.run(RecursiveAxesTest.class);
36     }
37
38     /**
39      * @see TestCase#setUp()
40      */

41     protected void setUp() throws Exception JavaDoc {
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(
57             context,
58             "//.[name = 'three']",
59             "/first/first/second");
60     }
61 }
62
63
Popular Tags