1 package org.apache.jcs.auxiliary.remote;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.IOException;
23 import java.io.Serializable;
24 import java.util.HashMap;
25 import java.util.LinkedList;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Set;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
33 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient;
34 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
35 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService;
36 import org.apache.jcs.engine.CacheConstants;
37 import org.apache.jcs.engine.behavior.ICacheElement;
38 import org.apache.jcs.engine.stats.behavior.IStats;
39
40 /***
41 * Used for testing the no wait.
42 * <p>
43 * @author Aaron Smuts
44 */
45 public class RemoteCacheClientMockImpl
46 implements IRemoteCacheClient
47 {
48 private static final long serialVersionUID = 1L;
49
50 private final static Log log = LogFactory.getLog( RemoteCacheClientMockImpl.class );
51
52 /***
53 * List of ICacheElement objects passed into update.
54 */
55 public List updateList = new LinkedList();
56
57 /***
58 * List of key objects passed into remove.
59 */
60 public List removeList = new LinkedList();
61
62 /*** status to return. */
63 public int status = CacheConstants.STATUS_ALIVE;
64
65 /*** Can setup values to return from get. values must be ICacheElement */
66 public Map getSetupMap = new HashMap();
67
68 /***
69 * The last service passed to fixCache
70 */
71 public IRemoteCacheService fixed;
72
73 /***
74 * Attributes.
75 */
76 public RemoteCacheAttributes attributes = new RemoteCacheAttributes();
77
78 /***
79 * Stores the last argument as fixed.
80 * <p>
81 * (non-Javadoc)
82 * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#fixCache(org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService)
83 */
84 public void fixCache( IRemoteCacheService remote )
85 {
86 fixed = remote;
87 }
88
89
90
91
92
93 public long getListenerId()
94 {
95
96 return 0;
97 }
98
99
100
101
102
103 public IRemoteCacheListener getListener()
104 {
105
106 return null;
107 }
108
109 /***
110 * Adds the argument to the updatedList.
111 * <p>
112 * (non-Javadoc)
113 * @see org.apache.jcs.auxiliary.AuxiliaryCache#update(org.apache.jcs.engine.behavior.ICacheElement)
114 */
115 public void update( ICacheElement ce )
116 throws IOException
117 {
118 updateList.add( ce );
119 }
120
121 /***
122 * Looks in the getSetupMap for a value.
123 * <p>
124 * (non-Javadoc)
125 * @see org.apache.jcs.auxiliary.AuxiliaryCache#get(java.io.Serializable)
126 */
127 public ICacheElement get( Serializable key )
128 throws IOException
129 {
130 log.info( "get [" + key + "]" );
131 return (ICacheElement) getSetupMap.get( key );
132 }
133
134 /***
135 * Adds the key to the remove list.
136 * <p>
137 * (non-Javadoc)
138 * @see org.apache.jcs.auxiliary.AuxiliaryCache#remove(java.io.Serializable)
139 */
140 public boolean remove( Serializable key )
141 throws IOException
142 {
143 removeList.add( key );
144 return false;
145 }
146
147
148
149
150
151 public void removeAll()
152 throws IOException
153 {
154
155
156 }
157
158
159
160
161
162 public void dispose()
163 throws IOException
164 {
165
166
167 }
168
169
170
171
172
173 public int getSize()
174 {
175
176 return 0;
177 }
178
179 /***
180 * Returns the status setup variable. (non-Javadoc)
181 * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatus()
182 */
183 public int getStatus()
184 {
185 return status;
186 }
187
188
189
190
191
192 public String getCacheName()
193 {
194
195 return null;
196 }
197
198
199
200
201
202 public Set getGroupKeys( String group )
203 throws IOException
204 {
205
206 return null;
207 }
208
209
210
211
212
213 public IStats getStatistics()
214 {
215
216 return null;
217 }
218
219 /***
220 * Returns the setup attributes. By default they are not null.
221 * <p>
222 * (non-Javadoc)
223 * @see org.apache.jcs.auxiliary.AuxiliaryCache#getAuxiliaryCacheAttributes()
224 */
225 public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
226 {
227 return attributes;
228 }
229
230
231
232
233
234 public String getStats()
235 {
236
237 return null;
238 }
239
240
241
242
243
244 public int getCacheType()
245 {
246
247 return 0;
248 }
249
250 }