001: package net.firstpartners.nounit.reader.bytecode.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 junit.framework.*;
028:
029: import net.firstpartners.nounit.reader.*;
030: import net.firstpartners.nounit.reader.bytecode.*;
031: import net.firstpartners.nounit.snippet.*;
032: import net.firstpartners.nounit.test.*;
033:
034: import org.apache.log4j.Logger;
035:
036: /**
037: * Test the Class Snippet Factory<BR>
038:
039: */
040: public class TestByteCodeProjectSnippetFactory extends TestCase {
041:
042: //handle to logger
043: static Logger log = Logger
044: .getLogger(TestByteCodeProjectSnippetFactory.class);
045:
046: /**
047: * Constructor as required by Junit
048: * @param name to be displayed on testrunner
049: */
050: public TestByteCodeProjectSnippetFactory(String name) {
051: super (name);
052: }
053:
054: /**
055: * Code run before each test
056: */
057: public void setUp() {
058:
059: }
060:
061: /**
062: * Code run after each test
063: */
064: protected void tearDown() {
065:
066: }
067:
068: /**
069: * Enable Junit to run this Class individually
070: * @param args
071: */
072: public static void main(String[] args) {
073: junit.textui.TestRunner.run(suite());
074: }
075:
076: /**
077: * Enable Junit to run this class as part of AllTests.java
078: * @return TestSuite
079: */
080: public static Test suite() {
081: return new TestSuite(TestByteCodeProjectSnippetFactory.class);
082: }
083:
084: public void testGetSnippetInfo() throws Exception {
085:
086: //Local Variables
087: Snippets javaInformation;
088: String info;
089: String sourceDirectory = TestData.SAMPLE_CLASS_SOURCE_FULL;
090:
091: //Get Information about File & assert
092: ISnippetFactory myFactory = new ByteCodeProjectSnippetFactory(
093: sourceDirectory);
094: javaInformation = myFactory.getSnippets();
095: info = javaInformation.toString();
096:
097: log.debug(info);
098:
099: assertTrue(info.indexOf("roject") > -1);
100: assertTrue(info.indexOf("package location") > -1);
101: assertTrue(info.indexOf("public net.firstpartners.nounit") > -1);
102:
103: }
104:
105: }
|