KickJava   Java API By Example, From Geeks To Geeks.

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


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.SnippetPackage;
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 TestSnippetPackage extends TestCase {
38
39     //handle to logger
40
static Logger log = Logger.getLogger(TestSnippetPackage.class);
41
42   /**
43    * Constructor as required by Junit
44    * @param name to be displayed on testrunner
45    */

46     public TestSnippetPackage(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(TestSnippetPackage.class);
79   }
80   
81     public void testSnippetPackages() throws Exception JavaDoc {
82       
83                                                 
84         Snippets someClasses = TestSnippetData.getSnippetClasses();
85         
86         SnippetPackage testPackage = new SnippetPackage("testName",someClasses);
87         
88         String JavaDoc tmpString = testPackage.toString();
89
90            
91   }
92   
93      public void testSnippetPackagesToXml() throws Exception JavaDoc {
94       
95                                                 
96         Snippets someClasses = TestSnippetData.getSnippetClasses();
97         
98         SnippetPackage testPackage = new SnippetPackage("testPackageName",someClasses);
99         
100         String JavaDoc tmpString = testPackage.toXml();
101         
102         log.debug(tmpString);
103       
104          int oldPlaceHolder=-1;
105          int placeHolder=-1;
106          
107          //Assert that each of the following tests come after the previous
108
oldPlaceHolder=placeHolder;
109          placeHolder=tmpString.indexOf("<PACKAGE location=");
110          assertTrue(placeHolder>oldPlaceHolder);
111          
112          oldPlaceHolder=placeHolder;
113          placeHolder=tmpString.indexOf("<CLASS name=");
114          assertTrue(placeHolder>oldPlaceHolder);
115          
116          oldPlaceHolder=placeHolder;
117          placeHolder=tmpString.indexOf("access=");
118          assertTrue(placeHolder>oldPlaceHolder);
119          
120          oldPlaceHolder=placeHolder;
121          placeHolder=tmpString.indexOf("<EXTENDS name=");
122          assertTrue(placeHolder>oldPlaceHolder);
123          
124          oldPlaceHolder=placeHolder;
125          placeHolder=tmpString.indexOf("<METHOD name=");
126          assertTrue(placeHolder>oldPlaceHolder);
127                
128   }
129 }
130
131  
Popular Tags