001: package net.firstpartners.nounit.snippet.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.Iterator;
027:
028: import junit.framework.Test;
029: import junit.framework.TestCase;
030: import junit.framework.TestSuite;
031: import net.firstpartners.nounit.snippet.Snippets;
032: import net.firstpartners.nounit.snippet.xml.IXmlSource;
033: import org.apache.log4j.Logger;
034:
035: /**
036: * Test the Class Snippet Package<BR>
037:
038: */
039: public class TestSnippetMethod extends TestCase {
040:
041: //handle to logger
042: static Logger log = Logger.getLogger(TestSnippetMethod.class);
043:
044: /**
045: * Constructor as required by Junit
046: * @param name to be displayed on testrunner
047: */
048: public TestSnippetMethod(String name) {
049: super (name);
050: }
051:
052: /**
053: * Code run before each test
054: */
055: public void setUp() {
056:
057: }
058:
059: /**
060: * Code run after each test
061: */
062: protected void tearDown() {
063:
064: }
065:
066: /**
067: * Enable Junit to run this Class individually
068: * @param args
069: */
070: public static void main(String[] args) {
071: junit.textui.TestRunner.run(suite());
072: }
073:
074: /**
075: * Enable Junit to run this class as part of AllTests.java
076: * @return TestSuite
077: */
078: public static Test suite() {
079: return new TestSuite(TestSnippetMethod.class);
080: }
081:
082: public void testSnippetMethodXml() throws Exception {
083:
084: //Local Variables
085: IXmlSource this XmlSource;
086: Iterator loop;
087: String tmpString;
088: StringBuffer results = new StringBuffer();
089:
090: //Get Test Data
091: Snippets someMethods = TestSnippetData.getSnippetMethods();
092:
093: loop = someMethods.getIterator();
094: while (loop.hasNext()) {
095:
096: //Add the XML in this method
097: this XmlSource = (IXmlSource) loop.next();
098: results.append(this XmlSource.toXml());
099: results.append("\n");
100:
101: }
102:
103: //Now check if the results are as expected
104: tmpString = results.toString();
105:
106: log.debug(tmpString);
107: assertTrue(tmpString.indexOf("<METHOD name=") > -1);
108: assertTrue(tmpString.indexOf("access=") > -1);
109: assertTrue(tmpString.indexOf("<PARAM>") > -1);
110: assertTrue(tmpString.indexOf("<CLASS name=") > -1);
111: assertTrue(tmpString.indexOf("</PARAM>") > -1);
112: assertTrue(tmpString.indexOf("</METHOD") > -1);
113:
114: }
115:
116: }
|