1   package org.apache.jcs.auxiliary.remote;
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.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       * (non-Javadoc)
91       * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#getListenerId()
92       */
93      public long getListenerId()
94      {
95          // TODO Auto-generated method stub
96          return 0;
97      }
98  
99      /*
100      * (non-Javadoc)
101      * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#getListener()
102      */
103     public IRemoteCacheListener getListener()
104     {
105         // TODO Auto-generated method stub
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      * (non-Javadoc)
149      * @see org.apache.jcs.auxiliary.AuxiliaryCache#removeAll()
150      */
151     public void removeAll()
152         throws IOException
153     {
154         // TODO Auto-generated method stub
155 
156     }
157 
158     /*
159      * (non-Javadoc)
160      * @see org.apache.jcs.auxiliary.AuxiliaryCache#dispose()
161      */
162     public void dispose()
163         throws IOException
164     {
165         // TODO Auto-generated method stub
166 
167     }
168 
169     /*
170      * (non-Javadoc)
171      * @see org.apache.jcs.auxiliary.AuxiliaryCache#getSize()
172      */
173     public int getSize()
174     {
175         // TODO Auto-generated method stub
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      * (non-Javadoc)
190      * @see org.apache.jcs.auxiliary.AuxiliaryCache#getCacheName()
191      */
192     public String getCacheName()
193     {
194         // TODO Auto-generated method stub
195         return null;
196     }
197 
198     /*
199      * (non-Javadoc)
200      * @see org.apache.jcs.auxiliary.AuxiliaryCache#getGroupKeys(java.lang.String)
201      */
202     public Set getGroupKeys( String group )
203         throws IOException
204     {
205         // TODO Auto-generated method stub
206         return null;
207     }
208 
209     /*
210      * (non-Javadoc)
211      * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
212      */
213     public IStats getStatistics()
214     {
215         // TODO Auto-generated method stub
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      * (non-Javadoc)
232      * @see org.apache.jcs.engine.behavior.ICache#getStats()
233      */
234     public String getStats()
235     {
236         // TODO Auto-generated method stub
237         return null;
238     }
239 
240     /*
241      * (non-Javadoc)
242      * @see org.apache.jcs.engine.behavior.ICacheType#getCacheType()
243      */
244     public int getCacheType()
245     {
246         // TODO Auto-generated method stub
247         return 0;
248     }
249 
250 }