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 ListManagedObjectStateTest 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 testObjectList1() throws Exception {
24: String className = "java.util.ArrayList";
25: TestDNACursor cursor = new TestDNACursor();
26:
27: cursor.addLogicalAction(SerializationUtil.ADD,
28: new Object[] { new ObjectID(2002) });
29: cursor.addLogicalAction(SerializationUtil.ADD,
30: new Object[] { new ObjectID(2003) });
31: cursor.addLogicalAction(SerializationUtil.ADD_FIRST,
32: new Object[] { new ObjectID(2004) });
33:
34: basicTestUnit(className, ManagedObjectState.LIST_TYPE, cursor,
35: 3);
36: }
37:
38: public void testObjectList2() throws Exception {
39: String className = "java.util.ArrayList";
40: TestDNACursor cursor = new TestDNACursor();
41:
42: cursor.addLogicalAction(SerializationUtil.ADD,
43: new Object[] { new ObjectID(2002) });
44: cursor.addLogicalAction(SerializationUtil.ADD,
45: new Object[] { new ObjectID(2003) });
46: cursor.addLogicalAction(SerializationUtil.ADD_FIRST,
47: new Object[] { new ObjectID(2004) });
48: cursor.addLogicalAction(SerializationUtil.ADD_AT, new Object[] {
49: new Integer(1), new ObjectID(1000) });
50:
51: basicTestUnit(className, ManagedObjectState.LIST_TYPE, cursor,
52: 4);
53: }
54:
55: public void testObjectList3() throws Exception {
56: String className = "java.util.ArrayList";
57: TestDNACursor cursor = new TestDNACursor();
58:
59: for (int i = 0; i < 1000; ++i) {
60: cursor.addLogicalAction(SerializationUtil.ADD,
61: new Object[] { new ObjectID(1000 + i) });
62: }
63: cursor.addLogicalAction(SerializationUtil.CLEAR, null);
64:
65: basicTestUnit(className, ManagedObjectState.LIST_TYPE, cursor,
66: 0);
67: }
68:
69: public void testObjectList4() throws Exception {
70: String className = "java.util.ArrayList";
71: TestDNACursor cursor = new TestDNACursor();
72:
73: cursor.addLogicalAction(SerializationUtil.ADD,
74: new Object[] { new ObjectID(2002) });
75: cursor.addLogicalAction(SerializationUtil.ADD,
76: new Object[] { new ObjectID(2003) });
77: cursor.addLogicalAction(SerializationUtil.ADD,
78: new Object[] { new ObjectID(2004) });
79: cursor.addLogicalAction(SerializationUtil.REMOVE_FIRST, null);
80: cursor.addLogicalAction(SerializationUtil.REMOVE,
81: new Object[] { new ObjectID(2004) });
82:
83: basicTestUnit(className, ManagedObjectState.LIST_TYPE, cursor,
84: 1);
85: }
86:
87: }
|