1 4 package com.tc.objectserver.impl; 5 6 import com.tc.object.ObjectID; 7 import com.tc.objectserver.core.api.ManagedObject; 8 import com.tc.objectserver.core.impl.TestManagedObject; 9 import com.tc.objectserver.persistence.impl.TestPersistenceTransaction; 10 import com.tc.test.TCTestCase; 11 12 import java.util.ArrayList ; 13 import java.util.HashMap ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 import java.util.Map ; 17 18 public class InMemoryManagedObjectStoreTest extends TCTestCase { 19 20 private InMemoryManagedObjectStore os; 21 private Map managed; 22 23 public void setUp() throws Exception { 24 managed = new HashMap (); 25 os = new InMemoryManagedObjectStore(managed); 26 } 27 28 public void testReleaseAll() { 29 List l = new ArrayList (); 30 for (int i=0; i<10; i++) { 31 l.add(new TestManagedObject(new ObjectID(i))); 32 } 33 assertEquals(0, managed.size()); 34 35 try { 36 os.commitAllObjects(TestPersistenceTransaction.NULL_TRANSACTION, l); 37 fail("Shouldn't be able to release objects that haven't been added."); 38 } catch (AssertionError e) { 39 } 41 42 for (Iterator i = l.iterator(); i.hasNext();) { 43 os.addNewObject((ManagedObject) i.next()); 44 } 45 os.commitAllObjects(TestPersistenceTransaction.NULL_TRANSACTION, l); 47 48 assertTrue(managed.values().containsAll(l)); 49 assertTrue(l.containsAll(managed.values())); 50 } 51 52 } 53 | Popular Tags |