/** * Synchronously reads from the remote cache. * <p> * @param key * @return Either an ICacheElement<K, V> or null if it is not found. */ @Override public ICacheElement<K, V> get( K key ) { for (RemoteCacheNoWait<K, V> nw : noWaits) { try { ICacheElement<K, V> obj = nw.get( key ); if ( obj != null ) { return obj; } } catch ( IOException ex ) { log.debug( "Failed to get." ); return null; } } return null; }
/** * Synchronously reads from the remote cache. * <p> * @param key * @return Either an ICacheElement<K, V> or null if it is not found. */ @Override public ICacheElement<K, V> get( K key ) { for ( int i = 0; i < noWaits.length; i++ ) { try { ICacheElement<K, V> obj = noWaits[i].get( key ); if ( obj != null ) { return obj; } } catch ( IOException ex ) { log.debug( "Failed to get." ); return null; } } return null; }
/** * Simply verify that the client get is called from the no wait. * <p> * @throws Exception */ public void testGet() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> input = new CacheElement<String, String>( "testUpdate", "key", "value" ); client.getSetupMap.put( "key", input ); // DO WORK ICacheElement<String, String> result = noWait.get( "key" ); // VERIFY assertEquals( "Wrong element", input, result ); }
/** * Simply verify that the client get is called from the no wait. * <p> * @throws Exception */ public void testGet() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> input = new CacheElement<String, String>( "testUpdate", "key", "value" ); client.getSetupMap.put( "key", input ); // DO WORK ICacheElement<String, String> result = noWait.get( "key" ); // VERIFY assertEquals( "Wrong element", input, result ); }