1 61 62 63 package org.jaxen.xom; 64 65 import java.io.IOException ; 66 import java.util.Iterator ; 67 import java.util.List ; 68 69 import junit.framework.TestCase; 70 import nu.xom.Builder; 71 import nu.xom.Document; 72 import nu.xom.Element; 73 import nu.xom.ParsingException; 74 75 import org.jaxen.JaxenException; 76 import org.jaxen.XPath; 77 78 public class XPathTest extends TestCase 79 { 80 81 private static final String BASIC_XML = "xml/basic.xml"; 82 83 public XPathTest(String name) 84 { 85 super( name ); 86 } 87 88 public void testConstruction() throws JaxenException 89 { 90 new XOMXPath( "/foo/bar/baz" ); 91 } 92 93 public void testSelection() throws ParsingException, IOException , JaxenException 94 { 95 XPath xpath = new XOMXPath( "/foo/bar/baz" ); 96 97 Builder builder = new Builder(); 98 99 Document doc = builder.build( BASIC_XML ); 100 101 List results = xpath.selectNodes( doc ); 102 103 assertEquals( 3, 104 results.size() ); 105 106 Iterator iter = results.iterator(); 107 108 assertEquals( "baz", 109 ((Element)iter.next()).getLocalName() ); 110 111 assertEquals( "baz", 112 ((Element)iter.next()).getLocalName() ); 113 114 assertEquals( "baz", 115 ((Element)iter.next()).getLocalName() ); 116 117 assertTrue( ! iter.hasNext() ); 118 } 119 } 120 | Popular Tags |