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.util.HashMap;
027: import java.util.Iterator;
028:
029: import junit.framework.Test;
030: import junit.framework.TestCase;
031: import junit.framework.TestSuite;
032: import net.firstpartners.nounit.reader.ISnippetFactory;
033: import net.firstpartners.nounit.reader.bytecode.ByteCodeMethodSnippetFactory;
034: import net.firstpartners.nounit.snippet.Snippets;
035: import net.firstpartners.nounit.test.TestData;
036: import org.apache.log4j.Logger;
037:
038: /**
039: * Test the Method Snippet Factory<BR>
040:
041: */
042: public class TestByteCodeMethodSnippetFactory extends TestCase {
043:
044: //handle to logger
045: static Logger log = Logger
046: .getLogger(TestByteCodeCallsSnippetFactory.class);
047:
048: /**
049: * Constructor as required by Junit
050: * @param name to be displayed on testrunner
051: */
052: public TestByteCodeMethodSnippetFactory(String name) {
053: super (name);
054: }
055:
056: /**
057: * Code run before each test
058: */
059: public void setUp() {
060:
061: }
062:
063: /**
064: * Code run after each test
065: */
066: protected void tearDown() {
067:
068: }
069:
070: /**
071: * Enable Junit to run this Class individually
072: * @param args
073: */
074: public static void main(String[] args) {
075: junit.textui.TestRunner.run(suite());
076: }
077:
078: /**
079: * Enable Junit to run this class as part of AllTests.java
080: * @return TestSuite
081: */
082: public static Test suite() {
083: return new TestSuite(TestByteCodeMethodSnippetFactory.class);
084: }
085:
086: /**
087: * Test the breaking of the parameter String (tag info) into Hashtable
088: */
089: public void testParameterStringConversion() throws Exception {
090:
091: String tmpString;
092: String testString = "<(Ljava/lang/String;Ljava/lang/String;Lorg/jdom/Namespace;)Lorg/jdom/Attirbute;>";
093: ByteCodeMethodSnippetFactory myFactory = new ByteCodeMethodSnippetFactory(
094: TestData.getSampleClassFile());
095:
096: HashMap results = myFactory
097: .splitTagVerboseIntoHashMap(testString);
098: Iterator loop = results.keySet().iterator();
099:
100: assertTrue(results.get("0").equals("java.lang.String"));
101: assertTrue(results.get("1").equals("java.lang.String"));
102: assertTrue(results.get("2").equals("org.jdom.Namespace"));
103: assertTrue(results.get("3").equals("org.jdom.Attirbute"));
104:
105: }
106:
107: public void testConvertMethodsAsSnippets() throws Exception {
108:
109: Snippets javaInformation;
110: Iterator informationList;
111: ISnippetFactory myFactory = new ByteCodeMethodSnippetFactory(
112: TestData.getSampleClassFile());
113:
114: //Get Information about File
115: javaInformation = myFactory.getSnippets();
116: informationList = javaInformation.getIterator();
117:
118: while (informationList.hasNext()) {
119: // assertTrue(informationList.next() instanceof ISnippet);
120: log.debug(informationList.next().getClass());
121: }
122:
123: }
124:
125: }
|