1 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 ; 21 import java.util.HashMap ; 22 import java.util.Map ; 23 24 29 public class TestUriMap extends AbstractTestCase { 30 31 public static void main( String [] args ) { 32 TestRunner.run( suite() ); 33 } 34 35 public static Test suite() { 36 return new TestSuite( TestUriMap.class ); 37 } 38 39 public TestUriMap(String name) { 40 super(name); 41 } 42 43 public void testURIMap() throws Exception { 46 Map uris = new HashMap (); 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 55 assertTrue( "Found valid node", babelfish != null ); 56 } 57 58 protected void setUp() throws Exception { 59 document = new SAXReader().read( new File ( "xml/soap.xml" ) ); 60 } 61 } 62 63 64 65 66 110 | Popular Tags |