1 61 62 63 64 package org.jaxen.pattern; 65 66 import junit.framework.TestCase; 67 68 import org.jaxen.JaxenException; 69 import org.jaxen.saxpath.SAXPathException; 70 import org.jaxen.saxpath.XPathSyntaxException; 71 72 public class PatternHandlerTest extends TestCase 73 { 74 75 String [] paths = { 76 "foo", 77 "*", 78 "/", 79 "foo/bar", 80 "foo//bar", 81 "/*/foo", 82 "*[@name]", 83 "foo/bar[1]", 84 "foo[bar=\"contents\"]", 85 "foo[bar='contents']", 86 "foo|bar", 87 "foo/title | bar/title | xyz/title", 88 "/foo//*", 89 "foo/text()", 90 "foo/@*", 91 }; 92 93 String [] bogusPaths = { }; 94 95 String [] ignore_bogusPaths = { 96 "/foo/bar/", 98 99 "12 + sum(count(//author),count(//author/attribute::*)) / 2", 102 "id()/2", 103 "+" 104 }; 105 106 public PatternHandlerTest(String name) 107 { 108 super( name ); 109 } 110 111 public void testValidPaths() throws JaxenException, SAXPathException 112 { 113 for ( int i = 0; i < paths.length; i++ ) { 114 String path = paths[i]; 115 PatternParser.parse( path ); 116 } 117 } 118 119 public void testBogusPaths() throws JaxenException, SAXPathException 120 { 121 for ( int i = 0; i < bogusPaths.length; i++ ) { 122 String path = bogusPaths[i]; 123 try 124 { 125 Pattern pattern = PatternParser.parse( path ); 126 fail( "Parsed bogus path as: " + pattern ); 127 } 128 catch (XPathSyntaxException e) 129 { 130 } 131 } 132 133 } 134 } 135 | Popular Tags |