01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.objectserver.managedobject;
06:
07: import com.tc.object.ObjectID;
08: import com.tc.object.SerializationUtil;
09: import com.tc.objectserver.core.api.ManagedObjectState;
10: import com.tc.util.Assert;
11:
12: public class SetManagedObjectStateTest extends
13: AbstractTestManagedObjectState {
14:
15: // override due to difference on dehydrate
16: protected void basicDehydrate(TestDNACursor cursor, int objCount,
17: ManagedObjectState state) {
18: TestDNAWriter dnaWriter = new TestDNAWriter();
19: state.dehydrate(objectID, dnaWriter);
20: Assert.assertEquals(objCount, dnaWriter.getActionCount());
21: }
22:
23: public void testObjectTreeSet1() throws Exception {
24: String className = "java.util.TreeSet";
25: String COMPARATOR_FIELDNAME = "java.util.TreeMap.comparator";
26:
27: TestDNACursor cursor = new TestDNACursor();
28:
29: cursor.addPhysicalAction(COMPARATOR_FIELDNAME, new ObjectID(
30: 2001), true);
31:
32: cursor.addLogicalAction(SerializationUtil.ADD,
33: new Object[] { new ObjectID(2002) });
34: cursor.addLogicalAction(SerializationUtil.ADD,
35: new Object[] { new ObjectID(2003) });
36:
37: basicTestUnit(className, ManagedObjectState.TREE_SET_TYPE,
38: cursor, 3);
39: }
40:
41: public void testObjectTreeSet2() throws Exception {
42: String className = "java.util.TreeSet";
43: TestDNACursor cursor = new TestDNACursor();
44:
45: for (int i = 0; i < 1000; ++i) {
46: cursor.addLogicalAction(SerializationUtil.ADD,
47: new Object[] { new ObjectID(1000 + i) });
48: }
49: cursor.addLogicalAction(SerializationUtil.CLEAR, null);
50:
51: basicTestUnit(className, ManagedObjectState.TREE_SET_TYPE,
52: cursor, 0);
53: }
54:
55: }
|