1 7 8 package org.dom4j.io; 9 10 import junit.textui.TestRunner; 11 12 import org.dom4j.AbstractTestCase; 13 import org.dom4j.ElementHandler; 14 15 20 public class DispatchHandlerTest extends AbstractTestCase { 21 public static void main(String [] args) { 22 TestRunner.run(DispatchHandlerTest.class); 23 } 24 25 public void testBug611445() throws Exception { 26 MyHandler handler = new MyHandler(); 27 28 SAXReader reader = new SAXReader(); 29 reader.addHandler("/products/product/colour", handler); 30 reader.read(getFile("/xml/test/sample.xml")); 31 32 assertEquals(3, handler.getCount()); 33 34 reader.read(getFile("/xml/test/sample.xml")); 35 assertEquals(6, handler.getCount()); 36 } 37 38 private static class MyHandler implements ElementHandler { 39 private int count = 0; 40 41 public void onEnd(org.dom4j.ElementPath elementPath) { 42 } 43 44 public void onStart(org.dom4j.ElementPath elementPath) { 45 count++; 46 } 47 48 int getCount() { 49 return count; 50 } 51 } 52 } 53 54 90 | Popular Tags |