1 17 18 package org.apache.avalon.fortress.util.dag.test; 19 20 import java.util.List ; 21 22 import junit.framework.TestCase; 23 24 import org.apache.avalon.fortress.util.dag.CyclicDependencyException; 25 import org.apache.avalon.fortress.util.dag.Vertex; 26 27 33 public class VertexTestCase extends TestCase 34 { 35 public VertexTestCase( String name ) 36 { 37 super( name ); 38 } 39 40 public void testSortMethods() 41 { 42 Vertex v = new Vertex( "Root" ); 43 List deps = v.getDependencies(); 44 assertNotNull( deps ); 45 assertEquals( 0, deps.size() ); 46 assertEquals( "Root", v.getNode() ); 47 assertEquals( "Root", v.getName() ); 48 assertEquals( 0, v.getOrder() ); 49 50 Vertex w = new Vertex( "Child" ); 51 v.addDependency( w ); 52 deps = v.getDependencies(); 53 assertNotNull( deps ); 54 assertEquals( 1, deps.size() ); 55 56 v.reset(); 57 w.reset(); 58 59 try 60 { 61 v.resolveOrder(); 62 w.resolveOrder(); 63 } 64 catch ( CyclicDependencyException e ) 65 { 66 fail( "Unexpected cyclic exception: " + e ); 67 } 68 69 assertEquals( 1, v.getOrder() ); 70 assertEquals( 0, w.getOrder() ); 71 } 72 } 73 | Popular Tags |