MemcacheClientWrapper extends AbstractMemcacheClientWrapper { @Override public Map<String, Object> getBulk(final Collection<String> keys) throws TimeoutException, CacheException { try { return memcachedClient.getBulk(keys); } catch (OperationTimeoutException e) { LOGGER.warn("Operation timeout while getBulk {}", keys, e); throw (TimeoutException) e.getCause(); } catch (RuntimeException e) { if (translateException(e)) { throw new CacheException(e); } throw 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 @SuppressWarnings("unchecked") public void getBulkCollectionOfString() throws TimeoutException, CacheException { Collection<String> keys = EasyMock.createMock(Collection.class); Map<String, Object> results = EasyMock.createMock(Map.class); EasyMock.expect(client.getBulk(keys)).andReturn(results); EasyMock.replay(client); assertEquals(results, clientWrapper.getBulk(keys)); EasyMock.verify(client); }
@Test @SuppressWarnings("unchecked") public void getBulkCollectionOfStringMemcacheTranscoderOfT() throws TimeoutException, CacheException { Collection<String> keys = EasyMock.createMock(Collection.class); Map<String, Object> results = EasyMock.createMock(Map.class); CacheTranscoder transcoder = EasyMock.createMock(CacheTranscoder.class); EasyMock.expect(client.getBulk(EasyMock.eq(keys), EasyMock.anyObject(Transcoder.class))).andReturn(results); EasyMock.replay(client); assertEquals(results, clientWrapper.getBulk(keys, transcoder)); EasyMock.verify(client); }