Source Code Cross Referenced for TestCounters.java in  » UML » jrefactory » org » acm » seguin » summary » 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 » UML » jrefactory » org.acm.seguin.summary 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.acm.seguin.summary;
002:
003:        import org.acm.seguin.io.FileCopy;
004:        import java.util.Iterator;
005:        import java.io.File;
006:        import org.acm.seguin.junit.DirSourceTestCase;
007:
008:        /**
009:         *  Unit tests to check that we get all the counts correct
010:         *
011:         *@author    Chris Seguin
012:         */
013:        public class TestCounters extends DirSourceTestCase {
014:            private File destDir;
015:
016:            /**
017:             *  Constructor for the TestCounters object
018:             *
019:             *@param  name  The name of the test method to invoke
020:             */
021:            public TestCounters(String name) {
022:                super (name);
023:            }
024:
025:            /**
026:             *  A unit test for JUnit
027:             */
028:            public void test01() {
029:                FileSummary fileSummary = FileSummary.getFileSummary(new File(
030:                        destDir, "NoPackage.java"));
031:
032:                Iterator iter = fileSummary.getImports();
033:                ImportSummary one = (ImportSummary) iter.next();
034:                assertEquals("Started at the wrong place - import #1", 1, one
035:                        .getStartLine());
036:                assertEquals("Ended at the wrong place - import #1", 1, one
037:                        .getEndLine());
038:
039:                ImportSummary two = (ImportSummary) iter.next();
040:                assertEquals("Started at the wrong place - import #2", 2, two
041:                        .getStartLine());
042:                assertEquals("Ended at the wrong place - import #2", 2, two
043:                        .getEndLine());
044:
045:                TypeSummary typeSummary = (TypeSummary) (fileSummary.getTypes()
046:                        .next());
047:
048:                iter = typeSummary.getFields();
049:                int[][] results = new int[][] { { 5, 8 }, { 9, 10 },
050:                        { 11, 18 }, { 19, 23 }, { 19, 24 } };
051:                for (int ndx = 0; ndx < 5; ndx++) {
052:                    FieldSummary next = (FieldSummary) iter.next();
053:                    assertEquals("Started at the wrong place - field " + ndx,
054:                            results[ndx][0], next.getStartLine());
055:                    assertEquals("Ended at the wrong place - field " + ndx,
056:                            results[ndx][1], next.getEndLine());
057:                }
058:
059:                assertEquals("Started at the wrong place - type", 3,
060:                        typeSummary.getStartLine());
061:                assertEquals("Ended at the wrong place - type", 25, typeSummary
062:                        .getEndLine());
063:            }
064:
065:            /**
066:             *  A unit test for JUnit
067:             */
068:            public void test02() {
069:                FileSummary fileSummary = FileSummary.getFileSummary(new File(
070:                        destDir, "MethodCounts.java"));
071:
072:                Iterator iter = fileSummary.getImports();
073:                ImportSummary one = (ImportSummary) iter.next();
074:                assertEquals("Started at the wrong place - import #1", 2, one
075:                        .getStartLine());
076:                assertEquals("Ended at the wrong place - import #1", 3, one
077:                        .getEndLine());
078:
079:                ImportSummary two = (ImportSummary) iter.next();
080:                assertEquals("Started at the wrong place - import #2", 4, two
081:                        .getStartLine());
082:                assertEquals("Ended at the wrong place - import #2", 4, two
083:                        .getEndLine());
084:
085:                TypeSummary typeSummary = (TypeSummary) (fileSummary.getTypes()
086:                        .next());
087:
088:                iter = typeSummary.getMethods();
089:                int[][] results = new int[][] { { 12, 29, 7, 2 },
090:                        { 30, 43, 5, 3 }, { 44, 53, 1, 1 }, { 54, 75, 8, 2 },
091:                        { 76, 97, 6, 2 } };
092:                for (int ndx = 0; ndx < 5; ndx++) {
093:                    MethodSummary next = (MethodSummary) iter.next();
094:                    assertEquals("Started at the wrong place - method " + ndx,
095:                            results[ndx][0], next.getStartLine());
096:                    assertEquals("Ended at the wrong place - method " + ndx,
097:                            results[ndx][1], next.getEndLine());
098:                    assertEquals("Wrong statement count - method " + ndx,
099:                            results[ndx][2], next.getStatementCount());
100:                    assertEquals("Wrong block depth - method " + ndx,
101:                            results[ndx][3], next.getMaxBlockDepth());
102:                }
103:
104:                assertEquals("Started at the wrong place - type", 5,
105:                        typeSummary.getStartLine());
106:                assertEquals("Ended at the wrong place - type", 98, typeSummary
107:                        .getEndLine());
108:            }
109:
110:            /**
111:             *  A unit test for JUnit
112:             */
113:            public void test03() {
114:                FileSummary fileSummary = FileSummary.getFileSummary(new File(
115:                        destDir, "ConstructorCounts.java"));
116:
117:                Iterator iter = fileSummary.getImports();
118:                ImportSummary one = (ImportSummary) iter.next();
119:                assertEquals("Started at the wrong place - import #1", 2, one
120:                        .getStartLine());
121:                assertEquals("Ended at the wrong place - import #1", 3, one
122:                        .getEndLine());
123:
124:                ImportSummary two = (ImportSummary) iter.next();
125:                assertEquals("Started at the wrong place - import #2", 4, two
126:                        .getStartLine());
127:                assertEquals("Ended at the wrong place - import #2", 4, two
128:                        .getEndLine());
129:
130:                TypeSummary typeSummary = (TypeSummary) (fileSummary.getTypes()
131:                        .next());
132:
133:                iter = typeSummary.getMethods();
134:                int[][] results = new int[][] { { 12, 28, 7, 2, 0, 16 },
135:                        { 29, 46, 6, 3, 1, 36 }, { 47, 58, 2, 1, 1, 54 },
136:                        { 59, 82, 9, 2, 2, 67 }, { 83, 115, 7, 2, 3, 94 } };
137:                for (int ndx = 0; ndx < 5; ndx++) {
138:                    MethodSummary next = (MethodSummary) iter.next();
139:                    assertEquals("Started at the wrong place - constructor "
140:                            + ndx, results[ndx][0], next.getStartLine());
141:                    assertEquals("Ended at the wrong place - constructor "
142:                            + ndx, results[ndx][1], next.getEndLine());
143:                    assertEquals("Wrong statement count - constructor " + ndx,
144:                            results[ndx][2], next.getStatementCount());
145:                    assertEquals("Wrong block depth - constructor " + ndx,
146:                            results[ndx][3], next.getMaxBlockDepth());
147:                    assertEquals("Wrong parameter count - constructor " + ndx,
148:                            results[ndx][4], next.getParameterCount());
149:                    assertEquals("Wrong declaration line - constructor " + ndx,
150:                            results[ndx][5], next.getDeclarationLine());
151:                }
152:
153:                assertEquals("Started at the wrong place - type", 5,
154:                        typeSummary.getStartLine());
155:                assertEquals("Ended at the wrong place - type", 119,
156:                        typeSummary.getEndLine());
157:            }
158:
159:            /**
160:             *  A unit test for JUnit
161:             */
162:            public void test04() {
163:                FileSummary fileSummary = FileSummary.getFileSummary(new File(
164:                        destDir, "TypeCount.java"));
165:
166:                Iterator iter = fileSummary.getImports();
167:                ImportSummary one = (ImportSummary) iter.next();
168:                assertEquals("Started at the wrong place - import #1", 2, one
169:                        .getStartLine());
170:                assertEquals("Ended at the wrong place - import #1", 3, one
171:                        .getEndLine());
172:
173:                ImportSummary two = (ImportSummary) iter.next();
174:                assertEquals("Started at the wrong place - import #2", 4, two
175:                        .getStartLine());
176:                assertEquals("Ended at the wrong place - import #2", 4, two
177:                        .getEndLine());
178:
179:                TypeSummary typeSummary = (TypeSummary) (fileSummary.getTypes()
180:                        .next());
181:
182:                iter = typeSummary.getTypes();
183:                TypeSummary nestedClass = (TypeSummary) iter.next();
184:                TypeSummary nestedInterface = (TypeSummary) iter.next();
185:
186:                assertEquals("Started at the wrong place - nested class", 15,
187:                        nestedClass.getStartLine());
188:                assertEquals("Ended at the wrong place - nested class", 30,
189:                        nestedClass.getEndLine());
190:                FieldSummary field = (FieldSummary) nestedClass.getFields()
191:                        .next();
192:                MethodSummary abstractMethod = (MethodSummary) nestedClass
193:                        .getMethods().next();
194:                assertEquals("Started at the wrong place - field", 23, field
195:                        .getStartLine());
196:                assertEquals("Ended at the wrong place - field", 23, field
197:                        .getEndLine());
198:                assertEquals("Started at the wrong place - abstract method",
199:                        24, abstractMethod.getStartLine());
200:                assertEquals("Ended at the wrong place - abstract method", 29,
201:                        abstractMethod.getEndLine());
202:
203:                assertEquals("Started at the wrong place - nested interface",
204:                        31, nestedInterface.getStartLine());
205:                MethodSummary interfaceMethod = (MethodSummary) nestedInterface
206:                        .getMethods().next();
207:                assertEquals("Started at the wrong place - interface method",
208:                        40, interfaceMethod.getStartLine());
209:                assertEquals("Ended at the wrong place - interface method", 45,
210:                        interfaceMethod.getEndLine());
211:                assertEquals("Ended at the wrong place - nested interface", 46,
212:                        nestedInterface.getEndLine());
213:
214:                assertEquals("Started at the wrong place - type", 5,
215:                        typeSummary.getStartLine());
216:                assertEquals("Ended at the wrong place - type", 47, typeSummary
217:                        .getEndLine());
218:            }
219:
220:            /**
221:             *  A unit test for JUnit
222:             */
223:            public void test05() {
224:                FileSummary fileSummary = FileSummary.getFileSummary(new File(
225:                        destDir, "AnonymousClassCounts.java"));
226:
227:                Iterator iter = fileSummary.getImports();
228:                ImportSummary one = (ImportSummary) iter.next();
229:                assertEquals("Started at the wrong place - import #1", 2, one
230:                        .getStartLine());
231:                assertEquals("Ended at the wrong place - import #1", 3, one
232:                        .getEndLine());
233:
234:                ImportSummary two = (ImportSummary) iter.next();
235:                assertEquals("Started at the wrong place - import #2", 4, two
236:                        .getStartLine());
237:                assertEquals("Ended at the wrong place - import #2", 4, two
238:                        .getEndLine());
239:
240:                TypeSummary typeSummary = (TypeSummary) (fileSummary.getTypes()
241:                        .next());
242:                assertEquals("Started at the wrong place - type", 5,
243:                        typeSummary.getStartLine());
244:
245:                FieldSummary field = (FieldSummary) typeSummary.getFields()
246:                        .next();
247:                assertEquals("Started at the wrong place - field", 12, field
248:                        .getStartLine());
249:                assertEquals("Ended at the wrong place - field", 23, field
250:                        .getEndLine());
251:
252:                iter = typeSummary.getMethods();
253:                MethodSummary method = (MethodSummary) iter.next();
254:                while (!method.getName().equals("getResults")) {
255:                    method = (MethodSummary) iter.next();
256:                }
257:                assertEquals("Started at the wrong place - method", 24, method
258:                        .getStartLine());
259:                assertEquals("Ended at the wrong place - method", 57, method
260:                        .getEndLine());
261:
262:                assertEquals("Ended at the wrong place - type", 58, typeSummary
263:                        .getEndLine());
264:            }
265:
266:            /**
267:             *  The JUnit setup method
268:             */
269:            protected void setUp() {
270:                File cleanDir = new File(clean);
271:                destDir = new File(root + "\\count");
272:                destDir.mkdirs();
273:
274:                (new FileCopy(new File(cleanDir, "count_NoPackage.java"),
275:                        new File(destDir, "NoPackage.java"), false)).run();
276:
277:                (new FileCopy(new File(cleanDir, "count_MethodCounts.java"),
278:                        new File(destDir, "MethodCounts.java"), false)).run();
279:
280:                (new FileCopy(
281:                        new File(cleanDir, "count_ConstructorCounts.java"),
282:                        new File(destDir, "ConstructorCounts.java"), false))
283:                        .run();
284:
285:                (new FileCopy(new File(cleanDir, "count_TypeCount.java"),
286:                        new File(destDir, "TypeCount.java"), false)).run();
287:
288:                (new FileCopy(new File(cleanDir,
289:                        "count_AnonymousClassCounts.java"), new File(destDir,
290:                        "AnonymousClassCounts.java"), false)).run();
291:            }
292:
293:            /**
294:             *  The teardown method for JUnit
295:             */
296:            protected void tearDown() {
297:                (new File(destDir, "NoPackage.java")).delete();
298:                (new File(destDir, "MethodCounts.java")).delete();
299:                (new File(destDir, "ConstructorCounts.java")).delete();
300:                (new File(destDir, "TypeCount.java")).delete();
301:                (new File(destDir, "AnonymousClassCounts.java")).delete();
302:            }
303:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.