KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.HashMap JavaDoc;
27
28 import net.firstpartners.nounit.snippet.ISnippet;
29 import net.firstpartners.nounit.snippet.SnippetCalls;
30 import net.firstpartners.nounit.snippet.SnippetClass;
31 import net.firstpartners.nounit.snippet.SnippetMethod;
32 import net.firstpartners.nounit.snippet.SnippetPackage;
33 import net.firstpartners.nounit.snippet.Snippets;
34
35 /**
36  * Provides standard information for testing Snippets
37  */

38 public class TestSnippetData {
39   
40
41     /**
42      * Mock up some SnippetClasses for testing
43      */

44     public static Snippets getSnippetPackages() {
45       
46         Snippets someClasses = getSnippetClasses();
47         
48         ISnippet testProject1 = new SnippetPackage("location1",someClasses);
49         ISnippet testProject2 = new SnippetPackage("location1",someClasses);
50         ISnippet testProject3 = new SnippetPackage("location1",someClasses);
51                                                 
52         Snippets somePackages = new Snippets();
53         somePackages.add(testProject1);
54         somePackages.add(testProject2);
55         somePackages.add(testProject3);
56         
57         return somePackages;
58            
59   }
60     
61     /**
62      * Mock up some SnippetClasses for testing
63      */

64     public static Snippets getSnippetClasses() {
65       
66         Snippets someMethods = getSnippetMethods();
67         
68         ISnippet testClass = new SnippetClass("TestName",
69                                                 "protected",
70                                                 "java.lang.Object",
71                                                 someMethods);
72                                                 
73         Snippets someClasses = new Snippets();
74         someClasses.add(testClass);
75         
76         return someClasses;
77            
78   }
79   
80       /**
81      * Mock up some SnippetMethods for testing
82      */

83     public static Snippets getSnippetMethods() {
84       
85         //Local Variables
86
Snippets someMethods = new Snippets();
87         HashMap JavaDoc methodParams = new HashMap JavaDoc();
88         
89         //Mockup methodParams
90
methodParams.put("0","java.lang.String");
91         methodParams.put("1","java.lang.Integer");
92         methodParams.put("2","java.lang.Double");
93         
94         //Mock up some methods
95
ISnippet testClass1 = new SnippetMethod("method1","public",methodParams,null);
96         ISnippet testClass2 = new SnippetMethod("method2","protected",methodParams,null);
97         ISnippet testClass3 = new SnippetMethod("method3","private",methodParams,null);
98         
99         //Add to colleciton and return
100
Snippets someClasses = new Snippets();
101         someMethods.add(testClass1);
102         someMethods.add(testClass2);
103         someMethods.add(testClass3);
104         
105         return someMethods;
106            
107   }
108   
109    /**
110      * Mock up some SnippetMethods for testing
111      */

112     public static Snippets getSnippetCalledMethods() {
113       
114         //Local Variables
115
Snippets someCalledMethods = new Snippets();
116         HashMap JavaDoc methodParams = new HashMap JavaDoc();
117         
118         //Mockup methodParams
119
methodParams.put("0","java.lang.String");
120         methodParams.put("1","java.lang.Integer");
121         methodParams.put("2","java.lang.Double");
122         
123         //Mock up some methods
124
ISnippet testClass1 = new SnippetCalls("Class1","called-method1",methodParams);
125         ISnippet testClass2 = new SnippetCalls("Class2","called-method2",methodParams);
126         ISnippet testClass3 = new SnippetCalls("Class3","called-method3",methodParams);
127         
128         //Add to colleciton and return
129
Snippets someClasses = new Snippets();
130         someCalledMethods.add(testClass1);
131         someCalledMethods.add(testClass2);
132         someCalledMethods.add(testClass3);
133         
134         return someCalledMethods;
135            
136   }
137   
138 }
Popular Tags