1 /*
2 * Copyright 2001-2004 (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.5 2004/06/25 08:03:51 maartenc Exp $
8 */
9
10 package org.dom4j.xpath;
11
12 import java.io.File;
13 import java.util.HashMap;
14 import java.util.Map;
15
16 import junit.framework.Test;
17 import junit.framework.TestSuite;
18 import junit.textui.TestRunner;
19
20 import org.dom4j.AbstractTestCase;
21 import org.dom4j.Node;
22 import org.dom4j.XPath;
23 import org.dom4j.io.SAXReader;
24
25 /*** Tests the use of a Map for defining namespace URIs
26 *
27 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
28 * @version $Revision: 1.5 $
29 */
30 public class TestUriMap extends AbstractTestCase {
31
32 public static void main( String[] args ) {
33 TestRunner.run( suite() );
34 }
35
36 public static Test suite() {
37 return new TestSuite( TestUriMap.class );
38 }
39
40 public TestUriMap(String name) {
41 super(name);
42 }
43
44 // Test case(s)
45 //-------------------------------------------------------------------------
46 public void testURIMap() throws Exception {
47 Map uris = new HashMap();
48 uris.put( "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/" );
49 uris.put( "m", "urn:xmethodsBabelFish" );
50 XPath xpath = document.createXPath( "/SOAP-ENV:Envelope/SOAP-ENV:Body/m:BabelFish" );
51 xpath.setNamespaceURIs( uris );
52 Node babelfish = xpath.selectSingleNode( document );
53
54 //log( "Found: " + babelfish );
55
56 assertTrue( "Found valid node", babelfish != null );
57 }
58
59 protected void setUp() throws Exception {
60 document = new SAXReader().read( new File( "xml/soap.xml" ) );
61 }
62 }
63
64
65
66
67 /*
68 * Redistribution and use of this software and associated documentation
69 * ("Software"), with or without modification, are permitted provided
70 * that the following conditions are met:
71 *
72 * 1. Redistributions of source code must retain copyright
73 * statements and notices. Redistributions must also contain a
74 * copy of this document.
75 *
76 * 2. Redistributions in binary form must reproduce the
77 * above copyright notice, this list of conditions and the
78 * following disclaimer in the documentation and/or other
79 * materials provided with the distribution.
80 *
81 * 3. The name "DOM4J" must not be used to endorse or promote
82 * products derived from this Software without prior written
83 * permission of MetaStuff, Ltd. For written permission,
84 * please contact dom4j-info@metastuff.com.
85 *
86 * 4. Products derived from this Software may not be called "DOM4J"
87 * nor may "DOM4J" appear in their names without prior written
88 * permission of MetaStuff, Ltd. DOM4J is a registered
89 * trademark of MetaStuff, Ltd.
90 *
91 * 5. Due credit should be given to the DOM4J Project -
92 * http://www.dom4j.org
93 *
94 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
95 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
96 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
97 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
98 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
99 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
100 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
101 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
102 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
103 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
104 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
105 * OF THE POSSIBILITY OF SUCH DAMAGE.
106 *
107 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
108 *
109 * $Id: TestUriMap.java,v 1.5 2004/06/25 08:03:51 maartenc Exp $
110 */