ICacheElement<Serializable, Serializable> element = remoteCacheService.get( request.getCacheName(), request.getKey(), request.getRequesterId() ); response.setPayload(element); break; case GET_MULTIPLE: response.setPayload(map); response.setPayload(map); case GET_KEYSET: Set<Serializable> keys = remoteCacheService.getKeySet( request.getCacheName() ); response.setPayload( keys ); break; default:
ICacheElement<K, V> element = getRemoteCacheService().get( request.getCacheName(), request.getKey(), request.getRequesterId() ); response.setPayload(element); break; case GET_MULTIPLE: response.setPayload(map); response.setPayload(map); case GET_KEYSET: Set<K> keys = getRemoteCacheService().getKeySet( request.getCacheName() ); response.setPayload( keys ); break; default:
/** * Verify get functionality * <p> * @throws IOException */ public void testGetMultiple_normal() throws IOException { // SETUP RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes(); RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes ); MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher(); client.setRemoteDispatcher( mockDispatcher ); String cacheName = "test"; Set<String> keys = Collections.emptySet(); ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, "key", "value" ); Map<String, ICacheElement<String, String>> expectedMap = new HashMap<String, ICacheElement<String,String>>(); expectedMap.put( "key", expected ); RemoteCacheResponse<Map<String, ICacheElement<String, String>>> remoteHttpCacheResponse = new RemoteCacheResponse<Map<String,ICacheElement<String,String>>>(); remoteHttpCacheResponse.setPayload( expectedMap ); mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse; // DO WORK Map<String, ICacheElement<String, String>> result = client.getMultiple( cacheName, keys ); // VERIFY assertEquals( "Wrong result.", expected, result.get( "key" ) ); assertEquals( "Wrong type.", RemoteRequestType.GET_MULTIPLE, mockDispatcher.lastRemoteCacheRequest.getRequestType() ); }
/** * Verify get functionality * <p> * @throws IOException */ public void testGetMultiple_normal() throws IOException { // SETUP RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes(); RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes ); MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher(); client.setRemoteDispatcher( mockDispatcher ); String cacheName = "test"; Set<String> keys = Collections.emptySet(); ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, "key", "value" ); Map<String, ICacheElement<String, String>> expectedMap = new HashMap<String, ICacheElement<String,String>>(); expectedMap.put( "key", expected ); RemoteCacheResponse<Map<String, ICacheElement<String, String>>> remoteHttpCacheResponse = new RemoteCacheResponse<Map<String,ICacheElement<String,String>>>(); remoteHttpCacheResponse.setPayload( expectedMap ); mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse; // DO WORK Map<String, ICacheElement<String, String>> result = client.getMultiple( cacheName, keys ); // VERIFY assertEquals( "Wrong result.", expected, result.get( "key" ) ); assertEquals( "Wrong type.", RemoteRequestType.GET_MULTIPLE, mockDispatcher.lastRemoteCacheRequest.getRequestType() ); }
/** * Verify get functionality * <p> * @throws IOException */ public void testGetMatching_normal() throws IOException { // SETUP RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes(); RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes ); MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher(); client.setRemoteDispatcher( mockDispatcher ); String cacheName = "test"; String pattern = "key"; ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, "key", "value" ); Map<String, ICacheElement<String, String>> expectedMap = new HashMap<String, ICacheElement<String,String>>(); expectedMap.put( "key", expected ); RemoteCacheResponse<Map<String, ICacheElement<String, String>>> remoteHttpCacheResponse = new RemoteCacheResponse<Map<String,ICacheElement<String,String>>>(); remoteHttpCacheResponse.setPayload( expectedMap ); mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse; // DO WORK Map<String, ICacheElement<String, String>> result = client.getMatching( cacheName, pattern ); // VERIFY assertEquals( "Wrong result.", expected, result.get( "key" ) ); assertEquals( "Wrong type.", RemoteRequestType.GET_MATCHING, mockDispatcher.lastRemoteCacheRequest.getRequestType() ); }
/** * Verify get functionality * <p> * @throws IOException */ public void testGetMatching_normal() throws IOException { // SETUP RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes(); RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes ); MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher(); client.setRemoteDispatcher( mockDispatcher ); String cacheName = "test"; String pattern = "key"; ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, "key", "value" ); Map<String, ICacheElement<String, String>> expectedMap = new HashMap<String, ICacheElement<String,String>>(); expectedMap.put( "key", expected ); RemoteCacheResponse<Map<String, ICacheElement<String, String>>> remoteHttpCacheResponse = new RemoteCacheResponse<Map<String,ICacheElement<String,String>>>(); remoteHttpCacheResponse.setPayload( expectedMap ); mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse; // DO WORK Map<String, ICacheElement<String, String>> result = client.getMatching( cacheName, pattern ); // VERIFY assertEquals( "Wrong result.", expected, result.get( "key" ) ); assertEquals( "Wrong type.", RemoteRequestType.GET_MATCHING, mockDispatcher.lastRemoteCacheRequest.getRequestType() ); }
/** * Verify get functionality * <p> * @throws IOException */ public void testGet_normal() throws IOException { // SETUP RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes(); RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes ); MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher(); client.setRemoteDispatcher( mockDispatcher ); String cacheName = "test"; String key = "key"; ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, key, "value" ); RemoteCacheResponse<ICacheElement<String, String>> remoteHttpCacheResponse = new RemoteCacheResponse<ICacheElement<String,String>>(); remoteHttpCacheResponse.setPayload( expected ); mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse; // DO WORK ICacheElement<String, String> result = client.get( cacheName, key ); // VERIFY assertEquals( "Wrong result.", expected, result ); assertEquals( "Wrong type.", RemoteRequestType.GET, mockDispatcher.lastRemoteCacheRequest .getRequestType() ); }
/** * Verify get functionality * <p> * @throws IOException */ public void testGet_normal() throws IOException { // SETUP RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes(); RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes ); MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher(); client.setRemoteDispatcher( mockDispatcher ); String cacheName = "test"; String key = "key"; ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, key, "value" ); RemoteCacheResponse<ICacheElement<String, String>> remoteHttpCacheResponse = new RemoteCacheResponse<ICacheElement<String,String>>(); remoteHttpCacheResponse.setPayload( expected ); mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse; // DO WORK ICacheElement<String, String> result = client.get( cacheName, key ); // VERIFY assertEquals( "Wrong result.", expected, result ); assertEquals( "Wrong type.", RemoteRequestType.GET, mockDispatcher.lastRemoteCacheRequest .getRequestType() ); }