1 61 62 package org.jaxen.function; 63 64 import javax.xml.parsers.DocumentBuilder ; 65 import javax.xml.parsers.DocumentBuilderFactory ; 66 import javax.xml.parsers.ParserConfigurationException ; 67 68 import junit.framework.TestCase; 69 70 import org.jaxen.FunctionCallException; 71 import org.jaxen.JaxenException; 72 import org.jaxen.XPath; 73 import org.jaxen.dom.DOMXPath; 74 import org.w3c.dom.Document ; 75 76 80 public class TrueTest extends TestCase { 81 82 private Document doc; 83 84 public void setUp() throws ParserConfigurationException 85 { 86 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 87 factory.setNamespaceAware(true); 88 DocumentBuilder builder = factory.newDocumentBuilder(); 89 doc = builder.newDocument(); 90 doc.appendChild(doc.createElement("root")); 91 } 92 93 94 public TrueTest(String name) { 95 super(name); 96 } 97 98 public void testTrueOfNumber() throws JaxenException 99 { 100 try 101 { 102 XPath xpath = new DOMXPath( "true(3)" ); 103 xpath.selectNodes( doc ); 104 fail("true() function took arguments"); 105 } 106 catch (FunctionCallException e) 107 { 108 assertEquals("true() requires no arguments.", e.getMessage()); 109 } 110 } 111 112 } 113 | Popular Tags |