001: package net.firstpartners.nounit.utility.test;
002:
003: /**
004: * Title: NoUnit - Identify Classes that are not being unit Tested
005: *
006: * Copyright (C) 2001 Paul Browne , FirstPartners.net
007: *
008: *
009: * This program is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; either version 2
012: * of the License, or (at your option) any later version.
013: *
014: * This program is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
017: * GNU General Public License for more details.
018: *
019: * You should have received a copy of the GNU General Public License
020: * along with this program; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * @author Paul Browne
024: * @version 0.7
025: */
026:
027: /**
028: * Test class for class FileManager
029: */
030:
031: import java.util.HashMap;
032:
033: import junit.framework.Test;
034: import junit.framework.TestCase;
035: import junit.framework.TestSuite;
036: import net.firstpartners.nounit.snippet.xml.IXmlConstants;
037: import net.firstpartners.nounit.test.TestData;
038: import net.firstpartners.nounit.utility.XmlUtil;
039:
040: import org.jdom.Document;
041: import org.jdom.Element;
042:
043: /**
044: * Tests the functions in the The Xml Util Class
045: */
046: public class TestXmlUtil extends TestCase {
047:
048: /**
049: * Constructor Required by Junit
050: * @param name
051: */
052: public TestXmlUtil(String name) {
053: super (name);
054: }
055:
056: /**
057: * Enable Junit to run this Class individually
058: * @param args
059: */
060: public static void main(String[] args) {
061: junit.textui.TestRunner.run(suite());
062: }
063:
064: /**
065: * Enable Junit to run this class
066: * @return TestSuite
067: */
068: public static Test suite() {
069: return new TestSuite(TestXmlUtil.class);
070: }
071:
072: /**
073: * Test Indexing of nodes
074: */
075: public void testGetNodeIndex() throws Exception {
076:
077: //Local Variables
078: Object tmpKey;
079:
080: //Get a test document
081: Document myTestDocument = TestData.getSimpleXmlDocument();
082:
083: //Index the document
084: HashMap index = XmlUtil.getNodeIndex(myTestDocument,
085: IXmlConstants.ATTRIBUTE_NAME);
086:
087: assertTrue(index
088: .get("net.firstpartners.nounit.reader.ISnippetFactory") != null);
089: assertTrue(index
090: .get("net.firstpartners.nounit.reader.ISnippetFactory") instanceof Element);
091: assertTrue(index
092: .get("net.firstpartners.nounit.report.AbstractReport") != null);
093: assertTrue(index
094: .get("net.firstpartners.nounit.report.AbstractReport") instanceof Element);
095: assertTrue(index
096: .get("net.firstpartners.nounit.utility.DirectoryWalker") != null);
097: assertTrue(index
098: .get("net.firstpartners.nounit.utility.DirectoryWalker") instanceof Element);
099:
100: }
101:
102: /**
103: * Test Search
104: */
105: public void testSearch() throws Exception {
106:
107: //Local Variables
108: Object tmpKey;
109:
110: //Get a test document
111: Document myTestDocument = TestData.getSimpleXmlDocument();
112:
113: //Search the document
114: Element foundNode = XmlUtil.findNode(myTestDocument,
115: IXmlConstants.ATTRIBUTE_NAME,
116: "net.firstpartners.nounit.utility.DirectoryWalker");
117: assertTrue(foundNode != null);
118: assertTrue(foundNode.getName().equals(
119: IXmlConstants.ELEMENT_CLASS));
120:
121: }
122:
123: }
|