MemcacheClientWrapper extends AbstractMemcacheClientWrapper { @Override public boolean set(final String key, final int exp, final Object value) throws TimeoutException, CacheException { Future<Boolean> f = null; try { f = memcachedClient.set(key, exp, value); return f.get(); } catch (InterruptedException | ExecutionException e) { cancel(f); throw new CacheException(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 setStringIntObject() throws TimeoutException, CacheException { EasyMock.expect(client.set("key1", 1, "value")).andReturn(getFuture(true)); EasyMock.replay(client); assertTrue(clientWrapper.set("key1", 1, "value")); EasyMock.verify(client); }
@Test @SuppressWarnings("unchecked") public void setStringIntTMemcacheTranscoderOfT() throws TimeoutException, CacheException { CacheTranscoder transcoder = EasyMock.createMock(CacheTranscoder.class); EasyMock.expect(client.set(EasyMock.eq("key1"), EasyMock.eq(1), EasyMock.eq("value"), EasyMock.anyObject(Transcoder.class))) .andReturn(getFuture(true)); EasyMock.replay(client); assertTrue(clientWrapper.set("key1", 1, "value", transcoder)); EasyMock.verify(client); }