1 9 10 package test.dom4j.rule; 11 12 import junit.framework.Test; 13 import junit.framework.TestCase; 14 import junit.framework.TestSuite; 15 import junit.textui.TestRunner; 16 import org.dom4j.DocumentFactory; 17 import org.dom4j.rule.Pattern; 18 19 24 public class TestPriority extends TestCase 25 { 26 public TestPriority(String name) { 27 super( name ); 28 } 29 30 public static void main(String [] args) { 31 TestRunner.run( suite() ); 32 } 33 34 public static Test suite() { 35 return new TestSuite( TestPriority.class ); 36 } 37 38 public void testNameNode() throws Exception { 39 testPriority( "foo", 0 ); 40 } 41 42 public void testQNameNode() throws Exception { 43 } 45 46 public void testFilter() throws Exception { 47 testPriority( "foo[@id='123']", 0.5 ); 48 } 49 50 public void testURI() throws Exception { 51 testPriority( "foo:*", -0.25); 52 } 53 54 public void testAnyNode() throws Exception { 55 testPriority( "*", -0.5 ); 56 } 57 58 protected void testPriority(String expr, double priority) throws Exception { 59 System.out.println( "parsing: " + expr ); 60 61 Pattern pattern = DocumentFactory.getInstance().createPattern( expr ); 62 double d = pattern.getPriority(); 63 64 System.out.println( "expr: " + expr + " has priority: " + d ); 65 System.out.println( "pattern: " + pattern ); 66 67 assertEquals( "expr: " + expr, new Double (priority), new Double (d) ); 68 } 69 } 70 | Popular Tags |