KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > util > dag > test > VertexTestCase


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.avalon.fortress.util.dag.test;
19
20 import java.util.List JavaDoc;
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 /**
28  * VertexTest does XYZ
29  *
30  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
31  * @version CVS $ Revision: 1.1 $
32  */

33 public class VertexTestCase extends TestCase
34 {
35     public VertexTestCase( String JavaDoc name )
36     {
37         super( name );
38     }
39
40     public void testSortMethods()
41     {
42         Vertex v = new Vertex( "Root" );
43         List JavaDoc 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