1 16 package org.apache.commons.jxpath.ri.compiler; 17 18 import org.apache.commons.jxpath.JXPathTestCase; 19 import org.apache.commons.jxpath.ri.Parser; 20 21 27 28 public class ContextDependencyTest extends JXPathTestCase { 29 public ContextDependencyTest(String name) { 30 super(name); 31 } 32 33 public void testContextDependency() { 34 testContextDependency("1", false); 35 testContextDependency("$x", false); 36 testContextDependency("/foo", false); 37 testContextDependency("foo", true); 38 testContextDependency("/foo[3]", false); 39 testContextDependency("/foo[$x]", false); 40 testContextDependency("/foo[bar]", true); 41 testContextDependency("3 + 5", false); 42 testContextDependency("test:func(3, 5)", true); 43 testContextDependency("test:func(3, foo)", true); 44 } 45 46 public void testContextDependency(String xpath, boolean expected) { 47 Expression expr = 48 (Expression) Parser.parseExpression(xpath, new TreeCompiler()); 49 50 assertEquals( 51 "Context dependency <" + xpath + ">", 52 expected, 53 expr.isContextDependent()); 54 } 55 } | Popular Tags |