/** * Create a request, process, extract the payload. * <p> * @param cacheName * @param key * @return ICacheElement * @throws IOException */ @Override public ICacheElement<K, V> get( String cacheName, K key ) throws IOException { return get( cacheName, key, 0 ); }
/** * Create a request, process, extract the payload. * <p> * @param cacheName * @param key * @return ICacheElement * @throws IOException */ @Override public ICacheElement<K, V> get( String cacheName, K key ) throws IOException { return get( cacheName, key, 0 ); }
/** * Verify get functionality * <p> * @throws IOException */ public void testGet_nullFromDispatcher() 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"; mockDispatcher.setupRemoteCacheResponse = null; // DO WORK ICacheElement<String, String> result = client.get( cacheName, key ); // VERIFY assertNull( "Wrong result.", result ); assertEquals( "Wrong type.", RemoteRequestType.GET, mockDispatcher.lastRemoteCacheRequest .getRequestType() ); }
/** * Verify get functionality * <p> * @throws IOException */ public void testGet_nullFromDispatcher() 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"; mockDispatcher.setupRemoteCacheResponse = null; // DO WORK ICacheElement<String, String> result = client.get( cacheName, key ); // VERIFY assertNull( "Wrong result.", 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() ); }
/** * 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() ); }