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:
11: public class MapManagedObjectStateTest extends
12: AbstractTestManagedObjectState {
13:
14: public void testConcurentHashMap() throws Exception {
15: String className = "java.util.concurrent.ConcurrentHashMap";
16: String SEGMENT_MASK_FIELD_NAME = className + ".segmentMask";
17: String SEGMENT_SHIFT_FIELD_NAME = className + ".segmentShift";
18: String SEGMENT_FIELD_NAME = className + ".segments";
19:
20: TestDNACursor cursor = new TestDNACursor();
21:
22: cursor.addPhysicalAction(SEGMENT_MASK_FIELD_NAME, new Integer(
23: 10), false);
24: cursor.addPhysicalAction(SEGMENT_SHIFT_FIELD_NAME, new Integer(
25: 20), false);
26: cursor.addLiteralAction(new Integer(2));
27: cursor.addPhysicalAction(SEGMENT_FIELD_NAME + 0, new ObjectID(
28: 2001), true);
29: cursor.addPhysicalAction(SEGMENT_FIELD_NAME + 1, new ObjectID(
30: 2002), true);
31:
32: cursor.addLogicalAction(SerializationUtil.PUT, new Object[] {
33: new ObjectID(2002), new ObjectID(2003) });
34: cursor.addLogicalAction(SerializationUtil.PUT, new Object[] {
35: new ObjectID(2004), new ObjectID(2005) });
36: cursor.addLogicalAction(SerializationUtil.PUT, new Object[] {
37: new ObjectID(2009), new ObjectID(2010) });
38:
39: basicTestUnit(className,
40: ManagedObjectState.CONCURRENT_HASHMAP_TYPE, cursor, 7);
41: }
42:
43: public void testTreeMap() throws Exception {
44: String className = "java.util.TreeMap";
45: String COMPARATOR_FIELDNAME = "java.util.TreeMap.comparator";
46:
47: TestDNACursor cursor = new TestDNACursor();
48:
49: cursor.addPhysicalAction(COMPARATOR_FIELDNAME, new ObjectID(
50: 2001), true);
51: cursor.addLogicalAction(SerializationUtil.PUT, new Object[] {
52: new ObjectID(2002), new ObjectID(2003) });
53: cursor.addLogicalAction(SerializationUtil.PUT, new Object[] {
54: new ObjectID(2004), new ObjectID(2005) });
55:
56: basicTestUnit(className, ManagedObjectState.TREE_MAP_TYPE,
57: cursor, 5);
58: }
59:
60: public void testLinkedHashMap() throws Exception {
61: String className = "java.util.LinkedHashMap";
62: String ACCESS_ORDER_FIELDNAME = "java.util.LinkedHashMap.accessOrder";
63:
64: TestDNACursor cursor = new TestDNACursor();
65:
66: cursor.addPhysicalAction(ACCESS_ORDER_FIELDNAME, Boolean.FALSE,
67: false);
68:
69: cursor.addLogicalAction(SerializationUtil.PUT, new Object[] {
70: new ObjectID(2002), new ObjectID(2003) });
71: cursor.addLogicalAction(SerializationUtil.PUT, new Object[] {
72: new ObjectID(2004), new ObjectID(2005) });
73:
74: basicTestUnit(className,
75: ManagedObjectState.LINKED_HASHMAP_TYPE, cursor, 4);
76: }
77:
78: /*
79: public void testIdentityHashMap() throws Exception {
80: String className = "java.util.IdentityHashMap";
81:
82: TestDNACursor cursor = new TestDNACursor();
83:
84: cursor.addLogicalAction(SerializationUtil.PUT, new Object[] { new ObjectID(2012), new ObjectID(2003) });
85: cursor.addLogicalAction(SerializationUtil.PUT, new Object[] { new ObjectID(2004), new ObjectID(2015) });
86:
87: basicTestUnit(className, ManagedObjectState.MAP_TYPE, cursor, 4);
88: // failed on equal, no implementation for basicWriteTo()
89: }
90: */
91:
92: }
|