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.SnippetProject;
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 TestSnippetProject extends TestCase {
039:
040: //handle to logger
041: static Logger log = Logger.getLogger(TestSnippetProject.class);
042:
043: /**
044: * Constructor as required by Junit
045: * @param name to be displayed on testrunner
046: */
047: public TestSnippetProject(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(TestSnippetProject.class);
079: }
080:
081: public void testSnippetProjectsToXml() throws Exception {
082:
083: Snippets somePackages = TestSnippetData.getSnippetPackages();
084:
085: SnippetProject testProject = new SnippetProject(somePackages);
086:
087: String tmpString = testProject.toXml();
088:
089: log.debug(tmpString);
090:
091: int oldPlaceHolder = -1;
092: int placeHolder = -1;
093:
094: //Assert that each of the following tests come after the previous
095: oldPlaceHolder = placeHolder;
096: placeHolder = tmpString.indexOf("<PROJECT>");
097: assertTrue(placeHolder > oldPlaceHolder);
098:
099: oldPlaceHolder = placeHolder;
100: placeHolder = tmpString.indexOf("<PACKAGE location=");
101: assertTrue(placeHolder > oldPlaceHolder);
102:
103: oldPlaceHolder = placeHolder;
104: placeHolder = tmpString.indexOf("<CLASS name=");
105: assertTrue(placeHolder > oldPlaceHolder);
106:
107: oldPlaceHolder = placeHolder;
108: placeHolder = tmpString.indexOf("access=");
109: assertTrue(placeHolder > oldPlaceHolder);
110:
111: oldPlaceHolder = placeHolder;
112: placeHolder = tmpString.indexOf("<EXTENDS name=");
113: assertTrue(placeHolder > oldPlaceHolder);
114:
115: oldPlaceHolder = placeHolder;
116: placeHolder = tmpString.indexOf("<METHOD name=");
117: assertTrue(placeHolder > oldPlaceHolder);
118:
119: }
120: }
|