Source Code Cross Referenced for TestMethodCollector.java in  » Code-Analyzer » JBlanket » csdl » jblanket » modifier » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » JBlanket » csdl.jblanket.modifier 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package csdl.jblanket.modifier;
002:
003:        import csdl.jblanket.methodset.MethodInfo;
004:        import csdl.jblanket.methodset.MethodSet;
005:
006:        import java.io.File;
007:        import java.util.ArrayList;
008:        import java.util.Date;
009:        import java.util.List;
010:
011:        import junit.framework.TestCase;
012:
013:        /**
014:         * Tests the MethodCollector class.
015:         *
016:         * @author Joy M. Agustin
017:         * @version $Id: TestMethodCollector.java,v 1.1 2004/11/07 00:32:30 timshadel Exp $
018:         */
019:        public class TestMethodCollector extends TestCase {
020:
021:            /** Directory separator */
022:            private static final String SLASH = File.separator;
023:
024:            /**
025:             * Constructor required by JUnit.
026:             *
027:             * @param name the name of this test class.
028:             */
029:            public TestMethodCollector(String name) {
030:                super (name);
031:            }
032:
033:            /**
034:             * Tests the isTestClass method.
035:             *
036:             * @throws Exception if an error occurs.
037:             */
038:            public void testIsTestClass() throws Exception {
039:
040:                // Test class names
041:                final String prefixFoo = "Prefixfoo";
042:                final String testFoo = "Testfoo";
043:                final String fooTest = "fooTest";
044:                final String fooEnding = "fooEnding";
045:
046:                // valid grammars that begin with 'Prefix'
047:                final String testPrefix1 = "Prefix*.class";
048:                final String testPrefix2 = "Prefix*.java";
049:                final String testPrefix3 = "Prefix*.";
050:                final String testPrefix4 = "Prefix*";
051:
052:                // valid grammars that begin with 'Test'
053:                final String testGrammar1 = "Test*.class";
054:                final String testGrammar2 = "Test*.java";
055:                final String testGrammar3 = "Test*.";
056:                final String testGrammar4 = "Test*";
057:
058:                // valid grammars that end with 'Test'
059:                final String grammarTest1 = "*Test.class";
060:                final String grammarTest2 = "*Test.java";
061:                final String grammarTest3 = "*Test.";
062:                final String grammarTest4 = "*Test";
063:
064:                // valid grammars that end with 'Ending'
065:                final String grammarEnding1 = "*Ending.class";
066:                final String grammarEnding2 = "*Ending.java";
067:                final String grammarEnding3 = "*Ending.";
068:                final String grammarEnding4 = "*Ending";
069:
070:                // begin tests
071:                // test valid grammars that begin with 'Prefix'
072:                assertTrue("Checking " + testPrefix1, MethodCollector
073:                        .isTestClass(prefixFoo, testPrefix1));
074:                assertTrue("Checking " + testPrefix2, MethodCollector
075:                        .isTestClass(prefixFoo, testPrefix2));
076:                assertTrue("Checking " + testPrefix3, MethodCollector
077:                        .isTestClass(prefixFoo, testPrefix3));
078:                assertTrue("Checking " + testPrefix4, MethodCollector
079:                        .isTestClass(prefixFoo, testPrefix4));
080:
081:                // test valid grammars that begin with 'Test'
082:                assertTrue("Checking " + testGrammar1, MethodCollector
083:                        .isTestClass(testFoo, testGrammar1));
084:                assertTrue("Checking " + testGrammar2, MethodCollector
085:                        .isTestClass(testFoo, testGrammar2));
086:                assertTrue("Checking " + testGrammar3, MethodCollector
087:                        .isTestClass(testFoo, testGrammar3));
088:                assertTrue("Checking " + testGrammar4, MethodCollector
089:                        .isTestClass(testFoo, testGrammar4));
090:
091:                // test valid grammars that end with 'Test'
092:                assertTrue("Checking " + grammarTest1, MethodCollector
093:                        .isTestClass(fooTest, grammarTest1));
094:                assertTrue("Checking " + grammarTest2, MethodCollector
095:                        .isTestClass(fooTest, grammarTest2));
096:                assertTrue("Checking " + grammarTest3, MethodCollector
097:                        .isTestClass(fooTest, grammarTest3));
098:                assertTrue("Checking " + grammarTest4, MethodCollector
099:                        .isTestClass(fooTest, grammarTest4));
100:
101:                // test valid grammars that end with 'TestCase'
102:                assertTrue("Checking " + grammarEnding1, MethodCollector
103:                        .isTestClass(fooEnding, grammarEnding1));
104:                assertTrue("Checking " + grammarEnding2, MethodCollector
105:                        .isTestClass(fooEnding, grammarEnding2));
106:                assertTrue("Checking " + grammarEnding3, MethodCollector
107:                        .isTestClass(fooEnding, grammarEnding3));
108:                assertTrue("Checking " + grammarEnding4, MethodCollector
109:                        .isTestClass(fooEnding, grammarEnding4));
110:
111:                // test valid grammars with invalid class names
112:                assertTrue("Checking invalid class name " + testFoo + " with "
113:                        + grammarTest1, !MethodCollector.isTestClass(testFoo,
114:                        grammarTest1));
115:                assertTrue("Checking invalid class name " + fooTest + " with "
116:                        + testGrammar1, !MethodCollector.isTestClass(fooTest,
117:                        testGrammar1));
118:            }
119:
120:            /**
121:             * Tests the getJBlanketDir method.
122:             *
123:             * @throws Exception if error occurs.
124:             */
125:            public void testGetJBlanketDir() throws Exception {
126:
127:                String userDir = System.getProperty("user.home");
128:                String defaultJBlanketDir = userDir + SLASH + "jblanket";
129:                System.setProperty("jblanket.dir", "");
130:                String jblanketDir = MethodCollector.getJBlanketDir();
131:
132:                // begin tests
133:                assertEquals("Checking default JBlanket directory",
134:                        defaultJBlanketDir, jblanketDir);
135:                jblanketDir = System.getProperty("jblanket.dir");
136:                assertEquals("Checking JBlanket directory value",
137:                        defaultJBlanketDir, jblanketDir);
138:            }
139:
140:            /**
141:             * Tests the reconstructType method.
142:             */
143:            public void testReconstructType() {
144:
145:                // constant Pool type 'byte'
146:                final String byteType = "B";
147:                // constant Pool type 'char'
148:                final String charType = "C";
149:                // Constant Pool type 'double'
150:                final String doubleType = "D";
151:                // constant Pool type 'float'
152:                final String floatType = "F";
153:                // constant Pool type 'integer'
154:                final String intType = "I";
155:                // constant Pool type 'long'
156:                final String longType = "J";
157:                // constant Pool type 'short'
158:                final String shortType = "S";
159:                // constant Pool type 'boolean'
160:                final String booleanType = "Z";
161:                // constant Pool type 'java.util.List'
162:                final String objectType = "Ljava/util/List;";
163:                // constant Pool type 'double[][][]'
164:                final String arrayType = "[[[D";
165:                // constant Pool type 'csdl.jblanket.modify.MethodCollector[][]'
166:                final String objectArrayType = "[[" + objectType;
167:
168:                // begin tests
169:                assertEquals("checking 'byte' base type", "byte",
170:                        MethodCollector.reconstructType(byteType));
171:                assertEquals("checking 'char' base type", "char",
172:                        MethodCollector.reconstructType(charType));
173:                assertEquals("checking 'double' base type", "double",
174:                        MethodCollector.reconstructType(doubleType));
175:                assertEquals("checking 'float' base type", "float",
176:                        MethodCollector.reconstructType(floatType));
177:                assertEquals("checking 'int' base type", "int", MethodCollector
178:                        .reconstructType(intType));
179:                assertEquals("checking 'long' base type", "long",
180:                        MethodCollector.reconstructType(longType));
181:                assertEquals("checking 'short' base type", "short",
182:                        MethodCollector.reconstructType(shortType));
183:                assertEquals("checking 'boolean' base type", "boolean",
184:                        MethodCollector.reconstructType(booleanType));
185:                assertEquals("checking object type", "java.util.List",
186:                        MethodCollector.reconstructType(objectType));
187:                assertEquals("checking 3-D 'double' array type",
188:                        "double[][][]", MethodCollector
189:                                .reconstructType(arrayType));
190:                assertEquals("checking 2-D object array type",
191:                        "java.util.List[][]", MethodCollector
192:                                .reconstructType(objectArrayType));
193:            }
194:
195:            /**
196:             * Tests the storeMethodData method.
197:             *
198:             * @throws Exception if error occurs.
199:             */
200:            public void testStoreMethodData() throws Exception {
201:
202:                // test MethodSet to store
203:                MethodSet testSet = new MethodSet();
204:
205:                // directory holding data for testing
206:                String testDir = System.getProperty("jblanket.testdir") + SLASH
207:                        + "testmethodcollector";
208:                // name of output XML file for output
209:                final String xmlFile = "testMethodSet.xml";
210:
211:                // MethodInfo object with 2 parameters
212:                MethodInfo methodInfo1;
213:                // MethodInfo object with no parameters
214:                MethodInfo methodInfo2;
215:
216:                // fully qualified class name for first class
217:                final String class1 = "java.lang.String";
218:                // fully qualified class name for second class
219:                final String class2 = "java.lang.Boolean";
220:                // fully qualified class name for third class
221:                final String class3 = "foo.bar.Baz";
222:                // fully qualified class name for fourth class
223:                final String class4 = "foo.bar.Foo";
224:
225:                // name of first method
226:                final String method1 = "getQux";
227:                // name of second method
228:                final String method2 = "setQux";
229:
230:                // creat MethodInfo instances.
231:                List params = new ArrayList();
232:                params.add(class1);
233:                params.add(class2);
234:                methodInfo1 = new MethodInfo(class3, method1, params);
235:                methodInfo2 = new MethodInfo(class4, method2, new ArrayList());
236:
237:                // load test MethodSet
238:                testSet.add(methodInfo1);
239:                testSet.add(methodInfo2);
240:
241:                // create output directory
242:                File outDir = new File(testDir);
243:                if (!outDir.exists()) {
244:                    outDir.mkdirs();
245:                }
246:
247:                // begin test
248:                try {
249:                    MethodCollector.storeMethodData(testSet, testDir + SLASH
250:                            + xmlFile, class3, new Date());
251:                } catch (Exception e) {
252:                    fail("Checking storeMethodData method");
253:                }
254:            }
255:
256:            /**
257:             * Tests the removePackagePrefix method.
258:             */
259:            public void testRemovePackagePrefix() {
260:                // fully qualified class name for String class
261:                final String string = "java.lang.String";
262:                assertEquals("Checking removePackagePrefix method", "String",
263:                        MethodCollector.removePackagePrefix(string));
264:            }
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.