KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > dom4j > xpath > TestUriMap


1 /*
2  * Copyright 2001 (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  * $Id: TestUriMap.java,v 1.1 2003/07/07 10:30:30 per_nyfelt Exp $
8  */

9
10 package test.dom4j.xpath;
11
12 import junit.framework.Test;
13 import junit.framework.TestSuite;
14 import junit.textui.TestRunner;
15 import org.dom4j.Node;
16 import org.dom4j.XPath;
17 import org.dom4j.io.SAXReader;
18 import test.dom4j.AbstractTestCase;
19
20 import java.io.File JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.Map JavaDoc;
23
24 /** Tests the use of a Map for defining namespace URIs
25   *
26   * @author <a HREF="mailto:jstrachan@apache.org">James Strachan</a>
27   * @version $Revision: 1.1 $
28   */

29 public class TestUriMap extends AbstractTestCase {
30
31     public static void main( String JavaDoc[] args ) {
32         TestRunner.run( suite() );
33     }
34
35     public static Test suite() {
36         return new TestSuite( TestUriMap.class );
37     }
38
39     public TestUriMap(String JavaDoc name) {
40         super(name);
41     }
42
43     // Test case(s)
44
//-------------------------------------------------------------------------
45
public void testURIMap() throws Exception JavaDoc {
46         Map JavaDoc uris = new HashMap JavaDoc();
47         uris.put( "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/" );
48         uris.put( "m", "urn:xmethodsBabelFish" );
49         XPath xpath = document.createXPath( "/SOAP-ENV:Envelope/SOAP-ENV:Body/m:BabelFish" );
50         xpath.setNamespaceURIs( uris );
51         Node babelfish = xpath.selectSingleNode( document );
52
53         //log( "Found: " + babelfish );
54

55         assertTrue( "Found valid node", babelfish != null );
56     }
57
58     protected void setUp() throws Exception JavaDoc {
59         document = new SAXReader().read( new File JavaDoc( "xml/soap.xml" ) );
60     }
61 }
62
63
64
65
66 /*
67  * Redistribution and use of this software and associated documentation
68  * ("Software"), with or without modification, are permitted provided
69  * that the following conditions are met:
70  *
71  * 1. Redistributions of source code must retain copyright
72  * statements and notices. Redistributions must also contain a
73  * copy of this document.
74  *
75  * 2. Redistributions in binary form must reproduce the
76  * above copyright notice, this list of conditions and the
77  * following disclaimer in the documentation and/or other
78  * materials provided with the distribution.
79  *
80  * 3. The name "DOM4J" must not be used to endorse or promote
81  * products derived from this Software without prior written
82  * permission of MetaStuff, Ltd. For written permission,
83  * please contact dom4j-info@metastuff.com.
84  *
85  * 4. Products derived from this Software may not be called "DOM4J"
86  * nor may "DOM4J" appear in their names without prior written
87  * permission of MetaStuff, Ltd. DOM4J is a registered
88  * trademark of MetaStuff, Ltd.
89  *
90  * 5. Due credit should be given to the DOM4J Project
91  * (http://dom4j.org/).
92  *
93  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
94  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
95  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
96  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
97  * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
98  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
99  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
100  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
101  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
102  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
103  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
104  * OF THE POSSIBILITY OF SUCH DAMAGE.
105  *
106  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
107  *
108  * $Id: TestUriMap.java,v 1.1 2003/07/07 10:30:30 per_nyfelt Exp $
109  */

110
Popular Tags