1 package org.apache.commons.jcs.auxiliary;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.io.IOException;
23 import java.util.HashMap;
24 import java.util.Map;
25 import java.util.Set;
26
27 import org.apache.commons.jcs.engine.CacheStatus;
28 import org.apache.commons.jcs.engine.behavior.ICacheElement;
29 import org.apache.commons.jcs.engine.stats.behavior.IStats;
30
31 /**
32 * Mock auxiliary for unit tests.
33 * <p>
34 * @author Aaron Smuts
35 */
36 public class MockAuxiliaryCache<K, V>
37 extends AbstractAuxiliaryCache<K, V>
38 {
39 /** Can setup the cache type */
40 public CacheType cacheType = CacheType.DISK_CACHE;
41
42 /** Can setup status */
43 public CacheStatus status = CacheStatus.ALIVE;
44
45 /** Times getMatching was Called */
46 public int getMatchingCallCount = 0;
47
48 /**
49 * @param ce
50 * @throws IOException
51 */
52 @Override
53 public void update( ICacheElement<K, V> ce )
54 throws IOException
55 {
56 // TODO Auto-generated method stub
57
58 }
59
60 /**
61 * @param key
62 * @return ICacheElement
63 * @throws IOException
64 */
65 @Override
66 public ICacheElement<K, V> get( K key )
67 throws IOException
68 {
69 // TODO Auto-generated method stub
70 return null;
71 }
72
73 /**
74 * @param pattern
75 * @return Map
76 * @throws IOException
77 */
78 @Override
79 public Map<K, ICacheElement<K, V>> getMatching(String pattern)
80 throws IOException
81 {
82 getMatchingCallCount++;
83 return new HashMap<K, ICacheElement<K, V>>();
84 }
85
86 /**
87 * Gets multiple items from the cache based on the given set of keys.
88 * <p>
89 * @param keys
90 * @return a map of K key to ICacheElement<String, String> element, or an empty map if there is no
91 * data in cache for any of these keys
92 */
93 @Override
94 public Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys)
95 {
96 return new HashMap<K, ICacheElement<K, V>>();
97 }
98
99 /**
100 * @param key
101 * @return boolean
102 * @throws IOException
103 */
104 @Override
105 public boolean remove( K key )
106 throws IOException
107 {
108 // TODO Auto-generated method stub
109 return false;
110 }
111
112 /**
113 * @throws IOException
114 */
115 @Override
116 public void removeAll()
117 throws IOException
118 {
119 // TODO Auto-generated method stub
120
121 }
122
123 /**
124 * @throws IOException
125 */
126 @Override
127 public void dispose()
128 throws IOException
129 {
130 // TODO Auto-generated method stub
131
132 }
133
134 /**
135 * @return int
136 */
137 @Override
138 public int getSize()
139 {
140 // TODO Auto-generated method stub
141 return 0;
142 }
143
144 /**
145 * @return int
146 */
147 @Override
148 public CacheStatus getStatus()
149 {
150 return status;
151 }
152
153 /**
154 * @return null
155 */
156 @Override
157 public String getCacheName()
158 {
159 return null;
160 }
161
162 /**
163 * Return the keys in this cache.
164 * <p>
165 * @see org.apache.commons.jcs.auxiliary.disk.AbstractDiskCache#getKeySet()
166 */
167 @Override
168 public Set<K> getKeySet() throws IOException
169 {
170 return null;
171 }
172
173 /**
174 * @return null
175 */
176 @Override
177 public IStats getStatistics()
178 {
179 return null;
180 }
181
182 /**
183 * @return null
184 */
185 @Override
186 public String getStats()
187 {
188 return null;
189 }
190
191 /**
192 * @return cacheType
193 */
194 @Override
195 public CacheType getCacheType()
196 {
197 return cacheType;
198 }
199
200 /**
201 * @return Returns the AuxiliaryCacheAttributes.
202 */
203 @Override
204 public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
205 {
206 return null;
207 }
208
209 /** @return null */
210 @Override
211 public String getEventLoggingExtraInfo()
212 {
213 return null;
214 }
215 }