1 7 8 package org.dom4j.rule; 9 10 import junit.textui.TestRunner; 11 12 import org.dom4j.AbstractTestCase; 13 import org.dom4j.DocumentFactory; 14 15 21 public class PriorityTest extends AbstractTestCase { 22 public static void main(String [] args) { 23 TestRunner.run(PriorityTest.class); 24 } 25 26 public void testNameNode() throws Exception { 27 testPriority("foo", 0); 28 } 29 30 public void testFilter() throws Exception { 31 testPriority("foo[@id='123']", 0.5); 32 } 33 34 public void testURI() throws Exception { 35 testPriority("foo:*", -0.25); 36 } 37 38 public void testAnyNode() throws Exception { 39 testPriority("*", -0.5); 40 } 41 42 protected void testPriority(String expr, double priority) throws Exception { 43 System.out.println("parsing: " + expr); 44 45 Pattern pattern = DocumentFactory.getInstance().createPattern(expr); 46 double d = pattern.getPriority(); 47 48 System.out.println("expr: " + expr + " has priority: " + d); 49 System.out.println("pattern: " + pattern); 50 51 assertEquals("expr: " + expr, new Double (priority), new Double (d)); 52 } 53 } 54 55 91 | Popular Tags |