1 package org.tigris.scarab.om; 2 3 48 49 import java.util.Iterator ; 50 import java.util.List ; 51 52 import org.apache.torque.om.NumberKey; 53 import org.tigris.scarab.test.BaseScarabTestCase; 54 55 61 public class AttributeOptionTest extends BaseScarabTestCase 62 { 63 private AttributeOption ao; 64 65 public void setUp() 66 throws Exception 67 { 68 super.setUp(); 69 ao = 70 AttributeOptionManager.getInstance(new NumberKey(83)); 71 72 73 } 74 75 public void testGetChildren() 76 throws Exception 77 { 78 System.out.println ( 79 "Testing: testGetChildren() with AttributeOption: " + ao.getName()); 80 List options = ao.getChildren(); 81 Iterator itr = options.iterator(); 82 while (itr.hasNext()) 83 { 84 AttributeOption val = ((AttributeOption)itr.next()); 85 System.out.println (val); 86 } 87 int size = options.size(); 88 assertEquals(size, 8); 89 assertEquals("BSDI", ((AttributeOption)ao.getChildren().get(0)).getName()); 90 assertEquals("AIX", ((AttributeOption)ao.getChildren().get(1)).getName()); 91 assertEquals("BeOS", ((AttributeOption)ao.getChildren().get(2)).getName()); 92 assertEquals("HPUX", ((AttributeOption)ao.getChildren().get(3)).getName()); 93 assertEquals("IRIX", ((AttributeOption)ao.getChildren().get(4)).getName()); 94 assertEquals("OSF1", ((AttributeOption)ao.getChildren().get(5)).getName()); 95 assertEquals("Solaris", ((AttributeOption)ao.getChildren().get(6)).getName()); 96 assertEquals("SunOS", ((AttributeOption)ao.getChildren().get(7)).getName()); 97 } 98 99 public void testGetParents() 100 throws Exception 101 { 102 System.out.println ( 103 "Testing: testGetParents() with AttributeOption: " + ao.getName()); 104 List options = ao.getParents(); 105 Iterator itr = options.iterator(); 106 while (itr.hasNext()) 107 { 108 AttributeOption val = ((AttributeOption)itr.next()); 109 System.out.println (val); 110 } 111 int size = options.size(); 112 assertEquals(size, 1); 113 assertEquals(((AttributeOption)ao.getParents().get(0)).getName(), "Unix"); 114 } 115 116 public void testIsChildOf() 117 throws Exception 118 { 119 System.out.println ( 120 "Testing: testIsChildOf() with AttributeOption: " + ao.getName()); 121 AttributeOption parent = 122 AttributeOptionManager.getInstance(new NumberKey(87)); 123 assertEquals(true, ao.isChildOf(parent)); 124 System.out.println (ao.isChildOf(parent)); 125 } 126 127 public void testIsParentOf() 128 throws Exception 129 { 130 System.out.println ( 131 "Testing: testIsParentOf() with AttributeOption: " + ao.getName()); 132 AttributeOption child = 133 AttributeOptionManager.getInstance(new NumberKey(39)); 134 assertEquals(true, ao.isParentOf(child)); 135 System.out.println (ao.isParentOf(child)); 136 } 137 138 public void testHasChildren() 139 throws Exception 140 { 141 System.out.println ( 142 "Testing: testHasChildren() with AttributeOption: " + ao.getName()); 143 assertEquals(true, ao.hasChildren()); 144 System.out.println (ao.hasChildren()); 145 } 146 147 public void testHasParents() 148 throws Exception 149 { 150 System.out.println ( 151 "Testing: testHasParents() with AttributeOption: " + ao.getName()); 152 assertEquals(true, ao.hasParents()); 153 System.out.println (ao.hasParents()); 154 } 155 237 public void testGetAncestors() 238 throws Exception 239 { 240 System.out.println ( 241 "Testing: testGetAncestors()"); 242 243 List ancestors = ao.getAncestors(); 244 Iterator itr = ancestors.iterator(); 245 while (itr.hasNext()) 246 { 247 AttributeOption val = ((AttributeOption)itr.next()); 248 System.out.println (val.getPrimaryKey() + " : " + val.getName()); 249 } 250 assertEquals("Unix", ((AttributeOption)(ancestors.get(0))).getName()); 251 assertEquals("All", ((AttributeOption)(ancestors.get(1))).getName()); 252 } 253 254 public void testGetDescendants() 255 throws Exception 256 { 257 System.out.println ( 258 "Testing: testGetDescendants()"); 259 260 List descendants = ao.getDescendants(); 261 Iterator itr = descendants.iterator(); 262 while (itr.hasNext()) 263 { 264 AttributeOption val = ((AttributeOption)itr.next()); 265 System.out.println (val.getPrimaryKey() + " : " + val.getName()); 266 } 267 assertEquals("SunOS", ((AttributeOption)(descendants.get(0))).getName()); 268 assertEquals("Solaris", ((AttributeOption)(descendants.get(1))).getName()); 269 assertEquals("OSF1", ((AttributeOption)(descendants.get(2))).getName()); 270 assertEquals("IRIX", ((AttributeOption)(descendants.get(3))).getName()); 271 assertEquals("HPUX", ((AttributeOption)(descendants.get(4))).getName()); 272 assertEquals("BeOS", ((AttributeOption)(descendants.get(5))).getName()); 273 assertEquals("AIX", ((AttributeOption)(descendants.get(6))).getName()); 274 assertEquals("BSDI", ((AttributeOption)(descendants.get(7))).getName()); 275 } 276 277 278 295 } 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | Popular Tags |