KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > firstpartners > nounit > snippet > test > TestSnippetProject


1 package net.firstpartners.nounit.snippet.test;
2
3 /**
4  * Title: NoUnit - Identify Classes that are not being unit Tested
5  *
6  * Copyright (C) 2001 Paul Browne , FirstPartners.net
7  *
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * @author Paul Browne
24  * @version 0.7
25  */

26
27 import junit.framework.Test;
28 import junit.framework.TestCase;
29 import junit.framework.TestSuite;
30 import net.firstpartners.nounit.snippet.SnippetProject;
31 import net.firstpartners.nounit.snippet.Snippets;
32 import org.apache.log4j.Logger;
33 /**
34  * Test the Class Snippet Package<BR>
35
36  */

37 public class TestSnippetProject extends TestCase {
38
39     //handle to logger
40
static Logger log = Logger.getLogger(TestSnippetProject.class);
41
42   /**
43    * Constructor as required by Junit
44    * @param name to be displayed on testrunner
45    */

46     public TestSnippetProject(String JavaDoc name) {
47     super(name);
48   }
49
50   /**
51    * Code run before each test
52    */

53   public void setUp(){
54
55   }
56
57   /**
58    * Code run after each test
59    */

60   protected void tearDown()
61   {
62
63   }
64
65   /**
66   * Enable Junit to run this Class individually
67   * @param args
68   */

69   public static void main(String JavaDoc[] args) {
70       junit.textui.TestRunner.run (suite());
71   }
72
73   /**
74    * Enable Junit to run this class as part of AllTests.java
75    * @return TestSuite
76    */

77   public static Test suite() {
78       return new TestSuite(TestSnippetProject.class);
79   }
80   
81   
82      public void testSnippetProjectsToXml() throws Exception JavaDoc {
83       
84                                                 
85         Snippets somePackages = TestSnippetData.getSnippetPackages();
86         
87         SnippetProject testProject = new SnippetProject(somePackages);
88         
89         String JavaDoc tmpString = testProject.toXml();
90         
91          log.debug(tmpString);
92       
93          int oldPlaceHolder=-1;
94          int placeHolder=-1;
95          
96          //Assert that each of the following tests come after the previous
97
oldPlaceHolder=placeHolder;
98          placeHolder=tmpString.indexOf("<PROJECT>");
99          assertTrue(placeHolder>oldPlaceHolder);
100  
101          oldPlaceHolder=placeHolder;
102          placeHolder=tmpString.indexOf("<PACKAGE location=");
103          assertTrue(placeHolder>oldPlaceHolder);
104          
105          oldPlaceHolder=placeHolder;
106          placeHolder=tmpString.indexOf("<CLASS name=");
107          assertTrue(placeHolder>oldPlaceHolder);
108          
109          oldPlaceHolder=placeHolder;
110          placeHolder=tmpString.indexOf("access=");
111          assertTrue(placeHolder>oldPlaceHolder);
112          
113          oldPlaceHolder=placeHolder;
114          placeHolder=tmpString.indexOf("<EXTENDS name=");
115          assertTrue(placeHolder>oldPlaceHolder);
116          
117          oldPlaceHolder=placeHolder;
118          placeHolder=tmpString.indexOf("<METHOD name=");
119          assertTrue(placeHolder>oldPlaceHolder);
120               
121   }
122 }
123
124  
Popular Tags