1 package net.firstpartners.nounit.utility.test; 2 3 26 27 30 31 import java.util.HashMap ; 32 33 import junit.framework.Test; 34 import junit.framework.TestCase; 35 import junit.framework.TestSuite; 36 import net.firstpartners.nounit.snippet.xml.IXmlConstants; 37 import net.firstpartners.nounit.test.TestData; 38 import net.firstpartners.nounit.utility.XmlUtil; 39 40 import org.jdom.Document; 41 import org.jdom.Element; 42 43 46 public class TestXmlUtil extends TestCase{ 47 48 49 53 public TestXmlUtil(String name) { 54 super(name); 55 } 56 57 58 62 public static void main(String [] args) { 63 junit.textui.TestRunner.run(suite()); 64 } 65 66 70 public static Test suite() { 71 return new TestSuite(TestXmlUtil.class); 72 } 73 74 77 public void testGetNodeIndex() throws Exception { 78 79 Object tmpKey; 81 82 Document myTestDocument = TestData.getSimpleXmlDocument(); 84 85 HashMap index = XmlUtil.getNodeIndex(myTestDocument,IXmlConstants.ATTRIBUTE_NAME); 87 88 assertTrue(index.get("net.firstpartners.nounit.reader.ISnippetFactory") !=null); 89 assertTrue(index.get("net.firstpartners.nounit.reader.ISnippetFactory") instanceof Element); 90 assertTrue(index.get("net.firstpartners.nounit.report.AbstractReport") !=null); 91 assertTrue(index.get("net.firstpartners.nounit.report.AbstractReport") instanceof Element); 92 assertTrue(index.get("net.firstpartners.nounit.utility.DirectoryWalker") !=null); 93 assertTrue(index.get("net.firstpartners.nounit.utility.DirectoryWalker") instanceof Element); 94 95 96 } 97 98 101 public void testSearch() throws Exception { 102 103 Object tmpKey; 105 106 Document myTestDocument = TestData.getSimpleXmlDocument(); 108 109 Element foundNode = XmlUtil.findNode(myTestDocument, 111 IXmlConstants.ATTRIBUTE_NAME, 112 "net.firstpartners.nounit.utility.DirectoryWalker"); 113 assertTrue(foundNode!=null); 114 assertTrue(foundNode.getName().equals(IXmlConstants.ELEMENT_CLASS)); 115 116 } 117 118 } 119 | Popular Tags |