1 7 8 package org.dom4j.xpath; 9 10 import junit.textui.TestRunner; 11 12 import org.dom4j.AbstractTestCase; 13 import org.dom4j.XPath; 14 15 21 public class BadPathTest extends AbstractTestCase { 22 private String [] paths = {"+", "/foo/bar/"}; 23 24 public static void main(String [] args) { 25 TestRunner.run(BadPathTest.class); 26 } 27 28 public void testBadPaths() throws Exception { 31 for (int i = 0, size = paths.length; i < size; i++) { 32 String path = paths[i]; 33 testBadPath(path); 34 } 35 } 36 37 protected void testBadPath(String path) throws Exception { 38 try { 39 document.selectObject(path); 40 41 fail("Should have thrown exception for: " + path); 42 } catch (Exception e) { 43 log("Successfully caught: " + e); 44 } 45 46 try { 47 XPath xpath = document.createXPath(path); 48 49 fail("Should have thrown exception for: " + path); 50 } catch (Exception e) { 51 log("Successfully caught: " + e); 52 } 53 } 54 } 55 56 92 | Popular Tags |