1 10 package org.picocontainer.gems.monitors; 11 12 import junit.framework.TestCase; 13 import org.picocontainer.testmodel.DependsOnList; 14 import org.picocontainer.testmodel.DependsOnDependsOnListAndVector; 15 16 import java.util.ArrayList ; 17 import java.util.Collection ; 18 import java.util.List ; 19 import java.util.Vector ; 20 21 public class DotDependencyGraphComponentMonitorTestCase extends TestCase { 22 23 DotDependencyGraphComponentMonitor monitor; 24 25 protected void setUp() throws Exception { 26 monitor = new DotDependencyGraphComponentMonitor(); 27 28 Vector vec = new Vector(); 29 List list = new ArrayList (); 30 DependsOnList dol = new DependsOnList(list); 31 DependsOnDependsOnListAndVector dodolav = new DependsOnDependsOnListAndVector(vec, dol); 32 33 monitor.instantiated(Vector.class.getConstructor(new Class [0]), vec, new Object []{}, 8); 34 monitor.instantiated(ArrayList .class.getConstructor(new Class []{Collection .class}), list, new Object []{vec}, 12); 35 monitor.instantiated(DependsOnList.class.getConstructors()[0], dol, new Object []{list}, 10); 36 monitor.instantiated(DependsOnDependsOnListAndVector.class.getConstructors()[0], dodolav, new Object []{vec, dol}, 16); 37 monitor.instantiated(DependsOnDependsOnListAndVector.class.getConstructors()[0], dodolav, new Object []{vec, dol}, 12); 38 monitor.instantiated(DependsOnDependsOnListAndVector.class.getConstructors()[0], dodolav, new Object []{vec, dol}, 9); 39 } 40 41 public void testSimpleClassDependencyGraphCanEliminateDupes() throws NoSuchMethodException { 42 String expected = ("" + 43 " 'java.util.ArrayList' -> 'java.util.Vector';\n" + 44 " 'org.picocontainer.testmodel.DependsOnDependsOnListAndVector' -> 'java.util.Vector';\n" + 45 " 'org.picocontainer.testmodel.DependsOnDependsOnListAndVector' -> 'org.picocontainer.testmodel.DependsOnList';\n" + 46 " 'org.picocontainer.testmodel.DependsOnList' -> 'java.util.ArrayList';\n" + 47 "").replaceAll("'","\""); 48 assertEquals(expected, monitor.getClassDependencyGraph()); 49 } 50 51 public void testSimpleInterfaceDependencyGraphCanEliminateDupes() throws NoSuchMethodException { 52 String expected = ("" + 53 " 'java.util.ArrayList' -> 'java.util.Collection' [style=dotted,label='needs'];\n" + 54 " 'java.util.ArrayList' -> 'java.util.List' [style=dotted, color=red,label='isA'];\n" + 55 " 'java.util.ArrayList' [label='ArrayList\\njava.util'];\n" + 56 " 'java.util.Collection' [shape=box, label='Collection\\njava.util'];\n" + 57 " 'java.util.List' [shape=box, label='List\\njava.util'];\n" + 58 " 'java.util.Vector' -> 'java.util.Collection' [style=dotted, color=red,label='isA'];\n" + 59 " 'org.picocontainer.testmodel.DependsOnDependsOnListAndVector' -> 'java.util.Vector' [label='needs'];\n" + 60 " 'org.picocontainer.testmodel.DependsOnDependsOnListAndVector' -> 'org.picocontainer.testmodel.DependsOnList' [label='needs'];\n" + 61 " 'org.picocontainer.testmodel.DependsOnDependsOnListAndVector' [label='DependsOnDependsOnListAndVector\\norg.picocontainer.testmodel'];\n" + 62 " 'org.picocontainer.testmodel.DependsOnList' -> 'java.util.List' [style=dotted,label='needs'];\n" + 63 " 'org.picocontainer.testmodel.DependsOnList' [label='DependsOnList\\norg.picocontainer.testmodel'];\n" + 64 "").replaceAll("'","\""); 65 String interfaceDependencyGraph = monitor.getInterfaceDependencyGraph(); 66 assertEquals(expected, interfaceDependencyGraph); 67 } 68 69 70 } 71 | Popular Tags |