MemcacheClientWrapper extends AbstractMemcacheClientWrapper { @Override public Object get(final String key) throws TimeoutException, CacheException { try { return memcachedClient.get(key); } catch (OperationTimeoutException e) { LOGGER.warn("Operation timeout while get {}", key, e); throw new TimeoutException(e.getMessage()); } catch (RuntimeException e) { throw mapAndRethrow(e); } } MemcacheClientWrapper(final MemcachedClientIF memcachedClient); @Override boolean add(final String key, final int exp, final Object value); @Override boolean add(final String key, final int exp, final T value, final CacheTranscoder transcoder); @Override long decr(final String key, final int by); @Override long decr(final String key, final int by, final long def); @Override boolean delete(final String key); @Override void flush(); @Override Object get(final String key); @Override T get(final String key, final CacheTranscoder transcoder); @Override T get(final String key, final CacheTranscoder transcoder, final long timeout); @Override Collection<SocketAddress> getAvailableServers(); @Override Map<String, Object> getBulk(final Collection<String> keys); @Override Map<String, T> getBulk(final Collection<String> keys, final CacheTranscoder transcoder); @Override long incr(final String key, final int by); @Override long incr(final String key, final int by, final long def); @Override long incr(final String key, final int by, final long def, final int expiration); @Override boolean set(final String key, final int exp, final Object value); @Override boolean set(final String key, final int exp, final T value, final CacheTranscoder transcoder); @Override void shutdown(); @Override CacheTranscoder getTranscoder(); @Override Object getNativeClient();  }
@Test public void getString() throws TimeoutException, CacheException { EasyMock.expect(client.get("key1")).andReturn("test-value"); EasyMock.replay(client); assertEquals("test-value", clientWrapper.get("key1")); EasyMock.verify(client); }
@Test @SuppressWarnings("unchecked") public void getStringMemcacheTranscoderOfT() throws CacheException, TimeoutException { CacheTranscoder transcoder = EasyMock.createMock(CacheTranscoder.class); EasyMock.expect(client.get(EasyMock.eq("key1"), EasyMock.anyObject(Transcoder.class))).andReturn("test-value"); EasyMock.replay(client); assertEquals("test-value", clientWrapper.get("key1", transcoder)); EasyMock.verify(client); }
@Test @SuppressWarnings("unchecked") public void getStringMemcacheTranscoderOfTLong() throws TimeoutException, CacheException { CacheTranscoder transcoder = EasyMock.createMock(CacheTranscoder.class); EasyMock.expect(client.asyncGet(EasyMock.eq("key1"), EasyMock.anyObject(Transcoder.class))).andReturn(getFuture("test-value")); EasyMock.replay(client); assertEquals("test-value", clientWrapper.get("key1", transcoder, 100)); EasyMock.verify(client); }