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: import java.util.HashSet;
028: import java.util.Iterator;
029:
030: import junit.framework.Test;
031: import junit.framework.TestCase;
032: import junit.framework.TestSuite;
033: import net.firstpartners.nounit.test.TestData;
034: import net.firstpartners.nounit.utility.DirectoryWalker;
035:
036: import org.apache.log4j.Logger;
037:
038: /**
039: * Class to test the Directory Walker
040: */
041: public class TestDirectoryWalker extends TestCase {
042:
043: //handle to logger
044: static Logger log = Logger.getLogger(TestDirectoryWalker.class);
045:
046: /**
047: * Constructor Required by Junit
048: * @param name
049: */
050: public TestDirectoryWalker(String name) {
051: super (name);
052: }
053:
054: /**
055: * Method to setup logging test
056: */
057: protected void setUp() {
058: //Put in Setup Code Here
059:
060: }
061:
062: /**
063: * Enable Junit to run this Class individually
064: * @param args
065: */
066: public static void main(String[] args) {
067: junit.textui.TestRunner.run(suite());
068: }
069:
070: /**
071: * Enable Junit to run this class
072: * @return TestDataCaptureDefaults.class
073: */
074: public static Test suite() {
075: return new TestSuite(TestDirectoryWalker.class);
076: }
077:
078: public void testSeeFiles() throws Exception {
079:
080: HashSet myResults = DirectoryWalker.getFiles(
081: TestData.SAMPLE_CLASS_SOURCE, ".class");
082: Iterator myList = myResults.iterator();
083: StringBuffer addList = new StringBuffer();
084:
085: //Get everything into String
086: while (myList.hasNext()) {
087: addList.append(myList.next());
088: addList.append("\n");
089:
090: }
091: String searchString = addList.toString();
092:
093: //Now Check that it's picked up all the sample files
094: //assertTrue(searchString.indexOf("G:\\NoUnitFiles\\net\\firstpartners\\nounit\\utility\\Logging.class")>-1);
095://assertTrue(searchString.indexOf("G:\\NoUnitFiles\\net\\firstpartners\\nounit\\utility\\DirectoryWalker.class")>-1);
096://assertTrue(searchString.indexOf("G:\\NoUnitFiles\\net\\firstpartners\\nounit\\utility\\NoUnitException.class")>-1);
097:
098: }
099:
100: public void testSeeDirs() throws Exception {
101:
102: HashSet myResults = DirectoryWalker
103: .getDirs(TestData.SAMPLE_CLASS_SOURCE);
104: Iterator myList = myResults.iterator();
105: StringBuffer addList = new StringBuffer();
106:
107: //Get everything into String
108: while (myList.hasNext()) {
109: addList.append(myList.next());
110: addList.append("\n");
111:
112: }
113: String searchString = addList.toString();
114:
115: log.debug(searchString);
116:
117: //Now Check that it's picked up all the sample files
118: //assertTrue(searchString.indexOf("G:\\NoUnitFiles\\net\\firstpartners\\nounit\\utility\\test")>-1);
119:
120: }
121:
122: }
|