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:
027: import junit.framework.Test;
028: import junit.framework.TestCase;
029: import junit.framework.TestSuite;
030: import net.firstpartners.nounit.snippet.SnippetPackage;
031: import net.firstpartners.nounit.snippet.Snippets;
032: import org.apache.log4j.Logger;
033:
034: /**
035: * Test the Class Snippet Package<BR>
036:
037: */
038: public class TestSnippetPackage extends TestCase {
039:
040: //handle to logger
041: static Logger log = Logger.getLogger(TestSnippetPackage.class);
042:
043: /**
044: * Constructor as required by Junit
045: * @param name to be displayed on testrunner
046: */
047: public TestSnippetPackage(String name) {
048: super (name);
049: }
050:
051: /**
052: * Code run before each test
053: */
054: public void setUp() {
055:
056: }
057:
058: /**
059: * Code run after each test
060: */
061: protected void tearDown() {
062:
063: }
064:
065: /**
066: * Enable Junit to run this Class individually
067: * @param args
068: */
069: public static void main(String[] args) {
070: junit.textui.TestRunner.run(suite());
071: }
072:
073: /**
074: * Enable Junit to run this class as part of AllTests.java
075: * @return TestSuite
076: */
077: public static Test suite() {
078: return new TestSuite(TestSnippetPackage.class);
079: }
080:
081: public void testSnippetPackages() throws Exception {
082:
083: Snippets someClasses = TestSnippetData.getSnippetClasses();
084:
085: SnippetPackage testPackage = new SnippetPackage("testName",
086: someClasses);
087:
088: String tmpString = testPackage.toString();
089:
090: }
091:
092: public void testSnippetPackagesToXml() throws Exception {
093:
094: Snippets someClasses = TestSnippetData.getSnippetClasses();
095:
096: SnippetPackage testPackage = new SnippetPackage(
097: "testPackageName", someClasses);
098:
099: String tmpString = testPackage.toXml();
100:
101: log.debug(tmpString);
102:
103: int oldPlaceHolder = -1;
104: int placeHolder = -1;
105:
106: //Assert that each of the following tests come after the previous
107: oldPlaceHolder = placeHolder;
108: placeHolder = tmpString.indexOf("<PACKAGE location=");
109: assertTrue(placeHolder > oldPlaceHolder);
110:
111: oldPlaceHolder = placeHolder;
112: placeHolder = tmpString.indexOf("<CLASS name=");
113: assertTrue(placeHolder > oldPlaceHolder);
114:
115: oldPlaceHolder = placeHolder;
116: placeHolder = tmpString.indexOf("access=");
117: assertTrue(placeHolder > oldPlaceHolder);
118:
119: oldPlaceHolder = placeHolder;
120: placeHolder = tmpString.indexOf("<EXTENDS name=");
121: assertTrue(placeHolder > oldPlaceHolder);
122:
123: oldPlaceHolder = placeHolder;
124: placeHolder = tmpString.indexOf("<METHOD name=");
125: assertTrue(placeHolder > oldPlaceHolder);
126:
127: }
128: }
|