/** * Gets multiple items from the cache based on the given set of keys. * <p> * @param cacheName * @param keys * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no * data in cache for any of these keys * @throws IOException */ @Override public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys ) throws IOException { return getMultiple( cacheName, keys, 0 ); }
/** * Gets multiple items from the cache based on the given set of keys. * <p> * @param cacheName * @param keys * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no * data in cache for any of these keys * @throws IOException */ @Override public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys ) throws IOException { return getMultiple( cacheName, keys, 0 ); }
/** * Verify get functionality * <p> * @throws IOException */ public void testGetMultiple_normal() throws IOException { // SETUP RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes(); RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes ); MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher(); client.setRemoteDispatcher( mockDispatcher ); String cacheName = "test"; Set<String> keys = Collections.emptySet(); ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, "key", "value" ); Map<String, ICacheElement<String, String>> expectedMap = new HashMap<String, ICacheElement<String,String>>(); expectedMap.put( "key", expected ); RemoteCacheResponse<Map<String, ICacheElement<String, String>>> remoteHttpCacheResponse = new RemoteCacheResponse<Map<String,ICacheElement<String,String>>>(); remoteHttpCacheResponse.setPayload( expectedMap ); mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse; // DO WORK Map<String, ICacheElement<String, String>> result = client.getMultiple( cacheName, keys ); // VERIFY assertEquals( "Wrong result.", expected, result.get( "key" ) ); assertEquals( "Wrong type.", RemoteRequestType.GET_MULTIPLE, mockDispatcher.lastRemoteCacheRequest.getRequestType() ); }
/** * Verify get functionality * <p> * @throws IOException */ public void testGetMultiple_normal() throws IOException { // SETUP RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes(); RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes ); MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher(); client.setRemoteDispatcher( mockDispatcher ); String cacheName = "test"; Set<String> keys = Collections.emptySet(); ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, "key", "value" ); Map<String, ICacheElement<String, String>> expectedMap = new HashMap<String, ICacheElement<String,String>>(); expectedMap.put( "key", expected ); RemoteCacheResponse<Map<String, ICacheElement<String, String>>> remoteHttpCacheResponse = new RemoteCacheResponse<Map<String,ICacheElement<String,String>>>(); remoteHttpCacheResponse.setPayload( expectedMap ); mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse; // DO WORK Map<String, ICacheElement<String, String>> result = client.getMultiple( cacheName, keys ); // VERIFY assertEquals( "Wrong result.", expected, result.get( "key" ) ); assertEquals( "Wrong type.", RemoteRequestType.GET_MULTIPLE, mockDispatcher.lastRemoteCacheRequest.getRequestType() ); }