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.dependency;
034:
035: import junit.framework.*;
036: import org.apache.log4j.*;
037:
038: public class TestGraphSummarizer extends TestCase {
039: private RegularExpressionSelectionCriteria scopeCriteria;
040: private RegularExpressionSelectionCriteria filterCriteria;
041: private NodeFactory factory;
042:
043: private Node a_package;
044: private Node a_A_class;
045: private Node a_A_a_method;
046: private Node a_B_class;
047:
048: private Node b_package;
049: private Node b_B_class;
050: private Node b_B_b_method;
051:
052: private GraphSummarizer summarizer;
053:
054: protected void setUp() throws Exception {
055: Logger.getLogger(getClass())
056: .info("Starting test: " + getName());
057:
058: scopeCriteria = new RegularExpressionSelectionCriteria("//");
059: filterCriteria = new RegularExpressionSelectionCriteria("//");
060: factory = new NodeFactory();
061:
062: a_package = factory.createPackage("a");
063: a_A_class = factory.createClass("a.A");
064: a_A_a_method = factory.createFeature("a.A.a");
065: a_B_class = factory.createClass("a.B");
066:
067: b_package = factory.createPackage("b");
068: b_B_class = factory.createClass("b.B");
069: b_B_b_method = factory.createFeature("b.B.b");
070:
071: summarizer = new GraphSummarizer(scopeCriteria, filterCriteria);
072: }
073:
074: protected void tearDown() throws Exception {
075: Logger.getLogger(getClass()).info("End of " + getName());
076: }
077:
078: public void testP2PasP2P() {
079: a_package.addDependency(b_package);
080:
081: scopeCriteria.setMatchingClasses(false);
082: scopeCriteria.setMatchingFeatures(false);
083: filterCriteria.setMatchingClasses(false);
084: filterCriteria.setMatchingFeatures(false);
085:
086: summarizer.traverseNodes(factory.getPackages().values());
087:
088: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
089: .toString(), summarizer.getScopeFactory().getPackages()
090: .keySet().contains("a"));
091: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
092: .toString(), summarizer.getScopeFactory().getPackages()
093: .keySet().contains("b"));
094: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
095: .toString(), summarizer.getScopeFactory().getClasses()
096: .keySet().isEmpty());
097: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
098: .toString(), summarizer.getScopeFactory().getFeatures()
099: .keySet().isEmpty());
100:
101: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
102: .getInboundDependencies().size());
103: assertEquals(1, summarizer.getScopeFactory().createPackage("a")
104: .getOutboundDependencies().size());
105: assertTrue(summarizer
106: .getScopeFactory()
107: .createPackage("a")
108: .getOutboundDependencies()
109: .contains(
110: summarizer.getScopeFactory().createPackage("b")));
111: assertEquals(1, summarizer.getScopeFactory().createPackage("b")
112: .getInboundDependencies().size());
113: assertTrue(summarizer
114: .getScopeFactory()
115: .createPackage("b")
116: .getInboundDependencies()
117: .contains(
118: summarizer.getScopeFactory().createPackage("a")));
119: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
120: .getOutboundDependencies().size());
121: }
122:
123: public void testP2PasC2C() {
124: a_package.addDependency(b_package);
125:
126: scopeCriteria.setMatchingPackages(false);
127: scopeCriteria.setMatchingFeatures(false);
128: filterCriteria.setMatchingPackages(false);
129: filterCriteria.setMatchingFeatures(false);
130:
131: summarizer.traverseNodes(factory.getPackages().values());
132:
133: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
134: .toString(), summarizer.getScopeFactory().getPackages()
135: .keySet().contains("a"));
136: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
137: .toString(), summarizer.getScopeFactory().getPackages()
138: .keySet().contains("b"));
139: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
140: .toString(), summarizer.getScopeFactory().getClasses()
141: .keySet().contains("a.A"));
142: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
143: .toString(), summarizer.getScopeFactory().getClasses()
144: .keySet().contains("b.B"));
145: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
146: .toString(), summarizer.getScopeFactory().getFeatures()
147: .keySet().isEmpty());
148:
149: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
150: .getInboundDependencies().size());
151: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
152: .getOutboundDependencies().size());
153: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
154: .getInboundDependencies().size());
155: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
156: .getOutboundDependencies().size());
157:
158: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
159: .getInboundDependencies().size());
160: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
161: .getOutboundDependencies().size());
162: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
163: .getInboundDependencies().size());
164: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
165: .getOutboundDependencies().size());
166: }
167:
168: public void testP2PasF2F() {
169: a_package.addDependency(b_package);
170:
171: scopeCriteria.setMatchingPackages(false);
172: scopeCriteria.setMatchingClasses(false);
173: filterCriteria.setMatchingPackages(false);
174: filterCriteria.setMatchingClasses(false);
175:
176: summarizer.traverseNodes(factory.getPackages().values());
177:
178: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
179: .toString(), summarizer.getScopeFactory().getPackages()
180: .keySet().contains("a"));
181: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
182: .toString(), summarizer.getScopeFactory().getPackages()
183: .keySet().contains("b"));
184: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
185: .toString(), summarizer.getScopeFactory().getClasses()
186: .keySet().contains("a.A"));
187: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
188: .toString(), summarizer.getScopeFactory().getClasses()
189: .keySet().contains("b.B"));
190: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
191: .toString(), summarizer.getScopeFactory().getFeatures()
192: .keySet().contains("a.A.a"));
193: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
194: .toString(), summarizer.getScopeFactory().getFeatures()
195: .keySet().contains("b.B.b"));
196:
197: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
198: .getInboundDependencies().size());
199: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
200: .getOutboundDependencies().size());
201: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
202: .getInboundDependencies().size());
203: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
204: .getOutboundDependencies().size());
205:
206: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
207: .getInboundDependencies().size());
208: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
209: .getOutboundDependencies().size());
210: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
211: .getInboundDependencies().size());
212: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
213: .getOutboundDependencies().size());
214:
215: assertEquals(0, summarizer.getScopeFactory().createFeature(
216: "a.A.a").getInboundDependencies().size());
217: assertEquals(0, summarizer.getScopeFactory().createFeature(
218: "a.A.a").getOutboundDependencies().size());
219: assertEquals(0, summarizer.getScopeFactory().createFeature(
220: "b.B.b").getInboundDependencies().size());
221: assertEquals(0, summarizer.getScopeFactory().createFeature(
222: "b.B.b").getOutboundDependencies().size());
223: }
224:
225: public void testC2CasP2P() {
226: a_A_class.addDependency(b_B_class);
227:
228: scopeCriteria.setMatchingClasses(false);
229: scopeCriteria.setMatchingFeatures(false);
230: filterCriteria.setMatchingClasses(false);
231: filterCriteria.setMatchingFeatures(false);
232:
233: summarizer.traverseNodes(factory.getPackages().values());
234:
235: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
236: .toString(), summarizer.getScopeFactory().getPackages()
237: .keySet().contains("a"));
238: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
239: .toString(), summarizer.getScopeFactory().getPackages()
240: .keySet().contains("b"));
241: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
242: .toString(), summarizer.getScopeFactory().getClasses()
243: .isEmpty());
244: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
245: .toString(), summarizer.getScopeFactory().getFeatures()
246: .isEmpty());
247:
248: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
249: .getInboundDependencies().size());
250: assertEquals(1, summarizer.getScopeFactory().createPackage("a")
251: .getOutboundDependencies().size());
252: assertTrue(summarizer
253: .getScopeFactory()
254: .createPackage("a")
255: .getOutboundDependencies()
256: .contains(
257: summarizer.getScopeFactory().createPackage("b")));
258: assertEquals(1, summarizer.getScopeFactory().createPackage("b")
259: .getInboundDependencies().size());
260: assertTrue(summarizer
261: .getScopeFactory()
262: .createPackage("b")
263: .getInboundDependencies()
264: .contains(
265: summarizer.getScopeFactory().createPackage("a")));
266: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
267: .getOutboundDependencies().size());
268: }
269:
270: public void testC2CasP2CSamePackage() {
271: a_A_class.addDependency(a_B_class);
272:
273: scopeCriteria.setMatchingClasses(false);
274: scopeCriteria.setMatchingFeatures(false);
275: filterCriteria.setMatchingPackages(false);
276: filterCriteria.setMatchingFeatures(false);
277:
278: summarizer.traverseNodes(factory.getPackages().values());
279:
280: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
281: .toString(), summarizer.getScopeFactory().getPackages()
282: .keySet().contains("a"));
283: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
284: .toString(), summarizer.getScopeFactory().getPackages()
285: .keySet().contains("b"));
286: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
287: .toString(), summarizer.getScopeFactory().getClasses()
288: .isEmpty());
289: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
290: .toString(), summarizer.getScopeFactory().getFeatures()
291: .isEmpty());
292:
293: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
294: .getInboundDependencies().size());
295: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
296: .getOutboundDependencies().size());
297: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
298: .getInboundDependencies().size());
299: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
300: .getOutboundDependencies().size());
301: }
302:
303: public void testC2CasC2C() {
304: a_A_class.addDependency(b_B_class);
305:
306: scopeCriteria.setMatchingPackages(false);
307: scopeCriteria.setMatchingFeatures(false);
308: filterCriteria.setMatchingPackages(false);
309: filterCriteria.setMatchingFeatures(false);
310:
311: summarizer.traverseNodes(factory.getPackages().values());
312:
313: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
314: .toString(), summarizer.getScopeFactory().getPackages()
315: .keySet().contains("a"));
316: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
317: .toString(), summarizer.getScopeFactory().getPackages()
318: .keySet().contains("b"));
319: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
320: .toString(), summarizer.getScopeFactory().getClasses()
321: .keySet().contains("a.A"));
322: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
323: .toString(), summarizer.getScopeFactory().getClasses()
324: .keySet().contains("b.B"));
325: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
326: .toString(), summarizer.getScopeFactory().getFeatures()
327: .isEmpty());
328:
329: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
330: .getInboundDependencies().size());
331: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
332: .getOutboundDependencies().size());
333: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
334: .getInboundDependencies().size());
335: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
336: .getOutboundDependencies().size());
337:
338: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
339: .getInboundDependencies().size());
340: assertEquals(1, summarizer.getScopeFactory().createClass("a.A")
341: .getOutboundDependencies().size());
342: assertTrue(summarizer
343: .getScopeFactory()
344: .createClass("a.A")
345: .getOutboundDependencies()
346: .contains(
347: summarizer.getScopeFactory().createClass("b.B")));
348: assertEquals(1, summarizer.getScopeFactory().createClass("b.B")
349: .getInboundDependencies().size());
350: assertTrue(summarizer
351: .getScopeFactory()
352: .createClass("b.B")
353: .getInboundDependencies()
354: .contains(
355: summarizer.getScopeFactory().createClass("a.A")));
356: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
357: .getOutboundDependencies().size());
358: }
359:
360: public void testC2CasF2F() {
361: a_A_class.addDependency(b_B_class);
362:
363: scopeCriteria.setMatchingPackages(false);
364: scopeCriteria.setMatchingClasses(false);
365: filterCriteria.setMatchingPackages(false);
366: filterCriteria.setMatchingClasses(false);
367:
368: summarizer.traverseNodes(factory.getPackages().values());
369:
370: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
371: .toString(), summarizer.getScopeFactory().getPackages()
372: .keySet().contains("a"));
373: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
374: .toString(), summarizer.getScopeFactory().getPackages()
375: .keySet().contains("b"));
376: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
377: .toString(), summarizer.getScopeFactory().getClasses()
378: .keySet().contains("a.A"));
379: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
380: .toString(), summarizer.getScopeFactory().getClasses()
381: .keySet().contains("b.B"));
382: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
383: .toString(), summarizer.getScopeFactory().getFeatures()
384: .keySet().contains("a.A.a"));
385: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
386: .toString(), summarizer.getScopeFactory().getFeatures()
387: .keySet().contains("b.B.b"));
388:
389: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
390: .getInboundDependencies().size());
391: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
392: .getOutboundDependencies().size());
393: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
394: .getInboundDependencies().size());
395: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
396: .getOutboundDependencies().size());
397:
398: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
399: .getInboundDependencies().size());
400: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
401: .getOutboundDependencies().size());
402: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
403: .getInboundDependencies().size());
404: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
405: .getOutboundDependencies().size());
406:
407: assertEquals(0, summarizer.getScopeFactory().createFeature(
408: "a.A.a").getInboundDependencies().size());
409: assertEquals(0, summarizer.getScopeFactory().createFeature(
410: "a.A.a").getOutboundDependencies().size());
411: assertEquals(0, summarizer.getScopeFactory().createFeature(
412: "b.B.b").getInboundDependencies().size());
413: assertEquals(0, summarizer.getScopeFactory().createFeature(
414: "b.B.b").getOutboundDependencies().size());
415: }
416:
417: public void testF2FasP2P() {
418: a_A_a_method.addDependency(b_B_b_method);
419:
420: scopeCriteria.setMatchingClasses(false);
421: scopeCriteria.setMatchingFeatures(false);
422: filterCriteria.setMatchingClasses(false);
423: filterCriteria.setMatchingFeatures(false);
424:
425: summarizer.traverseNodes(factory.getPackages().values());
426:
427: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
428: .toString(), summarizer.getScopeFactory().getPackages()
429: .keySet().contains("a"));
430: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
431: .toString(), summarizer.getScopeFactory().getPackages()
432: .keySet().contains("b"));
433: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
434: .toString(), summarizer.getScopeFactory().getClasses()
435: .isEmpty());
436: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
437: .toString(), summarizer.getScopeFactory().getFeatures()
438: .isEmpty());
439:
440: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
441: .getInboundDependencies().size());
442: assertEquals(1, summarizer.getScopeFactory().createPackage("a")
443: .getOutboundDependencies().size());
444: assertTrue(summarizer
445: .getScopeFactory()
446: .createPackage("a")
447: .getOutboundDependencies()
448: .contains(
449: summarizer.getScopeFactory().createPackage("b")));
450: assertEquals(1, summarizer.getScopeFactory().createPackage("b")
451: .getInboundDependencies().size());
452: assertTrue(summarizer
453: .getScopeFactory()
454: .createPackage("b")
455: .getInboundDependencies()
456: .contains(
457: summarizer.getScopeFactory().createPackage("a")));
458: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
459: .getOutboundDependencies().size());
460: }
461:
462: public void testF2FasC2C() {
463: a_A_a_method.addDependency(b_B_b_method);
464:
465: scopeCriteria.setMatchingPackages(false);
466: scopeCriteria.setMatchingFeatures(false);
467: filterCriteria.setMatchingPackages(false);
468: filterCriteria.setMatchingFeatures(false);
469:
470: summarizer.traverseNodes(factory.getPackages().values());
471:
472: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
473: .toString(), summarizer.getScopeFactory().getPackages()
474: .keySet().contains("a"));
475: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
476: .toString(), summarizer.getScopeFactory().getPackages()
477: .keySet().contains("b"));
478: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
479: .toString(), summarizer.getScopeFactory().getClasses()
480: .keySet().contains("a.A"));
481: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
482: .toString(), summarizer.getScopeFactory().getClasses()
483: .keySet().contains("b.B"));
484: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
485: .toString(), summarizer.getScopeFactory().getFeatures()
486: .isEmpty());
487:
488: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
489: .getInboundDependencies().size());
490: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
491: .getOutboundDependencies().size());
492: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
493: .getInboundDependencies().size());
494: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
495: .getOutboundDependencies().size());
496:
497: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
498: .getInboundDependencies().size());
499: assertEquals(1, summarizer.getScopeFactory().createClass("a.A")
500: .getOutboundDependencies().size());
501: assertTrue(summarizer
502: .getScopeFactory()
503: .createClass("a.A")
504: .getOutboundDependencies()
505: .contains(
506: summarizer.getScopeFactory().createClass("b.B")));
507: assertEquals(1, summarizer.getScopeFactory().createClass("b.B")
508: .getInboundDependencies().size());
509: assertTrue(summarizer
510: .getScopeFactory()
511: .createClass("b.B")
512: .getInboundDependencies()
513: .contains(
514: summarizer.getScopeFactory().createClass("a.A")));
515: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
516: .getOutboundDependencies().size());
517: }
518:
519: public void testF2FasF2F() {
520: a_A_a_method.addDependency(b_B_b_method);
521:
522: scopeCriteria.setMatchingPackages(false);
523: scopeCriteria.setMatchingClasses(false);
524: filterCriteria.setMatchingPackages(false);
525: filterCriteria.setMatchingClasses(false);
526:
527: summarizer.traverseNodes(factory.getPackages().values());
528:
529: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
530: .toString(), summarizer.getScopeFactory().getPackages()
531: .keySet().contains("a"));
532: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
533: .toString(), summarizer.getScopeFactory().getPackages()
534: .keySet().contains("b"));
535: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
536: .toString(), summarizer.getScopeFactory().getClasses()
537: .keySet().contains("a.A"));
538: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
539: .toString(), summarizer.getScopeFactory().getClasses()
540: .keySet().contains("b.B"));
541: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
542: .toString(), summarizer.getScopeFactory().getFeatures()
543: .keySet().contains("a.A.a"));
544: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
545: .toString(), summarizer.getScopeFactory().getFeatures()
546: .keySet().contains("b.B.b"));
547:
548: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
549: .getInboundDependencies().size());
550: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
551: .getOutboundDependencies().size());
552: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
553: .getInboundDependencies().size());
554: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
555: .getOutboundDependencies().size());
556:
557: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
558: .getInboundDependencies().size());
559: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
560: .getOutboundDependencies().size());
561: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
562: .getInboundDependencies().size());
563: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
564: .getOutboundDependencies().size());
565:
566: assertEquals(0, summarizer.getScopeFactory().createFeature(
567: "a.A.a").getInboundDependencies().size());
568: assertEquals(1, summarizer.getScopeFactory().createFeature(
569: "a.A.a").getOutboundDependencies().size());
570: assertTrue(summarizer.getScopeFactory().createFeature("a.A.a")
571: .getOutboundDependencies().contains(
572: summarizer.getScopeFactory().createFeature(
573: "b.B.b")));
574: assertEquals(1, summarizer.getScopeFactory().createFeature(
575: "b.B.b").getInboundDependencies().size());
576: assertTrue(summarizer.getScopeFactory().createFeature("b.B.b")
577: .getInboundDependencies().contains(
578: summarizer.getScopeFactory().createFeature(
579: "a.A.a")));
580: assertEquals(0, summarizer.getScopeFactory().createFeature(
581: "b.B.b").getOutboundDependencies().size());
582: }
583:
584: public void testF2CasP2P() {
585: a_A_a_method.addDependency(b_B_class);
586:
587: scopeCriteria.setMatchingClasses(false);
588: scopeCriteria.setMatchingFeatures(false);
589: filterCriteria.setMatchingClasses(false);
590: filterCriteria.setMatchingFeatures(false);
591:
592: summarizer.traverseNodes(factory.getPackages().values());
593:
594: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
595: .toString(), summarizer.getScopeFactory().getPackages()
596: .keySet().contains("a"));
597: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
598: .toString(), summarizer.getScopeFactory().getPackages()
599: .keySet().contains("b"));
600: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
601: .toString(), summarizer.getScopeFactory().getClasses()
602: .isEmpty());
603: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
604: .toString(), summarizer.getScopeFactory().getFeatures()
605: .isEmpty());
606:
607: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
608: .getInboundDependencies().size());
609: assertEquals(1, summarizer.getScopeFactory().createPackage("a")
610: .getOutboundDependencies().size());
611: assertTrue(summarizer
612: .getScopeFactory()
613: .createPackage("a")
614: .getOutboundDependencies()
615: .contains(
616: summarizer.getScopeFactory().createPackage("b")));
617: assertEquals(1, summarizer.getScopeFactory().createPackage("b")
618: .getInboundDependencies().size());
619: assertTrue(summarizer
620: .getScopeFactory()
621: .createPackage("b")
622: .getInboundDependencies()
623: .contains(
624: summarizer.getScopeFactory().createPackage("a")));
625: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
626: .getOutboundDependencies().size());
627: }
628:
629: public void testF2CasC2C() {
630: a_A_a_method.addDependency(b_B_class);
631:
632: scopeCriteria.setMatchingPackages(false);
633: scopeCriteria.setMatchingFeatures(false);
634: filterCriteria.setMatchingPackages(false);
635: filterCriteria.setMatchingFeatures(false);
636:
637: summarizer.traverseNodes(factory.getPackages().values());
638:
639: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
640: .toString(), summarizer.getScopeFactory().getPackages()
641: .keySet().contains("a"));
642: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
643: .toString(), summarizer.getScopeFactory().getPackages()
644: .keySet().contains("b"));
645: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
646: .toString(), summarizer.getScopeFactory().getClasses()
647: .keySet().contains("a.A"));
648: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
649: .toString(), summarizer.getScopeFactory().getClasses()
650: .keySet().contains("b.B"));
651: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
652: .toString(), summarizer.getScopeFactory().getFeatures()
653: .isEmpty());
654:
655: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
656: .getInboundDependencies().size());
657: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
658: .getOutboundDependencies().size());
659: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
660: .getInboundDependencies().size());
661: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
662: .getOutboundDependencies().size());
663:
664: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
665: .getInboundDependencies().size());
666: assertEquals(1, summarizer.getScopeFactory().createClass("a.A")
667: .getOutboundDependencies().size());
668: assertTrue(summarizer
669: .getScopeFactory()
670: .createClass("a.A")
671: .getOutboundDependencies()
672: .contains(
673: summarizer.getScopeFactory().createClass("b.B")));
674: assertEquals(1, summarizer.getScopeFactory().createClass("b.B")
675: .getInboundDependencies().size());
676: assertTrue(summarizer
677: .getScopeFactory()
678: .createClass("b.B")
679: .getInboundDependencies()
680: .contains(
681: summarizer.getScopeFactory().createClass("a.A")));
682: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
683: .getOutboundDependencies().size());
684: }
685:
686: public void testF2CasF2F() {
687: a_A_a_method.addDependency(b_B_class);
688:
689: scopeCriteria.setMatchingPackages(false);
690: scopeCriteria.setMatchingClasses(false);
691: filterCriteria.setMatchingPackages(false);
692: filterCriteria.setMatchingClasses(false);
693:
694: summarizer.traverseNodes(factory.getPackages().values());
695:
696: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
697: .toString(), summarizer.getScopeFactory().getPackages()
698: .keySet().contains("a"));
699: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
700: .toString(), summarizer.getScopeFactory().getPackages()
701: .keySet().contains("b"));
702: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
703: .toString(), summarizer.getScopeFactory().getClasses()
704: .keySet().contains("a.A"));
705: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
706: .toString(), summarizer.getScopeFactory().getClasses()
707: .keySet().contains("b.B"));
708: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
709: .toString(), summarizer.getScopeFactory().getFeatures()
710: .keySet().contains("a.A.a"));
711: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
712: .toString(), summarizer.getScopeFactory().getFeatures()
713: .keySet().contains("b.B.b"));
714:
715: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
716: .getInboundDependencies().size());
717: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
718: .getOutboundDependencies().size());
719: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
720: .getInboundDependencies().size());
721: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
722: .getOutboundDependencies().size());
723:
724: assertEquals(0, summarizer.getScopeFactory().createClass("a")
725: .getInboundDependencies().size());
726: assertEquals(0, summarizer.getScopeFactory().createClass("a")
727: .getOutboundDependencies().size());
728: assertEquals(0, summarizer.getScopeFactory().createClass("b")
729: .getInboundDependencies().size());
730: assertEquals(0, summarizer.getScopeFactory().createClass("b")
731: .getOutboundDependencies().size());
732:
733: assertEquals(0, summarizer.getScopeFactory().createFeature("a")
734: .getInboundDependencies().size());
735: assertEquals(0, summarizer.getScopeFactory().createFeature("a")
736: .getOutboundDependencies().size());
737: assertEquals(0, summarizer.getScopeFactory().createFeature("b")
738: .getInboundDependencies().size());
739: assertEquals(0, summarizer.getScopeFactory().createFeature("b")
740: .getOutboundDependencies().size());
741: }
742:
743: public void testF2FasPCF2PCF() {
744: a_A_a_method.addDependency(b_B_b_method);
745:
746: summarizer.traverseNodes(factory.getPackages().values());
747:
748: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
749: .toString(), summarizer.getScopeFactory().getPackages()
750: .keySet().contains("a"));
751: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
752: .toString(), summarizer.getScopeFactory().getPackages()
753: .keySet().contains("b"));
754: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
755: .toString(), summarizer.getScopeFactory().getClasses()
756: .keySet().contains("a.A"));
757: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
758: .toString(), summarizer.getScopeFactory().getClasses()
759: .keySet().contains("b.B"));
760: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
761: .toString(), summarizer.getScopeFactory().getFeatures()
762: .keySet().contains("a.A.a"));
763: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
764: .toString(), summarizer.getScopeFactory().getFeatures()
765: .keySet().contains("b.B.b"));
766:
767: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
768: .getInboundDependencies().size());
769: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
770: .getOutboundDependencies().size());
771: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
772: .getInboundDependencies().size());
773: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
774: .getOutboundDependencies().size());
775:
776: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
777: .getInboundDependencies().size());
778: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
779: .getOutboundDependencies().size());
780: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
781: .getInboundDependencies().size());
782: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
783: .getOutboundDependencies().size());
784:
785: assertEquals(0, summarizer.getScopeFactory().createFeature(
786: "a.A.a").getInboundDependencies().size());
787: assertEquals(1, summarizer.getScopeFactory().createFeature(
788: "a.A.a").getOutboundDependencies().size());
789: assertTrue(summarizer.getScopeFactory().createFeature("a.A.a")
790: .getOutboundDependencies().contains(
791: summarizer.getScopeFactory().createFeature(
792: "b.B.b")));
793: assertEquals(1, summarizer.getScopeFactory().createFeature(
794: "b.B.b").getInboundDependencies().size());
795: assertTrue(summarizer.getScopeFactory().createFeature("b.B.b")
796: .getInboundDependencies().contains(
797: summarizer.getScopeFactory().createFeature(
798: "a.A.a")));
799: assertEquals(0, summarizer.getScopeFactory().createFeature(
800: "b.B.b").getOutboundDependencies().size());
801: }
802:
803: public void testC2CasPCF2PCF() {
804: a_A_class.addDependency(b_B_class);
805:
806: summarizer.traverseNodes(factory.getPackages().values());
807:
808: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
809: .toString(), summarizer.getScopeFactory().getPackages()
810: .keySet().contains("a"));
811: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
812: .toString(), summarizer.getScopeFactory().getPackages()
813: .keySet().contains("b"));
814: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
815: .toString(), summarizer.getScopeFactory().getClasses()
816: .keySet().contains("a.A"));
817: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
818: .toString(), summarizer.getScopeFactory().getClasses()
819: .keySet().contains("b.B"));
820: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
821: .toString(), summarizer.getScopeFactory().getFeatures()
822: .keySet().contains("a.A.a"));
823: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
824: .toString(), summarizer.getScopeFactory().getFeatures()
825: .keySet().contains("b.B.b"));
826:
827: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
828: .getInboundDependencies().size());
829: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
830: .getOutboundDependencies().size());
831: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
832: .getInboundDependencies().size());
833: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
834: .getOutboundDependencies().size());
835:
836: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
837: .getInboundDependencies().size());
838: assertEquals(1, summarizer.getScopeFactory().createClass("a.A")
839: .getOutboundDependencies().size());
840: assertTrue(summarizer
841: .getScopeFactory()
842: .createClass("a.A")
843: .getOutboundDependencies()
844: .contains(
845: summarizer.getScopeFactory().createClass("b.B")));
846: assertEquals(1, summarizer.getScopeFactory().createClass("b.B")
847: .getInboundDependencies().size());
848: assertTrue(summarizer
849: .getScopeFactory()
850: .createClass("b.B")
851: .getInboundDependencies()
852: .contains(
853: summarizer.getScopeFactory().createClass("a.A")));
854: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
855: .getOutboundDependencies().size());
856:
857: assertEquals(0, summarizer.getScopeFactory().createFeature(
858: "a.A.a").getInboundDependencies().size());
859: assertEquals(0, summarizer.getScopeFactory().createFeature(
860: "a.A.a").getOutboundDependencies().size());
861: assertEquals(0, summarizer.getScopeFactory().createFeature(
862: "b.B.b").getInboundDependencies().size());
863: assertEquals(0, summarizer.getScopeFactory().createFeature(
864: "b.B.b").getOutboundDependencies().size());
865: }
866:
867: public void testP2PasPCF2PCF() {
868: a_package.addDependency(b_package);
869:
870: summarizer.traverseNodes(factory.getPackages().values());
871:
872: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
873: .toString(), summarizer.getScopeFactory().getPackages()
874: .keySet().contains("a"));
875: assertTrue(summarizer.getScopeFactory().getPackages().keySet()
876: .toString(), summarizer.getScopeFactory().getPackages()
877: .keySet().contains("b"));
878: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
879: .toString(), summarizer.getScopeFactory().getClasses()
880: .keySet().contains("a.A"));
881: assertTrue(summarizer.getScopeFactory().getClasses().keySet()
882: .toString(), summarizer.getScopeFactory().getClasses()
883: .keySet().contains("b.B"));
884: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
885: .toString(), summarizer.getScopeFactory().getFeatures()
886: .keySet().contains("a.A.a"));
887: assertTrue(summarizer.getScopeFactory().getFeatures().keySet()
888: .toString(), summarizer.getScopeFactory().getFeatures()
889: .keySet().contains("b.B.b"));
890:
891: assertEquals(0, summarizer.getScopeFactory().createPackage("a")
892: .getInboundDependencies().size());
893: assertEquals(1, summarizer.getScopeFactory().createPackage("a")
894: .getOutboundDependencies().size());
895: assertTrue(summarizer
896: .getScopeFactory()
897: .createPackage("a")
898: .getOutboundDependencies()
899: .contains(
900: summarizer.getScopeFactory().createPackage("b")));
901: assertEquals(1, summarizer.getScopeFactory().createPackage("b")
902: .getInboundDependencies().size());
903: assertTrue(summarizer
904: .getScopeFactory()
905: .createPackage("b")
906: .getInboundDependencies()
907: .contains(
908: summarizer.getScopeFactory().createPackage("a")));
909: assertEquals(0, summarizer.getScopeFactory().createPackage("b")
910: .getOutboundDependencies().size());
911:
912: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
913: .getInboundDependencies().size());
914: assertEquals(0, summarizer.getScopeFactory().createClass("a.A")
915: .getOutboundDependencies().size());
916: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
917: .getInboundDependencies().size());
918: assertEquals(0, summarizer.getScopeFactory().createClass("b.B")
919: .getOutboundDependencies().size());
920:
921: assertEquals(0, summarizer.getScopeFactory().createFeature(
922: "a.A.a").getInboundDependencies().size());
923: assertEquals(0, summarizer.getScopeFactory().createFeature(
924: "a.A.a").getOutboundDependencies().size());
925: assertEquals(0, summarizer.getScopeFactory().createFeature(
926: "b.B.b").getInboundDependencies().size());
927: assertEquals(0, summarizer.getScopeFactory().createFeature(
928: "b.B.b").getOutboundDependencies().size());
929: }
930: }
|