Source Code Cross Referenced for TestMetricsGathererDependencies.java in  » Code-Analyzer » DependencyFinder » com » jeantessier » metrics » 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 » DependencyFinder » com.jeantessier.metrics 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright (c) 2001-2007, Jean Tessier
003:         *  All rights reserved.
004:         *  
005:         *  Redistribution and use in source and binary forms, with or without
006:         *  modification, are permitted provided that the following conditions
007:         *  are met:
008:         *  
009:         *      * Redistributions of source code must retain the above copyright
010:         *        notice, this list of conditions and the following disclaimer.
011:         *  
012:         *      * Redistributions in binary form must reproduce the above copyright
013:         *        notice, this list of conditions and the following disclaimer in the
014:         *        documentation and/or other materials provided with the distribution.
015:         *  
016:         *      * Neither the name of Jean Tessier nor the names of his contributors
017:         *        may be used to endorse or promote products derived from this software
018:         *        without specific prior written permission.
019:         *  
020:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
021:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
022:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
023:         *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
024:         *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025:         *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026:         *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
027:         *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
028:         *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
029:         *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030:         *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031:         */
032:
033:        package com.jeantessier.metrics;
034:
035:        import junit.framework.*;
036:
037:        import java.io.*;
038:        import java.util.*;
039:
040:        import org.xml.sax.*;
041:
042:        import org.apache.log4j.*;
043:
044:        import com.jeantessier.classreader.*;
045:
046:        public class TestMetricsGathererDependencies extends TestCase {
047:            public static final String TEST_DIRNAME = "classes"
048:                    + File.separator + "testpackage";
049:            public static final String OTHER_DIRNAME = "classes"
050:                    + File.separator + "otherpackage";
051:
052:            private MetricsFactory factory;
053:
054:            protected void setUp() throws Exception {
055:                Logger.getLogger(getClass()).debug(
056:                        "Starting " + getName() + " ...");
057:
058:                factory = new MetricsFactory("test",
059:                        new MetricsConfigurationLoader(Boolean
060:                                .getBoolean("DEPENDENCYFINDER_TESTS_VALIDATE"))
061:                                .load("etc" + File.separator
062:                                        + "MetricsConfig.xml"));
063:
064:                ClassfileLoader loader = new AggregatingClassfileLoader();
065:                Collection<String> dirs = new ArrayList<String>();
066:                dirs.add(TEST_DIRNAME);
067:                dirs.add(OTHER_DIRNAME);
068:                loader.load(dirs);
069:
070:                MetricsGatherer gatherer = new MetricsGatherer("test", factory);
071:                gatherer.visitClassfiles(loader.getAllClassfiles());
072:            }
073:
074:            protected void tearDown() throws Exception {
075:                Logger.getLogger(getClass()).debug(
076:                        "Done with " + getName() + " ...");
077:            }
078:
079:            public void testpackage_TestClass_testMethod() {
080:                Collection dependencies;
081:
082:                dependencies = ((CollectionMeasurement) factory
083:                        .createMethodMetrics(
084:                                "testpackage.TestClass.testMethod(java.lang.String)")
085:                        .getMeasurement(
086:                                Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES))
087:                        .getValues();
088:                assertTrue(
089:                        Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES
090:                                + " "
091:                                + dependencies
092:                                + " missing testpackage.TestClass.sourceMethod()",
093:                        dependencies
094:                                .contains("testpackage.TestClass.sourceMethod()"));
095:                assertEquals(Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES
096:                        + " " + dependencies, 1, dependencies.size());
097:
098:                dependencies = ((CollectionMeasurement) factory
099:                        .createMethodMetrics(
100:                                "testpackage.TestClass.testMethod(java.lang.String)")
101:                        .getMeasurement(
102:                                Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES))
103:                        .getValues();
104:                assertTrue(
105:                        Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
106:                                + " "
107:                                + dependencies
108:                                + " missing testpackage.SourceClass.sourceMethod()",
109:                        dependencies
110:                                .contains("testpackage.SourceClass.sourceMethod()"));
111:                assertEquals(Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
112:                        + " " + dependencies, 1, dependencies.size());
113:
114:                dependencies = ((CollectionMeasurement) factory
115:                        .createMethodMetrics(
116:                                "testpackage.TestClass.testMethod(java.lang.String)")
117:                        .getMeasurement(
118:                                Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES))
119:                        .getValues();
120:                assertTrue(
121:                        Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
122:                                + " "
123:                                + dependencies
124:                                + " missing otherpackage.SourceClass.sourceMethod()",
125:                        dependencies
126:                                .contains("otherpackage.SourceClass.sourceMethod()"));
127:                assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
128:                        + " " + dependencies, 1, dependencies.size());
129:
130:                dependencies = ((CollectionMeasurement) factory
131:                        .createMethodMetrics(
132:                                "testpackage.TestClass.testMethod(java.lang.String)")
133:                        .getMeasurement(
134:                                Metrics.OUTBOUND_INTRA_CLASS_FEATURE_DEPENDENCIES))
135:                        .getValues();
136:                assertTrue(
137:                        Metrics.OUTBOUND_INTRA_CLASS_FEATURE_DEPENDENCIES
138:                                + " "
139:                                + dependencies
140:                                + " missing testpackage.TestClass.targetMethod()",
141:                        dependencies
142:                                .contains("testpackage.TestClass.targetMethod()"));
143:                assertEquals(Metrics.OUTBOUND_INTRA_CLASS_FEATURE_DEPENDENCIES
144:                        + " " + dependencies, 1, dependencies.size());
145:
146:                dependencies = ((CollectionMeasurement) factory
147:                        .createMethodMetrics(
148:                                "testpackage.TestClass.testMethod(java.lang.String)")
149:                        .getMeasurement(
150:                                Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES))
151:                        .getValues();
152:                assertTrue(
153:                        Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES
154:                                + " "
155:                                + dependencies
156:                                + " missing testpackage.TargetClass.TargetClass()",
157:                        dependencies
158:                                .contains("testpackage.TargetClass.TargetClass()"));
159:                assertTrue(
160:                        Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES
161:                                + " "
162:                                + dependencies
163:                                + " missing testpackage.TargetClass.targetMethod()",
164:                        dependencies
165:                                .contains("testpackage.TargetClass.targetMethod()"));
166:                assertEquals(
167:                        Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES
168:                                + " " + dependencies, 2, dependencies.size());
169:
170:                dependencies = ((CollectionMeasurement) factory
171:                        .createMethodMetrics(
172:                                "testpackage.TestClass.testMethod(java.lang.String)")
173:                        .getMeasurement(
174:                                Metrics.OUTBOUND_INTRA_PACKAGE_CLASS_DEPENDENCIES))
175:                        .getValues();
176:                assertTrue(Metrics.OUTBOUND_INTRA_PACKAGE_CLASS_DEPENDENCIES
177:                        + " " + dependencies
178:                        + " missing testpackage.TargetClass", dependencies
179:                        .contains("testpackage.TargetClass"));
180:                assertEquals(Metrics.OUTBOUND_INTRA_PACKAGE_CLASS_DEPENDENCIES
181:                        + " " + dependencies, 1, dependencies.size());
182:
183:                dependencies = ((CollectionMeasurement) factory
184:                        .createMethodMetrics(
185:                                "testpackage.TestClass.testMethod(java.lang.String)")
186:                        .getMeasurement(
187:                                Metrics.OUTBOUND_EXTRA_PACKAGE_FEATURE_DEPENDENCIES))
188:                        .getValues();
189:                assertTrue(Metrics.OUTBOUND_EXTRA_PACKAGE_FEATURE_DEPENDENCIES
190:                        + " " + dependencies
191:                        + " missing java.lang.Object.Object()", dependencies
192:                        .contains("java.lang.Object.Object()"));
193:                assertEquals(
194:                        Metrics.OUTBOUND_EXTRA_PACKAGE_FEATURE_DEPENDENCIES
195:                                + " " + dependencies, 1, dependencies.size());
196:
197:                dependencies = ((CollectionMeasurement) factory
198:                        .createMethodMetrics(
199:                                "testpackage.TestClass.testMethod(java.lang.String)")
200:                        .getMeasurement(
201:                                Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES))
202:                        .getValues();
203:                assertTrue(Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES
204:                        + " " + dependencies + " missing java.lang.Object",
205:                        dependencies.contains("java.lang.Object"));
206:                assertTrue(Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES
207:                        + " " + dependencies + " missing java.lang.String",
208:                        dependencies.contains("java.lang.String"));
209:                assertEquals(Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES
210:                        + " " + dependencies, 2, dependencies.size());
211:            }
212:
213:            public void testpackage_TestClass() {
214:                Collection dependencies;
215:
216:                dependencies = ((CollectionMeasurement) factory
217:                        .createClassMetrics("testpackage.TestClass")
218:                        .getMeasurement(
219:                                Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES))
220:                        .getValues();
221:                assertTrue(Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
222:                        + dependencies + " missing testpackage.SourceClass",
223:                        dependencies.contains("testpackage.SourceClass"));
224:                assertEquals(Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
225:                        + dependencies, 1, dependencies.size());
226:
227:                dependencies = ((CollectionMeasurement) factory
228:                        .createClassMetrics("testpackage.TestClass")
229:                        .getMeasurement(
230:                                Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES))
231:                        .getValues();
232:                assertTrue(Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
233:                        + dependencies + " missing otherpackage.SourceClass",
234:                        dependencies.contains("otherpackage.SourceClass"));
235:                assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
236:                        + dependencies, 1, dependencies.size());
237:
238:                dependencies = ((CollectionMeasurement) factory
239:                        .createClassMetrics("testpackage.TestClass")
240:                        .getMeasurement(
241:                                Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES))
242:                        .getValues();
243:                assertTrue(
244:                        Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
245:                                + dependencies
246:                                + " missing testpackage.TargetInterface",
247:                        dependencies.contains("testpackage.TargetInterface"));
248:                assertEquals(Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
249:                        + dependencies, 1, dependencies.size());
250:
251:                dependencies = ((CollectionMeasurement) factory
252:                        .createClassMetrics("testpackage.TestClass")
253:                        .getMeasurement(
254:                                Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES))
255:                        .getValues();
256:                assertTrue(Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
257:                        + dependencies + " missing java.lang.Object",
258:                        dependencies.contains("java.lang.Object"));
259:                assertEquals(Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
260:                        + dependencies, 1, dependencies.size());
261:
262:                dependencies = ((CollectionMeasurement) factory
263:                        .createClassMetrics("testpackage.TestClass")
264:                        .getMeasurement(
265:                                Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES))
266:                        .getValues();
267:                assertTrue(
268:                        Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
269:                                + " "
270:                                + dependencies
271:                                + " missing testpackage.SourceClass.sourceMethod()",
272:                        dependencies
273:                                .contains("testpackage.SourceClass.sourceMethod()"));
274:                assertEquals(Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
275:                        + " " + dependencies, 1, dependencies.size());
276:
277:                dependencies = ((CollectionMeasurement) factory
278:                        .createClassMetrics("testpackage.TestClass")
279:                        .getMeasurement(
280:                                Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES))
281:                        .getValues();
282:                assertTrue(
283:                        Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
284:                                + " "
285:                                + dependencies
286:                                + " missing otherpackage.SourceClass.sourceMethod()",
287:                        dependencies
288:                                .contains("otherpackage.SourceClass.sourceMethod()"));
289:                assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
290:                        + " " + dependencies, 1, dependencies.size());
291:            }
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.