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