KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > firstpartners > nounit > reader > bytecode > test > TestByteCodePackageSnippetFactory


1 package net.firstpartners.nounit.reader.bytecode.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.reader.ISnippetFactory;
31 import net.firstpartners.nounit.reader.bytecode.ByteCodePackageSnippetFactory;
32 import net.firstpartners.nounit.snippet.Snippets;
33 import net.firstpartners.nounit.test.TestData;
34
35 /**
36  * Test the Class Snippet Factory<BR>
37
38  */

39 public class TestByteCodePackageSnippetFactory extends TestCase {
40
41   /**
42    * Constructor as required by Junit
43    * @param name to be displayed on testrunner
44    */

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

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

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

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

76   public static Test suite() {
77       return new TestSuite(TestByteCodePackageSnippetFactory.class);
78   }
79   
80   public void testGetSnippetInfo() throws Exception JavaDoc {
81       
82       //Local Variables
83
Snippets javaInformation;
84       String JavaDoc info;
85       String JavaDoc sourceDirectory = TestData.SAMPLE_CLASS_SOURCE;
86       
87            //Get Information about File & assert
88
ISnippetFactory myFactory = new ByteCodePackageSnippetFactory(sourceDirectory);
89       javaInformation = myFactory.getSnippets();
90       info = javaInformation.toString();
91       
92            
93       assertTrue(info.indexOf("public net.firstpartners.nounit.utility.TextUtil")>-1);
94       assertTrue(info.indexOf("public static replaceAll(java.lang.String:java.lang.String:java.lang.String:java.lang.String:), public static find(java.lang.String:ILjava.lang.String:java.lang.String:java.lang.String:), public <init>(), public static removeTrailing(java.lang.String:java.lang.String:java.lang.String:), public static removeAll(java.lang.String:java.lang.String:java.lang.String:), public static replace(java.lang.String:java.lang.String:java.lang.String:java.lang.String:)]}extends java.lang.Object")>-1);
95       assertTrue(info.indexOf("public net.firstpartners.nounit.utility.DirectoryWalker")>-1);
96       
97   }
98    
99
100
101 }
Popular Tags