/** * Removes the given key from the specified cache. * <p> * @param cacheName * @param key * @param requesterId * @throws IOException */ @Override public void remove( String cacheName, K key, long requesterId ) throws IOException { if ( !isInitialized() ) { String message = "The Remote Http Client is not initialized. Cannot process request."; log.warn( message ); throw new IOException( message ); } RemoteCacheRequest<K, V> remoteHttpCacheRequest = RemoteCacheRequestFactory.createRemoveRequest( cacheName, key, requesterId ); getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest ); }
/** * Removes the given key from the specified cache. * <p> * @param cacheName * @param key * @param requesterId * @throws IOException */ @Override public void remove( String cacheName, K key, long requesterId ) throws IOException { if ( !isInitialized() ) { String message = "The Remote Http Client is not initialized. Cannot process request."; log.warn( message ); throw new IOException( message ); } RemoteCacheRequest<K, V> remoteHttpCacheRequest = RemoteCacheRequestFactory.createRemoveRequest( cacheName, key, requesterId ); getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest ); }
/** Verify that the service is called. */ public void testProcessRequest_Remove() { String cacheName = "test"; Serializable key = "key"; long requesterId = 2; RemoteCacheRequest<Serializable, Serializable> request = RemoteCacheRequestFactory.createRemoveRequest( cacheName, key, requesterId ); // DO WORK RemoteCacheResponse<Object> result = servlet.processRequest( request ); // VERIFY assertNotNull( "Should have a result.", result ); assertEquals( "Wrong key.", key, remoteHttpCacheService.lastRemoveKey ); }
/** Simple test */ public void testCreateRemoveRequest_Normal() { // SETUP String cacheName = "test"; Serializable key = "key"; long requesterId = 2; // DO WORK RemoteCacheRequest<Serializable, Serializable> result = RemoteCacheRequestFactory .createRemoveRequest( cacheName, key, requesterId ); // VERIFY assertNotNull( "Should have a result", result ); assertEquals( "Wrong cacheName", cacheName, result.getCacheName() ); assertEquals( "Wrong type", RemoteRequestType.REMOVE, result.getRequestType() ); }
/** Simple test */ public void testCreateRemoveRequest_Normal() { // SETUP String cacheName = "test"; Serializable key = "key"; long requesterId = 2; // DO WORK RemoteCacheRequest<Serializable, Serializable> result = RemoteCacheRequestFactory .createRemoveRequest( cacheName, key, requesterId ); // VERIFY assertNotNull( "Should have a result", result ); assertEquals( "Wrong cacheName", cacheName, result.getCacheName() ); assertEquals( "Wrong type", RemoteRequestType.REMOVE, result.getRequestType() ); }
/** Verify that the service is called. */ public void testProcessRequest_Remove() { // SETUP RemoteCacheServiceAdaptor<String, String> adaptor = new RemoteCacheServiceAdaptor<String, String>(); MockRemoteCacheService<String, String> remoteHttpCacheService = new MockRemoteCacheService<String, String>(); adaptor.setRemoteCacheService( remoteHttpCacheService ); String cacheName = "test"; String key = "key"; long requesterId = 2; RemoteCacheRequest<String, String> request = RemoteCacheRequestFactory.createRemoveRequest( cacheName, key, requesterId ); // DO WORK RemoteCacheResponse<String> result = adaptor.processRequest( request ); // VERIFY assertNotNull( "Should have a result.", result ); assertEquals( "Wrong key.", key, remoteHttpCacheService.lastRemoveKey ); }