remoteCacheClient.setElementSerializer( elementSerializer ); remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient ); remoteCacheNoWait.setCacheEventLogger( cacheEventLogger ); remoteCacheNoWait.setElementSerializer( elementSerializer );
remoteCacheClient.setElementSerializer( elementSerializer ); remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient ); remoteCacheNoWait.setCacheEventLogger( cacheEventLogger ); remoteCacheNoWait.setElementSerializer( elementSerializer );
/** * Simply verify that the client getMultiple is called from the no wait. * <p> * @throws Exception */ public void testGetMultiple() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( "testUpdate", "key", "value" ); Map<String, ICacheElement<String, String>> inputMap = new HashMap<String, ICacheElement<String,String>>(); inputMap.put( "key", inputElement ); Set<String> keys = new HashSet<String>(); keys.add( "key" ); client.getMultipleSetupMap.put( keys, inputMap ); // DO WORK Map<String, ICacheElement<String, String>> result = noWait.getMultiple( keys ); // VERIFY assertEquals( "elements map", inputMap, result ); }
/** * Simply verify that the client status is returned in the stats. * <p> * @throws Exception */ public void testGetStats() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); client.status = CacheStatus.ALIVE; RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); // DO WORK String result = noWait.getStats(); // VERIFY assertTrue( "Status should contain 'ALIVE'", result.indexOf( "ALIVE" ) != -1 ); }
/** * Simply verify that the client getMultiple is called from the no wait. * <p> * @throws Exception */ public void testGetMultiple() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( "testUpdate", "key", "value" ); Map<String, ICacheElement<String, String>> inputMap = new HashMap<String, ICacheElement<String,String>>(); inputMap.put( "key", inputElement ); Set<String> keys = new HashSet<String>(); keys.add( "key" ); client.getMultipleSetupMap.put( keys, inputMap ); // DO WORK Map<String, ICacheElement<String, String>> result = noWait.getMultiple( keys ); // VERIFY assertEquals( "elements map", inputMap, result ); }
/** * Simply verify that the client status is returned in the stats. * <p> * @throws Exception */ public void testGetStats() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); client.status = CacheStatus.ALIVE; RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); // DO WORK String result = noWait.getStats(); // VERIFY assertTrue( "Status should contain 'ALIVE'", result.indexOf( "ALIVE" ) != -1 ); }
/** * Simply verify that we get a status of error if the cache is in error.. * <p> * @throws Exception */ public void testGetStatus_error() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); client.status = CacheStatus.ERROR; RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); // DO WORK CacheStatus result = noWait.getStatus(); // VERIFY assertEquals( "Wrong status", CacheStatus.ERROR, result ); }
/** * Simply verify that we get a status of error if the cache is in error.. * <p> * @throws Exception */ public void testGetStatus_error() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); client.status = CacheStatus.ERROR; RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); // DO WORK CacheStatus result = noWait.getStatus(); // VERIFY assertEquals( "Wrong status", CacheStatus.ERROR, result ); }
/** * Simply verify that the client get is called from the no wait. * <p> * @throws Exception */ public void testGet() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> input = new CacheElement<String, String>( "testUpdate", "key", "value" ); client.getSetupMap.put( "key", input ); // DO WORK ICacheElement<String, String> result = noWait.get( "key" ); // VERIFY assertEquals( "Wrong element", input, result ); }
/** * Simply verify that the client gets updated via the no wait. * <p> * @throws Exception */ public void testRemove() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); String input = "MyKey"; // DO WORK noWait.remove( input ); SleepUtil.sleepAtLeast( 10 ); // VERIFY assertEquals( "Wrong number updated.", 1, client.removeList.size() ); assertEquals( "Wrong key", input, client.removeList.get( 0 ) ); }
/** * Simply verify that the client get is called from the no wait. * <p> * @throws Exception */ public void testGet() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> input = new CacheElement<String, String>( "testUpdate", "key", "value" ); client.getSetupMap.put( "key", input ); // DO WORK ICacheElement<String, String> result = noWait.get( "key" ); // VERIFY assertEquals( "Wrong element", input, result ); }
/** * Simply verify that the client gets updated via the no wait. * <p> * @throws Exception */ public void testRemove() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); String input = "MyKey"; // DO WORK noWait.remove( input ); SleepUtil.sleepAtLeast( 10 ); // VERIFY assertEquals( "Wrong number updated.", 1, client.removeList.size() ); assertEquals( "Wrong key", input, client.removeList.get( 0 ) ); }
remoteCacheClient.setElementSerializer( elementSerializer ); remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient ); remoteCacheNoWait.setCacheEventLogger( cacheEventLogger ); remoteCacheNoWait.setElementSerializer( elementSerializer );
/** * Simply verify that the client gets updated via the no wait. * <p> * @throws Exception */ public void testUpdate() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> element = new CacheElement<String, String>( "testUpdate", "key", "value" ); // DO WORK noWait.update( element ); // VERIFY SleepUtil.sleepAtLeast( 10 ); assertEquals( "Wrong number updated.", 1, client.updateList.size() ); assertEquals( "Wrong element", element, client.updateList.get( 0 ) ); }
/** * Verify that we can add an item. */ public void testAddNoWait_InList() { // SETUP List<RemoteCacheNoWait<String, String>> noWaits = new ArrayList<RemoteCacheNoWait<String,String>>(); IRemoteCacheAttributes cattr = new RemoteCacheAttributes(); cattr.setCacheName( "testCache1" ); RemoteCache<String, String> client = new RemoteCache<String, String>(cattr, null, null, null); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); noWaits.add( noWait ); RemoteCacheNoWaitFacade<String, String> facade = new RemoteCacheNoWaitFacade<String, String>(noWaits, cattr, null, null, null ); // VERIFY assertEquals( "Should have one entry.", 1, facade.noWaits.size() ); assertTrue( "Should be in the list.", facade.noWaits.contains( noWait ) ); assertSame( "Should have same facade.", facade, ((RemoteCache<String, String>)facade.noWaits.get(0).getRemoteCache()).getFacade() ); } }
/** * Simply verify that the client gets updated via the no wait. * <p> * @throws Exception */ public void testUpdate() throws Exception { // SETUP MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>(); RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client ); ICacheElement<String, String> element = new CacheElement<String, String>( "testUpdate", "key", "value" ); // DO WORK noWait.update( element ); // VERIFY SleepUtil.sleepAtLeast( 10 ); assertEquals( "Wrong number updated.", 1, client.updateList.size() ); assertEquals( "Wrong element", element, client.updateList.get( 0 ) ); }
remoteCacheClient.setElementSerializer( elementSerializer ); RemoteCacheNoWait<K, V> remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient ); remoteCacheNoWait.setCacheEventLogger( cacheEventLogger ); remoteCacheNoWait.setElementSerializer( elementSerializer );
RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );