1 7 8 package org.dom4j.xpath; 9 10 import junit.textui.TestRunner; 11 12 import java.io.File ; 13 import java.util.HashMap ; 14 import java.util.Map ; 15 16 import org.dom4j.AbstractTestCase; 17 import org.dom4j.Node; 18 import org.dom4j.XPath; 19 import org.dom4j.io.SAXReader; 20 21 27 public class UriMapTest extends AbstractTestCase { 28 public static void main(String [] args) { 29 TestRunner.run(UriMapTest.class); 30 } 31 32 public void testURIMap() throws Exception { 35 Map uris = new HashMap (); 36 uris.put("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"); 37 uris.put("m", "urn:xmethodsBabelFish"); 38 39 String path = "/SOAP-ENV:Envelope/SOAP-ENV:Body/m:BabelFish"; 40 XPath xpath = document.createXPath(path); 41 xpath.setNamespaceURIs(uris); 42 43 Node babelfish = xpath.selectSingleNode(document); 44 45 assertTrue("Found valid node", babelfish != null); 47 } 48 49 protected void setUp() throws Exception { 50 super.setUp(); 51 document = new SAXReader().read(new File ("xml/soap.xml")); 52 } 53 } 54 55 91 | Popular Tags |