1 4 package com.tc.objectserver.core.api; 5 6 import com.tc.object.ObjectID; 7 import com.tc.object.tx.TransactionID; 8 import com.tc.objectserver.api.ObjectInstanceMonitor; 9 import com.tc.objectserver.impl.ObjectInstanceMonitorImpl; 10 import com.tc.objectserver.managedobject.BackReferences; 11 import com.tc.objectserver.managedobject.ManagedObjectImpl; 12 import com.tc.objectserver.managedobject.ManagedObjectStateFactory; 13 import com.tc.objectserver.managedobject.NullManagedObjectChangeListenerProvider; 14 import com.tc.objectserver.persistence.impl.InMemoryPersistor; 15 import com.tc.test.TCTestCase; 16 17 import java.util.Map ; 18 19 public class ManagedObjectTest extends TCTestCase { 20 21 public void testBasics() throws Exception { 22 ObjectInstanceMonitor instanceMonitor = new ObjectInstanceMonitorImpl(); 23 ObjectID objectID = new ObjectID(1); 24 ManagedObjectStateFactory.disableSingleton(true); 25 ManagedObjectStateFactory.createInstance(new NullManagedObjectChangeListenerProvider(), 26 new InMemoryPersistor()); 27 28 ManagedObjectImpl mo = new ManagedObjectImpl(objectID); 29 30 assertTrue(mo.isDirty()); 31 assertTrue(mo.isNew()); 32 33 TestDNACursor cursor = new TestDNACursor(); 34 cursor.addPhysicalAction("field1", new ObjectID(1)); 35 cursor.addPhysicalAction("field2", new Boolean (true)); 36 cursor.addPhysicalAction("field3", new Character ('c')); 37 TestDNA dna = new TestDNA(cursor); 38 39 Map instances = instanceMonitor.getInstanceCounts(); 40 assertEquals(0, instances.size()); 41 mo.apply(dna, new TransactionID(1), new BackReferences(), instanceMonitor); 42 assertFalse(mo.isNew()); 43 44 instances = instanceMonitor.getInstanceCounts(); 45 assertEquals(1, instances.size()); 46 assertEquals(new Integer (1), instances.get(dna.getTypeName())); 47 48 assertEquals(1, mo.getObjectReferences().size()); 49 assertEquals(dna.typeName, mo.getClassname()); 50 assertEquals(dna.loaderDesc, mo.getLoaderDescription()); 51 } 52 53 } | Popular Tags |