1 7 8 package org.netbeans.modules.xml.xdm.visitor; 9 10 import java.io.BufferedReader ; 11 import java.io.InputStreamReader ; 12 import junit.framework.*; 13 import org.netbeans.modules.xml.xdm.XDMModel; 14 import org.netbeans.modules.xml.xdm.nodes.*; 15 import org.netbeans.modules.xml.xdm.Util; 16 17 21 public class FindVisitorTest extends TestCase { 22 23 public FindVisitorTest(String testName) { 24 super(testName); 25 } 26 27 public static Test suite() { 28 TestSuite suite = new TestSuite(FindVisitorTest.class); 29 30 return suite; 31 } 32 33 public void testFind() { 34 35 FindVisitor instance = new FindVisitor(); 36 37 Document root = xmlModel.getDocument(); 38 39 Element company = (Element)root.getChildNodes().item(0); 41 Node result = instance.find(root, company.getId()); 42 assertEquals(company, result); 43 44 Element employee = (Element)company.getChildNodes().item(1); 46 Attribute attr = (Attribute)employee.getAttributes().item(0); 47 result = instance.find(root, attr.getId()); 48 assertEquals(attr, result); 49 50 Text txt = (Text)employee.getChildNodes().item(0); 52 result = instance.find(root, txt.getId()); 53 assertEquals(txt, result); 54 } 55 56 protected void setUp() throws Exception { 57 xmlModel = Util.loadXDMModel("visitor/test.xml"); 58 xmlModel.sync(); 59 } 60 61 private XDMModel xmlModel; 62 } 63 | Popular Tags |