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 TestMetricsGathererDependenciesScope 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: private ClassfileLoader loader;
054: private MetricsGatherer gatherer;
055:
056: protected void setUp() throws Exception {
057: Logger.getLogger(getClass()).debug(
058: "Starting " + getName() + " ...");
059:
060: factory = new MetricsFactory("test",
061: new MetricsConfigurationLoader(Boolean
062: .getBoolean("DEPENDENCYFINDER_TESTS_VALIDATE"))
063: .load("etc" + File.separator
064: + "MetricsConfig.xml"));
065:
066: Collection<String> dirs = new ArrayList<String>();
067: dirs.add(TEST_DIRNAME);
068: dirs.add(OTHER_DIRNAME);
069: loader = new AggregatingClassfileLoader();
070: loader.load(dirs);
071:
072: gatherer = new MetricsGatherer("test", factory);
073: }
074:
075: protected void tearDown() throws Exception {
076: Logger.getLogger(getClass()).debug(
077: "Done with " + getName() + " ...");
078: }
079:
080: public void testpackage_TestClass_testMethod_IntraClass() {
081: Collection scopeIncludes = new HashSet();
082: scopeIncludes.add("testpackage.TestClass.sourceMethod()");
083:
084: gatherer.setScopeIncludes(scopeIncludes);
085: gatherer.visitClassfiles(loader.getAllClassfiles());
086:
087: Collection dependencies;
088:
089: dependencies = ((CollectionMeasurement) factory
090: .createMethodMetrics(
091: "testpackage.TestClass.testMethod(java.lang.String)")
092: .getMeasurement(
093: Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES))
094: .getValues();
095: assertTrue(
096: Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES
097: + " "
098: + dependencies
099: + " missing testpackage.TestClass.sourceMethod()",
100: dependencies
101: .contains("testpackage.TestClass.sourceMethod()"));
102: assertEquals(Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES
103: + " " + dependencies, 1, dependencies.size());
104:
105: dependencies = ((CollectionMeasurement) factory
106: .createMethodMetrics(
107: "testpackage.TestClass.testMethod(java.lang.String)")
108: .getMeasurement(
109: Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES))
110: .getValues();
111: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
112: + " " + dependencies, 0, 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: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
121: + " " + dependencies, 0, dependencies.size());
122:
123: dependencies = ((CollectionMeasurement) factory
124: .createMethodMetrics(
125: "testpackage.TestClass.testMethod(java.lang.String)")
126: .getMeasurement(
127: Metrics.OUTBOUND_INTRA_CLASS_FEATURE_DEPENDENCIES))
128: .getValues();
129: assertEquals(Metrics.OUTBOUND_INTRA_CLASS_FEATURE_DEPENDENCIES
130: + " " + dependencies, 0, dependencies.size());
131:
132: dependencies = ((CollectionMeasurement) factory
133: .createMethodMetrics(
134: "testpackage.TestClass.testMethod(java.lang.String)")
135: .getMeasurement(
136: Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES))
137: .getValues();
138: assertEquals(
139: Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES
140: + " " + dependencies, 0, dependencies.size());
141:
142: dependencies = ((CollectionMeasurement) factory
143: .createMethodMetrics(
144: "testpackage.TestClass.testMethod(java.lang.String)")
145: .getMeasurement(
146: Metrics.OUTBOUND_INTRA_PACKAGE_CLASS_DEPENDENCIES))
147: .getValues();
148: assertEquals(Metrics.OUTBOUND_INTRA_PACKAGE_CLASS_DEPENDENCIES
149: + " " + dependencies, 0, dependencies.size());
150:
151: dependencies = ((CollectionMeasurement) factory
152: .createMethodMetrics(
153: "testpackage.TestClass.testMethod(java.lang.String)")
154: .getMeasurement(
155: Metrics.OUTBOUND_EXTRA_PACKAGE_FEATURE_DEPENDENCIES))
156: .getValues();
157: assertEquals(
158: Metrics.OUTBOUND_EXTRA_PACKAGE_FEATURE_DEPENDENCIES
159: + " " + dependencies, 0, dependencies.size());
160:
161: dependencies = ((CollectionMeasurement) factory
162: .createMethodMetrics(
163: "testpackage.TestClass.testMethod(java.lang.String)")
164: .getMeasurement(
165: Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES))
166: .getValues();
167: assertEquals(Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES
168: + " " + dependencies, 0, dependencies.size());
169: }
170:
171: public void testpackage_TestClass_testMethod_IntraPackage() {
172: Collection scopeIncludes = new HashSet();
173: scopeIncludes.add("testpackage.SourceClass.sourceMethod()");
174:
175: gatherer.setScopeIncludes(scopeIncludes);
176: gatherer.visitClassfiles(loader.getAllClassfiles());
177:
178: Collection dependencies;
179:
180: dependencies = ((CollectionMeasurement) factory
181: .createMethodMetrics(
182: "testpackage.TestClass.testMethod(java.lang.String)")
183: .getMeasurement(
184: Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES))
185: .getValues();
186: assertEquals(Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES
187: + " " + dependencies, 0, dependencies.size());
188:
189: dependencies = ((CollectionMeasurement) factory
190: .createMethodMetrics(
191: "testpackage.TestClass.testMethod(java.lang.String)")
192: .getMeasurement(
193: Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES))
194: .getValues();
195: assertTrue(
196: Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
197: + " "
198: + dependencies
199: + " missing testpackage.SourceClass.sourceMethod()",
200: dependencies
201: .contains("testpackage.SourceClass.sourceMethod()"));
202: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
203: + " " + dependencies, 1, dependencies.size());
204:
205: dependencies = ((CollectionMeasurement) factory
206: .createMethodMetrics(
207: "testpackage.TestClass.testMethod(java.lang.String)")
208: .getMeasurement(
209: Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES))
210: .getValues();
211: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
212: + " " + dependencies, 0, dependencies.size());
213:
214: dependencies = ((CollectionMeasurement) factory
215: .createMethodMetrics(
216: "testpackage.TestClass.testMethod(java.lang.String)")
217: .getMeasurement(
218: Metrics.OUTBOUND_INTRA_CLASS_FEATURE_DEPENDENCIES))
219: .getValues();
220: assertEquals(Metrics.OUTBOUND_INTRA_CLASS_FEATURE_DEPENDENCIES
221: + " " + dependencies, 0, dependencies.size());
222:
223: dependencies = ((CollectionMeasurement) factory
224: .createMethodMetrics(
225: "testpackage.TestClass.testMethod(java.lang.String)")
226: .getMeasurement(
227: Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES))
228: .getValues();
229: assertEquals(
230: Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES
231: + " " + dependencies, 0, dependencies.size());
232:
233: dependencies = ((CollectionMeasurement) factory
234: .createMethodMetrics(
235: "testpackage.TestClass.testMethod(java.lang.String)")
236: .getMeasurement(
237: Metrics.OUTBOUND_INTRA_PACKAGE_CLASS_DEPENDENCIES))
238: .getValues();
239: assertEquals(Metrics.OUTBOUND_INTRA_PACKAGE_CLASS_DEPENDENCIES
240: + " " + dependencies, 0, dependencies.size());
241:
242: dependencies = ((CollectionMeasurement) factory
243: .createMethodMetrics(
244: "testpackage.TestClass.testMethod(java.lang.String)")
245: .getMeasurement(
246: Metrics.OUTBOUND_EXTRA_PACKAGE_FEATURE_DEPENDENCIES))
247: .getValues();
248: assertEquals(
249: Metrics.OUTBOUND_EXTRA_PACKAGE_FEATURE_DEPENDENCIES
250: + " " + dependencies, 0, dependencies.size());
251:
252: dependencies = ((CollectionMeasurement) factory
253: .createMethodMetrics(
254: "testpackage.TestClass.testMethod(java.lang.String)")
255: .getMeasurement(
256: Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES))
257: .getValues();
258: assertEquals(Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES
259: + " " + dependencies, 0, dependencies.size());
260: }
261:
262: public void testpackage_TestClass_testMethod_ExtraPackage() {
263: Collection filterIncludes = new HashSet();
264: filterIncludes.add("otherpackage.SourceClass.sourceMethod()");
265:
266: gatherer.setScopeIncludes(filterIncludes);
267: gatherer.visitClassfiles(loader.getAllClassfiles());
268:
269: Collection dependencies;
270:
271: dependencies = ((CollectionMeasurement) factory
272: .createMethodMetrics(
273: "testpackage.TestClass.testMethod(java.lang.String)")
274: .getMeasurement(
275: Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES))
276: .getValues();
277: assertEquals(Metrics.INBOUND_INTRA_CLASS_METHOD_DEPENDENCIES
278: + " " + dependencies, 0, dependencies.size());
279:
280: dependencies = ((CollectionMeasurement) factory
281: .createMethodMetrics(
282: "testpackage.TestClass.testMethod(java.lang.String)")
283: .getMeasurement(
284: Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES))
285: .getValues();
286: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
287: + " " + dependencies, 0, dependencies.size());
288:
289: dependencies = ((CollectionMeasurement) factory
290: .createMethodMetrics(
291: "testpackage.TestClass.testMethod(java.lang.String)")
292: .getMeasurement(
293: Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES))
294: .getValues();
295: assertTrue(
296: Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
297: + " "
298: + dependencies
299: + " missing otherpackage.SourceClass.sourceMethod()",
300: dependencies
301: .contains("otherpackage.SourceClass.sourceMethod()"));
302: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
303: + " " + dependencies, 1, dependencies.size());
304:
305: dependencies = ((CollectionMeasurement) factory
306: .createMethodMetrics(
307: "testpackage.TestClass.testMethod(java.lang.String)")
308: .getMeasurement(
309: Metrics.OUTBOUND_INTRA_CLASS_FEATURE_DEPENDENCIES))
310: .getValues();
311: assertEquals(Metrics.OUTBOUND_INTRA_CLASS_FEATURE_DEPENDENCIES
312: + " " + dependencies, 0, dependencies.size());
313:
314: dependencies = ((CollectionMeasurement) factory
315: .createMethodMetrics(
316: "testpackage.TestClass.testMethod(java.lang.String)")
317: .getMeasurement(
318: Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES))
319: .getValues();
320: assertEquals(
321: Metrics.OUTBOUND_INTRA_PACKAGE_FEATURE_DEPENDENCIES
322: + " " + dependencies, 0, dependencies.size());
323:
324: dependencies = ((CollectionMeasurement) factory
325: .createMethodMetrics(
326: "testpackage.TestClass.testMethod(java.lang.String)")
327: .getMeasurement(
328: Metrics.OUTBOUND_INTRA_PACKAGE_CLASS_DEPENDENCIES))
329: .getValues();
330: assertEquals(Metrics.OUTBOUND_INTRA_PACKAGE_CLASS_DEPENDENCIES
331: + " " + dependencies, 0, dependencies.size());
332:
333: dependencies = ((CollectionMeasurement) factory
334: .createMethodMetrics(
335: "testpackage.TestClass.testMethod(java.lang.String)")
336: .getMeasurement(
337: Metrics.OUTBOUND_EXTRA_PACKAGE_FEATURE_DEPENDENCIES))
338: .getValues();
339: assertEquals(
340: Metrics.OUTBOUND_EXTRA_PACKAGE_FEATURE_DEPENDENCIES
341: + " " + dependencies, 0, dependencies.size());
342:
343: dependencies = ((CollectionMeasurement) factory
344: .createMethodMetrics(
345: "testpackage.TestClass.testMethod(java.lang.String)")
346: .getMeasurement(
347: Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES))
348: .getValues();
349: assertEquals(Metrics.OUTBOUND_EXTRA_PACKAGE_CLASS_DEPENDENCIES
350: + " " + dependencies, 0, dependencies.size());
351: }
352:
353: public void testpackage_TestClass_IntraPackageClass() {
354: Collection scopeIncludes = new HashSet();
355: scopeIncludes.add("testpackage.SourceClass");
356:
357: gatherer.setScopeIncludes(scopeIncludes);
358: gatherer.visitClassfiles(loader.getAllClassfiles());
359:
360: Collection dependencies;
361:
362: dependencies = ((CollectionMeasurement) factory
363: .createClassMetrics("testpackage.TestClass")
364: .getMeasurement(
365: Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES))
366: .getValues();
367: assertTrue(Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
368: + dependencies + " missing testpackage.SourceClass",
369: dependencies.contains("testpackage.SourceClass"));
370: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
371: + dependencies, 1, dependencies.size());
372:
373: dependencies = ((CollectionMeasurement) factory
374: .createClassMetrics("testpackage.TestClass")
375: .getMeasurement(
376: Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES))
377: .getValues();
378: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
379: + dependencies, 0, dependencies.size());
380:
381: dependencies = ((CollectionMeasurement) factory
382: .createClassMetrics("testpackage.TestClass")
383: .getMeasurement(
384: Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES))
385: .getValues();
386: assertEquals(Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
387: + dependencies, 0, dependencies.size());
388:
389: dependencies = ((CollectionMeasurement) factory
390: .createClassMetrics("testpackage.TestClass")
391: .getMeasurement(
392: Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES))
393: .getValues();
394: assertEquals(Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
395: + dependencies, 0, dependencies.size());
396:
397: dependencies = ((CollectionMeasurement) factory
398: .createClassMetrics("testpackage.TestClass")
399: .getMeasurement(
400: Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES))
401: .getValues();
402: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
403: + " " + dependencies, 0, dependencies.size());
404:
405: dependencies = ((CollectionMeasurement) factory
406: .createClassMetrics("testpackage.TestClass")
407: .getMeasurement(
408: Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES))
409: .getValues();
410: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
411: + " " + dependencies, 0, dependencies.size());
412: }
413:
414: public void testpackage_TestClass_ExtraPackageClass() {
415: Collection scopeIncludes = new HashSet();
416: scopeIncludes.add("otherpackage.SourceClass");
417:
418: gatherer.setScopeIncludes(scopeIncludes);
419: gatherer.visitClassfiles(loader.getAllClassfiles());
420:
421: Collection dependencies;
422:
423: dependencies = ((CollectionMeasurement) factory
424: .createClassMetrics("testpackage.TestClass")
425: .getMeasurement(
426: Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES))
427: .getValues();
428: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
429: + dependencies, 0, dependencies.size());
430:
431: dependencies = ((CollectionMeasurement) factory
432: .createClassMetrics("testpackage.TestClass")
433: .getMeasurement(
434: Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES))
435: .getValues();
436: assertTrue(Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
437: + dependencies + " missing otherpackage.SourceClass",
438: dependencies.contains("otherpackage.SourceClass"));
439: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
440: + dependencies, 1, dependencies.size());
441:
442: dependencies = ((CollectionMeasurement) factory
443: .createClassMetrics("testpackage.TestClass")
444: .getMeasurement(
445: Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES))
446: .getValues();
447: assertEquals(Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
448: + dependencies, 0, dependencies.size());
449:
450: dependencies = ((CollectionMeasurement) factory
451: .createClassMetrics("testpackage.TestClass")
452: .getMeasurement(
453: Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES))
454: .getValues();
455: assertEquals(Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
456: + dependencies, 0, dependencies.size());
457:
458: dependencies = ((CollectionMeasurement) factory
459: .createClassMetrics("testpackage.TestClass")
460: .getMeasurement(
461: Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES))
462: .getValues();
463: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
464: + " " + dependencies, 0, dependencies.size());
465:
466: dependencies = ((CollectionMeasurement) factory
467: .createClassMetrics("testpackage.TestClass")
468: .getMeasurement(
469: Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES))
470: .getValues();
471: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
472: + " " + dependencies, 0, dependencies.size());
473: }
474:
475: public void testpackage_TestClass_IntraPackageMethod() {
476: Collection scopeIncludes = new HashSet();
477: scopeIncludes.add("testpackage.SourceClass.sourceMethod()");
478:
479: gatherer.setScopeIncludes(scopeIncludes);
480: gatherer.visitClassfiles(loader.getAllClassfiles());
481:
482: Collection dependencies;
483:
484: dependencies = ((CollectionMeasurement) factory
485: .createClassMetrics("testpackage.TestClass")
486: .getMeasurement(
487: Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES))
488: .getValues();
489: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
490: + dependencies, 0, dependencies.size());
491:
492: dependencies = ((CollectionMeasurement) factory
493: .createClassMetrics("testpackage.TestClass")
494: .getMeasurement(
495: Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES))
496: .getValues();
497: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
498: + dependencies, 0, dependencies.size());
499:
500: dependencies = ((CollectionMeasurement) factory
501: .createClassMetrics("testpackage.TestClass")
502: .getMeasurement(
503: Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES))
504: .getValues();
505: assertEquals(Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
506: + dependencies, 0, dependencies.size());
507:
508: dependencies = ((CollectionMeasurement) factory
509: .createClassMetrics("testpackage.TestClass")
510: .getMeasurement(
511: Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES))
512: .getValues();
513: assertEquals(Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
514: + dependencies, 0, dependencies.size());
515:
516: dependencies = ((CollectionMeasurement) factory
517: .createClassMetrics("testpackage.TestClass")
518: .getMeasurement(
519: Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES))
520: .getValues();
521: assertTrue(
522: Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
523: + " "
524: + dependencies
525: + " missing testpackage.SourceClass.sourceMethod()",
526: dependencies
527: .contains("testpackage.SourceClass.sourceMethod()"));
528: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
529: + " " + dependencies, 1, dependencies.size());
530:
531: dependencies = ((CollectionMeasurement) factory
532: .createClassMetrics("testpackage.TestClass")
533: .getMeasurement(
534: Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES))
535: .getValues();
536: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
537: + " " + dependencies, 0, dependencies.size());
538: }
539:
540: public void testpackage_TestClass_ExtraPackageMethod() {
541: Collection scopeIncludes = new HashSet();
542: scopeIncludes.add("otherpackage.SourceClass.sourceMethod()");
543:
544: gatherer.setScopeIncludes(scopeIncludes);
545: gatherer.visitClassfiles(loader.getAllClassfiles());
546:
547: Collection dependencies;
548:
549: dependencies = ((CollectionMeasurement) factory
550: .createClassMetrics("testpackage.TestClass")
551: .getMeasurement(
552: Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES))
553: .getValues();
554: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
555: + dependencies, 0, dependencies.size());
556:
557: dependencies = ((CollectionMeasurement) factory
558: .createClassMetrics("testpackage.TestClass")
559: .getMeasurement(
560: Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES))
561: .getValues();
562: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
563: + dependencies, 0, dependencies.size());
564:
565: dependencies = ((CollectionMeasurement) factory
566: .createClassMetrics("testpackage.TestClass")
567: .getMeasurement(
568: Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES))
569: .getValues();
570: assertEquals(Metrics.OUTBOUND_INTRA_PACKAGE_DEPENDENCIES + " "
571: + dependencies, 0, dependencies.size());
572:
573: dependencies = ((CollectionMeasurement) factory
574: .createClassMetrics("testpackage.TestClass")
575: .getMeasurement(
576: Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES))
577: .getValues();
578: assertEquals(Metrics.OUTBOUND_EXTRA_PACKAGE_DEPENDENCIES + " "
579: + dependencies, 0, dependencies.size());
580:
581: dependencies = ((CollectionMeasurement) factory
582: .createClassMetrics("testpackage.TestClass")
583: .getMeasurement(
584: Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES))
585: .getValues();
586: assertEquals(Metrics.INBOUND_INTRA_PACKAGE_METHOD_DEPENDENCIES
587: + " " + dependencies, 0, dependencies.size());
588:
589: dependencies = ((CollectionMeasurement) factory
590: .createClassMetrics("testpackage.TestClass")
591: .getMeasurement(
592: Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES))
593: .getValues();
594: assertTrue(
595: Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
596: + " "
597: + dependencies
598: + " missing otherpackage.SourceClass.sourceMethod()",
599: dependencies
600: .contains("otherpackage.SourceClass.sourceMethod()"));
601: assertEquals(Metrics.INBOUND_EXTRA_PACKAGE_METHOD_DEPENDENCIES
602: + " " + dependencies, 1, dependencies.size());
603: }
604: }
|