KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > firstpartners > nounit > utility > test > TestXmlUtil


1 package net.firstpartners.nounit.utility.test;
2
3 /**
4  * Title: NoUnit - Identify Classes that are not being unit Tested
5  *
6  * Copyright (C) 2001 Paul Browne , FirstPartners.net
7  *
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * @author Paul Browne
24  * @version 0.7
25  */

26
27 /**
28  * Test class for class FileManager
29  */

30
31 import java.util.HashMap JavaDoc;
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 /**
44  * Tests the functions in the The Xml Util Class
45  */

46 public class TestXmlUtil extends TestCase{
47     
48     
49     /**
50      * Constructor Required by Junit
51      * @param name
52      */

53     public TestXmlUtil(String JavaDoc name) {
54         super(name);
55     }
56     
57     
58     /**
59      * Enable Junit to run this Class individually
60      * @param args
61      */

62     public static void main(String JavaDoc[] args) {
63         junit.textui.TestRunner.run(suite());
64     }
65     
66     /**
67      * Enable Junit to run this class
68      * @return TestSuite
69      */

70     public static Test suite() {
71         return new TestSuite(TestXmlUtil.class);
72     }
73     
74     /**
75      * Test Indexing of nodes
76      */

77     public void testGetNodeIndex() throws Exception JavaDoc {
78         
79         //Local Variables
80
Object JavaDoc tmpKey;
81         
82         //Get a test document
83
Document myTestDocument = TestData.getSimpleXmlDocument();
84         
85         //Index the document
86
HashMap JavaDoc 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     /**
99      * Test Search
100      */

101     public void testSearch() throws Exception JavaDoc {
102         
103         //Local Variables
104
Object JavaDoc tmpKey;
105         
106         //Get a test document
107
Document myTestDocument = TestData.getSimpleXmlDocument();
108         
109         //Search the document
110
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