KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dom4j > xpath > ObjectTest


1 /*
2  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
3  *
4  * This software is open source.
5  * See the bottom of this file for the licence.
6  */

7
8 package org.dom4j.xpath;
9
10 import junit.textui.TestRunner;
11
12 import org.dom4j.AbstractTestCase;
13 import org.dom4j.Node;
14 import org.dom4j.XPath;
15
16 /**
17  * Test harness for numeric XPath expressions
18  *
19  * @author <a HREF="mailto:james.strachan@metastuff.com">James Strachan </a>
20  * @version $Revision: 1.3 $
21  */

22 public class ObjectTest extends AbstractTestCase {
23     protected static String JavaDoc[] paths = {"name(/.)", "name()"};
24
25     public static void main(String JavaDoc[] args) {
26         TestRunner.run(ObjectTest.class);
27     }
28
29     // Test case(s)
30
// -------------------------------------------------------------------------
31
public void testXPaths() throws Exception JavaDoc {
32         Node element = document.selectSingleNode("//author");
33         int size = paths.length;
34
35         for (int i = 0; i < size; i++) {
36             testXPath(document, paths[i]);
37             testXPath(element, paths[i]);
38         }
39     }
40
41     // Implementation methods
42
// -------------------------------------------------------------------------
43
protected void testXPath(Node node, String JavaDoc xpathText) {
44         XPath xpath = node.createXPath(xpathText);
45         Object JavaDoc object = xpath.evaluate(node);
46     }
47 }
48
49 /*
50  * Redistribution and use of this software and associated documentation
51  * ("Software"), with or without modification, are permitted provided that the
52  * following conditions are met:
53  *
54  * 1. Redistributions of source code must retain copyright statements and
55  * notices. Redistributions must also contain a copy of this document.
56  *
57  * 2. Redistributions in binary form must reproduce the above copyright notice,
58  * this list of conditions and the following disclaimer in the documentation
59  * and/or other materials provided with the distribution.
60  *
61  * 3. The name "DOM4J" must not be used to endorse or promote products derived
62  * from this Software without prior written permission of MetaStuff, Ltd. For
63  * written permission, please contact dom4j-info@metastuff.com.
64  *
65  * 4. Products derived from this Software may not be called "DOM4J" nor may
66  * "DOM4J" appear in their names without prior written permission of MetaStuff,
67  * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
68  *
69  * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
70  *
71  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
72  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
73  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
74  * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
75  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
76  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
77  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
78  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
79  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
80  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
81  * POSSIBILITY OF SUCH DAMAGE.
82  *
83  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
84  */

85
Popular Tags