1 package org.apache.commons.jcs3.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.jcs3.engine.CacheStatus;
28 import org.apache.commons.jcs3.engine.behavior.ICacheElement;
29 import org.apache.commons.jcs3.engine.stats.behavior.IStats;
30
31 /**
32 * Mock auxiliary for unit tests.
33 */
34 public class MockAuxiliaryCache<K, V>
35 extends AbstractAuxiliaryCache<K, V>
36 {
37 /** Can setup the cache type */
38 public CacheType cacheType = CacheType.DISK_CACHE;
39
40 /** Can setup status */
41 public CacheStatus status = CacheStatus.ALIVE;
42
43 /** Times getMatching was Called */
44 public int getMatchingCallCount;
45
46 /**
47 * @param ce
48 * @throws IOException
49 */
50 @Override
51 public void update( final ICacheElement<K, V> ce )
52 throws IOException
53 {
54 // TODO Auto-generated method stub
55
56 }
57
58 /**
59 * @param key
60 * @return ICacheElement
61 * @throws IOException
62 */
63 @Override
64 public ICacheElement<K, V> get( final K key )
65 throws IOException
66 {
67 // TODO Auto-generated method stub
68 return null;
69 }
70
71 /**
72 * @param pattern
73 * @return Map
74 * @throws IOException
75 */
76 @Override
77 public Map<K, ICacheElement<K, V>> getMatching(final String pattern)
78 throws IOException
79 {
80 getMatchingCallCount++;
81 return new HashMap<>();
82 }
83
84 /**
85 * Gets multiple items from the cache based on the given set of keys.
86 * <p>
87 * @param keys
88 * @return a map of K key to ICacheElement<String, String> element, or an empty map if there is no
89 * data in cache for any of these keys
90 */
91 @Override
92 public Map<K, ICacheElement<K, V>> getMultiple(final Set<K> keys)
93 {
94 return new HashMap<>();
95 }
96
97 /**
98 * @param key
99 * @return boolean
100 * @throws IOException
101 */
102 @Override
103 public boolean remove( final K key )
104 throws IOException
105 {
106 // TODO Auto-generated method stub
107 return false;
108 }
109
110 /**
111 * @throws IOException
112 */
113 @Override
114 public void removeAll()
115 throws IOException
116 {
117 // TODO Auto-generated method stub
118
119 }
120
121 /**
122 * @throws IOException
123 */
124 @Override
125 public void dispose()
126 throws IOException
127 {
128 // TODO Auto-generated method stub
129
130 }
131
132 /**
133 * @return int
134 */
135 @Override
136 public int getSize()
137 {
138 // TODO Auto-generated method stub
139 return 0;
140 }
141
142 /**
143 * @return int
144 */
145 @Override
146 public CacheStatus getStatus()
147 {
148 return status;
149 }
150
151 /**
152 * @return null
153 */
154 @Override
155 public String getCacheName()
156 {
157 return null;
158 }
159
160 /**
161 * Return the keys in this cache.
162 * <p>
163 * @see org.apache.commons.jcs3.auxiliary.disk.AbstractDiskCache#getKeySet()
164 */
165 @Override
166 public Set<K> getKeySet() throws IOException
167 {
168 return null;
169 }
170
171 /**
172 * @return null
173 */
174 @Override
175 public IStats getStatistics()
176 {
177 return null;
178 }
179
180 /**
181 * @return null
182 */
183 @Override
184 public String getStats()
185 {
186 return null;
187 }
188
189 /**
190 * @return cacheType
191 */
192 @Override
193 public CacheType getCacheType()
194 {
195 return cacheType;
196 }
197
198 /**
199 * @return Returns the AuxiliaryCacheAttributes.
200 */
201 @Override
202 public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
203 {
204 return null;
205 }
206
207 /** @return null */
208 @Override
209 public String getEventLoggingExtraInfo()
210 {
211 return null;
212 }
213 }