/** * Gets multiple items from the cache based on the given set of keys. * <p> * @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 */ @Override public Map<K, ICacheElement<K, V>> getMultiple( Set<K> keys ) { if ( keys != null && !keys.isEmpty() ) { for (RemoteCacheNoWait<K, V> nw : noWaits) { try { return nw.getMultiple( keys ); } catch ( IOException ex ) { log.debug( "Failed to get." ); } } } return Collections.emptyMap(); }
/** * Gets multiple items from the cache based on the given set of keys. * <p> * @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 */ @Override public Map<K, ICacheElement<K, V>> getMultiple( Set<K> keys ) { if ( keys != null && !keys.isEmpty() ) { for ( int i = 0; i < noWaits.length; i++ ) { try { return noWaits[i].getMultiple( keys ); } catch ( IOException ex ) { log.debug( "Failed to get." ); } } } return Collections.emptyMap(); }
/** * Simply verify that the client getMultiple is called from the no wait. * <p> * @throws Exception */ public void testGetMultiple() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( "testUpdate", "key", "value" ); Map<String, ICacheElement<String, String>> inputMap = new HashMap<String, ICacheElement<String,String>>(); inputMap.put( "key", inputElement ); Set<String> keys = new HashSet<String>(); keys.add( "key" ); client.getMultipleSetupMap.put( keys, inputMap ); // DO WORK Map<String, ICacheElement<String, String>> result = noWait.getMultiple( keys ); // VERIFY assertEquals( "elements map", inputMap, result ); }
/** * Simply verify that the client getMultiple is called from the no wait. * <p> * @throws Exception */ public void testGetMultiple() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( "testUpdate", "key", "value" ); Map<String, ICacheElement<String, String>> inputMap = new HashMap<String, ICacheElement<String,String>>(); inputMap.put( "key", inputElement ); Set<String> keys = new HashSet<String>(); keys.add( "key" ); client.getMultipleSetupMap.put( keys, inputMap ); // DO WORK Map<String, ICacheElement<String, String>> result = noWait.getMultiple( keys ); // VERIFY assertEquals( "elements map", inputMap, result ); }