1 29 package jegg.type; 30 31 import java.util.Collection ; 32 33 import jegg.impl.TestBase; 34 35 38 public class TypeTreeTest extends TestBase 39 { 40 static 41 { 42 setTestClass(TypeTreeTest.class); 43 } 44 45 private TypeTree tree; 46 private Node nodeA, nodeA1, nodeA2; 47 private Node nodeB, nodeB1, nodeB2; 48 private Node nodeC, nodeC1, nodeC2; 49 50 public TypeTreeTest(String n) 51 { 52 super(n); 53 } 54 55 public void setup() 56 { 57 tree = new TypeTree(); 58 nodeA = new Node(TypeA.class); 59 nodeA1 = new Node(TypeA1.class); 60 nodeA2 = new Node(TypeA2.class); 61 nodeB = new Node(TypeB.class); 62 nodeB1 = new Node(TypeB1.class); 63 nodeB2 = new Node(TypeB2.class); 64 nodeC = new Node(TypeC.class); 65 nodeC1 = new Node(TypeC1.class); 66 nodeC2 = new Node(TypeC2.class); 67 } 68 69 public void teardown() 70 { 71 } 73 74 public void test1() 75 { 76 tree.insert(TypeA.class, null); 77 78 tree.insert(TypeC.class,null); 79 tree.insert(TypeC1.class,null); 80 tree.insert(TypeC2.class,null); 81 82 tree.insert(TypeB1.class,null); 83 tree.insert(TypeB2.class,null); 84 tree.insert(TypeB.class,null); 85 86 tree.insert(TypeA1.class, null); 87 tree.insert(TypeA2.class, null); 88 89 Node root = tree.getRoot(); 90 assertNotNull(root); 91 92 Collection branches = root.getBranches(); 93 assertNotNull(branches); 94 assertEquals(1,branches.size()); 95 assertEquals(Object .class, root.getType()); 96 97 Node rc1 = (Node) root.getBranches().iterator().next(); 98 assertNotNull(rc1); 99 100 Collection rc1_branches = rc1.getBranches(); 101 assertNotNull(rc1_branches); 102 assertEquals(3,rc1_branches.size()); 103 assertEquals(TypeA.class, rc1.getType()); 104 105 assertEquals(TypeA1.class, tree.find(TypeA1.class).getType()); 106 assertEquals(TypeA2.class, tree.find(TypeA2.class).getType()); 107 assertEquals(TypeB.class, tree.find(TypeB.class).getType()); 108 assertEquals(TypeB1.class, tree.find(TypeB1.class).getType()); 109 assertEquals(TypeB2.class, tree.find(TypeB2.class).getType()); 110 assertEquals(TypeC.class, tree.find(TypeC.class).getType()); 111 assertEquals(TypeC1.class, tree.find(TypeC1.class).getType()); 112 assertEquals(TypeC2.class, tree.find(TypeC2.class).getType()); 113 } 114 } 115 | Popular Tags |