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: import java.io.File;
027:
028: import junit.framework.Test;
029: import junit.framework.TestCase;
030: import junit.framework.TestSuite;
031: import net.firstpartners.nounit.reader.ISnippetFactory;
032: import net.firstpartners.nounit.reader.bytecode.AbstractByteCodeSnippetFactory;
033: import net.firstpartners.nounit.reader.bytecode.ByteCodeClassSnippetFactory;
034: import net.firstpartners.nounit.snippet.Snippets;
035: import net.firstpartners.nounit.test.TestData;
036:
037: /**
038: * Test the Class Snippet Factory<BR>
039: */
040: public class TestByteCodeClassSnippetFactory extends TestCase {
041:
042: /**
043: * Constructor as required by Junit.
044: * @param name to be displayed on testrunner
045: */
046: public TestByteCodeClassSnippetFactory(String name) {
047: super (name);
048: }
049:
050: /**
051: * Enable Junit to run this Class individually.
052: * @param args
053: */
054: public static void main(String[] args) {
055: junit.textui.TestRunner.run(suite());
056: }
057:
058: /**
059: * Enable Junit to run this class as part of AllTests.java
060: * @return TestSuite
061: */
062: public static Test suite() {
063: return new TestSuite(TestByteCodeClassSnippetFactory.class);
064: }
065:
066: public void testGetClassInfo() throws Exception {
067:
068: //Local Variables
069: File sourceFile = new File(TestData.SAMPLE_CLASS_PROXY);
070:
071: //Get Information about File & assert
072: ISnippetFactory myFactory = new ByteCodeClassSnippetFactory(
073: sourceFile);
074: Snippets javaInformation = myFactory.getSnippets();
075: String info = javaInformation.toString();
076:
077: assertTrue(info.indexOf("public eip.ProxyBean") > -1);
078: assertTrue(info.indexOf("handleGenericRequest(") > -1);
079: assertTrue(info.indexOf("main(") > -1);
080: assertTrue(info.indexOf("handleCommandLineRequest(") > -1);
081: assertTrue(info.indexOf("<init>(") > -1);
082: assertTrue(info.indexOf("clearError(") > -1);
083: assertTrue(info.indexOf("extends java.lang.Object") > -1);
084: assertTrue(info.indexOf("public") > -1);
085: assertTrue(info.indexOf("protected") > -1);
086: }
087:
088: /**
089: * Test the breaking of the parameter String (tag info) into Hashtable
090: */
091: public void testParameterStringConversion() throws Exception {
092:
093: AbstractByteCodeSnippetFactory myFactory = new ByteCodeClassSnippetFactory(
094: TestData.getSampleFile());
095: String testString = ".somepackage/someClass";
096: String results = myFactory.cleanValues(testString);
097:
098: assertTrue(results.equals("somepackage.someClass"));
099: }
100:
101: }
|