KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > tx > MockTransactionManager


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.tx;
5
6 import com.tc.exception.ImplementMe;
7 import com.tc.logging.TCLogger;
8 import com.tc.logging.TCLogging;
9 import com.tc.net.protocol.tcm.ChannelIDProvider;
10 import com.tc.object.ObjectID;
11 import com.tc.object.TCObject;
12 import com.tc.object.dmi.DmiDescriptor;
13 import com.tc.object.lockmanager.api.LockID;
14 import com.tc.object.session.SessionID;
15
16 import java.util.ArrayList JavaDoc;
17 import java.util.Collection JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.Map JavaDoc;
20 import java.util.Set JavaDoc;
21
22 /**
23  * MockTransactionManager for unit testing.
24  */

25 public class MockTransactionManager implements ClientTransactionManager {
26
27   private static final TCLogger logger = TCLogging.getLogger(MockTransactionManager.class);
28
29   private int commitCount;
30   private List JavaDoc begins = new ArrayList JavaDoc();
31
32   public void clearBegins() {
33     begins.clear();
34   }
35
36   public List JavaDoc getBegins() {
37     List JavaDoc rv = new ArrayList JavaDoc();
38     rv.addAll(begins);
39     return rv;
40   }
41
42   public void begin(String JavaDoc lock, int type) {
43     // System.err.println(this + ".begin(" + lock + ")");
44

45     begins.add(new Begin(lock, type));
46   }
47
48   public void clearCommitCount() {
49     this.commitCount = 0;
50   }
51
52   public int getCommitCount() {
53     return this.commitCount;
54   }
55
56   public void createObject(TCObject source) {
57     throw new ImplementMe();
58   }
59
60   public void createRoot(String JavaDoc name, ObjectID id) {
61     throw new ImplementMe();
62   }
63
64   public void fieldChanged(TCObject source, String JavaDoc classname, String JavaDoc fieldname, Object JavaDoc newValue, int index) {
65     throw new ImplementMe();
66   }
67
68   public void logicalInvoke(TCObject source, int name, String JavaDoc methodName, Object JavaDoc[] parameters) {
69     throw new ImplementMe();
70   }
71
72   public static class Begin {
73     public String JavaDoc lockName;
74     public int lockType;
75
76     Begin(String JavaDoc name, int type) {
77       this.lockName = name;
78       this.lockType = type;
79     }
80   }
81
82   public void wait(WaitInvocation call, Object JavaDoc object) {
83     throw new ImplementMe();
84   }
85
86   public void notify(String JavaDoc lockName, boolean all, Object JavaDoc object) throws UnlockedSharedObjectException {
87     throw new ImplementMe();
88   }
89
90   public void receivedBatchAcknowledgement(TxnBatchID batchID) {
91     throw new ImplementMe();
92   }
93
94   public void apply(TxnType txType, LockID[] lockIDs, Collection JavaDoc objectChanges, Set JavaDoc lookupObjectIDs, Map JavaDoc newRoots) {
95     throw new ImplementMe();
96   }
97
98   public void checkWriteAccess(Object JavaDoc context) {
99     //
100
}
101
102   public void receivedAcknowledgement(SessionID sessionID, TransactionID requestID) {
103     throw new ImplementMe();
104   }
105
106   public void addReference(TCObject tco) {
107     throw new ImplementMe();
108   }
109
110   public ChannelIDProvider getChannelIDProvider() {
111     return null;
112   }
113
114   public boolean isLocked(String JavaDoc lockName) {
115     throw new ImplementMe();
116   }
117
118   public void commit(String JavaDoc lockName) throws UnlockedSharedObjectException {
119     if (logger.isDebugEnabled()) {
120       logger.debug("commit(lockName)");
121     }
122     this.commitCount++;
123   }
124
125   public void wait(String JavaDoc lockName, WaitInvocation call, Object JavaDoc object) throws UnlockedSharedObjectException {
126     throw new ImplementMe();
127   }
128
129   public void lock(String JavaDoc lockName, int lockLevel) {
130     throw new ImplementMe();
131   }
132
133   public void unlock(String JavaDoc lockName) {
134     throw new ImplementMe();
135   }
136
137   public int queueLength(String JavaDoc lockName) {
138     throw new ImplementMe();
139   }
140
141   public int waitLength(String JavaDoc lockName) {
142     throw new ImplementMe();
143   }
144
145   public ClientTransaction getTransaction() {
146     throw new ImplementMe();
147   }
148
149   public void disableTransactionLogging() {
150     return;
151   }
152
153   public void enableTransactionLogging() {
154     return;
155   }
156
157   public boolean isTransactionLoggingDisabled() {
158     throw new ImplementMe();
159   }
160
161   public boolean isHeldByCurrentThread(String JavaDoc lockName, int lockLevel) {
162     throw new ImplementMe();
163   }
164
165   public boolean tryBegin(String JavaDoc lock, int lockLevel) {
166     throw new ImplementMe();
167   }
168
169   public void literalValueChanged(TCObject source, Object JavaDoc newValue, Object JavaDoc oldValue) {
170     throw new ImplementMe();
171   }
172
173   public void arrayChanged(TCObject src, int startPos, Object JavaDoc array, int length) {
174     throw new ImplementMe();
175   }
176
177   public void addDmiDescriptor(DmiDescriptor d) {
178     throw new ImplementMe();
179   }
180 }
181
Popular Tags