1 61 62 package org.jaxen; 63 64 65 import javax.xml.parsers.DocumentBuilderFactory ; 66 import javax.xml.parsers.ParserConfigurationException ; 67 68 import org.jaxen.dom.DOMXPath; 69 70 import junit.framework.TestCase; 71 72 73 77 public class UnresolvableExceptionTest extends TestCase { 78 79 public UnresolvableExceptionTest(String name) { 80 super(name); 81 } 82 83 private org.w3c.dom.Document doc; 84 85 protected void setUp() throws ParserConfigurationException { 86 87 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 88 factory.setNamespaceAware(true); 89 doc = factory.newDocumentBuilder().newDocument(); 90 doc.appendChild(doc.createElement("foo")); 91 } 92 93 public void testUnresolvableVariable() throws JaxenException { 94 95 try { 96 BaseXPath xpath = new DOMXPath("//foo[bar = $var]"); 97 xpath.evaluate(doc); 98 fail("Didn't throw Unresolvable Exception"); 99 } 100 catch (UnresolvableException ex) { 101 assertNotNull(ex.getMessage()); 102 } 103 } 104 105 106 public void testUnresolvableFunction() throws JaxenException { 107 108 try { 109 BaseXPath xpath = new DOMXPath("nonesuch()"); 110 xpath.evaluate(doc); 111 fail("Didn't throw Unresolvable Exception"); 112 } 113 catch (UnresolvableException ex) { 114 assertNotNull(ex.getMessage()); 115 } 116 } 117 118 119 120 } 121 | Popular Tags |