1 4 package com.tc.objectserver.core.impl; 5 6 import com.tc.object.ObjectID; 7 import com.tc.objectserver.managedobject.BackReferences; 8 import com.tc.test.TCTestCase; 9 10 import java.util.HashSet ; 11 import java.util.Set ; 12 13 public class BackReferencesTest extends TCTestCase { 14 15 public void testBasic() throws Exception { 16 BackReferences br = new BackReferences(); 17 assertTrue(br.getAllParents().isEmpty()); 18 19 Set actualParents = new HashSet (); 20 Set actualRefChildren = new HashSet (); 21 22 ObjectID p = new ObjectID(1); 24 ObjectID c = new ObjectID(2); 25 26 actualParents.add(p); 27 actualRefChildren.add(c); 28 29 br.addBackReference(c, p); 30 Set parents = br.getAllParents(); 31 assertEquals(actualParents, parents); 32 Set referencedChildren = br.addReferencedChildrenTo(new HashSet (), parents); 33 assertEquals(actualRefChildren, referencedChildren); 34 35 p = new ObjectID(3); 37 c = new ObjectID(5); 38 39 actualParents.add(p); 40 br.addBackReference(c, p); 41 42 p = new ObjectID(4); 43 actualParents.add(p); 44 br.addBackReference(c, p); 45 46 parents = br.getAllParents(); 47 assertEquals(actualParents, parents); 48 49 Set interestedParents = new HashSet (); 50 interestedParents.add(new ObjectID(1)); 51 52 referencedChildren = br.addReferencedChildrenTo(new HashSet (), interestedParents); 53 assertEquals(actualRefChildren, referencedChildren); 54 55 interestedParents.add(new ObjectID(3)); 56 actualRefChildren.add(new ObjectID(5)); 57 58 referencedChildren = br.addReferencedChildrenTo(new HashSet (), interestedParents); 59 assertEquals(actualRefChildren, referencedChildren); 60 61 62 p = new ObjectID(5); 64 c = new ObjectID(1); 65 66 actualParents.add(p); 67 br.addBackReference(c, p); 68 69 parents = br.getAllParents(); 70 assertEquals(actualParents, parents); 71 72 interestedParents = new HashSet (); 73 interestedParents.add(new ObjectID(3)); 74 actualRefChildren = new HashSet (); 75 actualRefChildren.add(new ObjectID(5)); 76 actualRefChildren.add(new ObjectID(1)); 77 actualRefChildren.add(new ObjectID(2)); 78 79 referencedChildren = br.addReferencedChildrenTo(new HashSet (), interestedParents); 80 assertEquals(actualRefChildren, referencedChildren); 81 82 } 83 } 84 | Popular Tags |