Advertisement
tpeierls

AsyncTtlIMapTest.java

May 31st, 2011
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.93 KB | None | 0 0
  1. package com.hazelcast.util;
  2.  
  3. import com.hazelcast.core.Hazelcast;
  4.  
  5. import java.util.concurrent.ExecutionException;
  6. import java.util.concurrent.Future;
  7. import java.util.concurrent.TimeUnit;
  8.  
  9. import org.junit.*;
  10. import org.junit.runner.*;
  11. import static org.junit.Assert.*;
  12.  
  13. public class AsyncTtlIMapTest {
  14.  
  15.     @After public void shutdown() {
  16.         Hazelcast.shutdownAll();
  17.     }
  18.  
  19.     @Test public void testPutAsync() throws ExecutionException, InterruptedException {
  20.         AsyncTtlIMap<String, Integer> testMap = AsyncTtlIMaps.getMap("testMap");
  21.         testMap.put("a", 42);
  22.         Future<Integer> f = testMap.putAsync("a", 111, 2, TimeUnit.SECONDS);
  23.         Integer i = f.get();
  24.         assertNotNull(i);
  25.         assertEquals(42, (int) i);
  26.         TimeUnit.SECONDS.sleep(3);
  27.         Future<Integer> f2 = testMap.putAsync("a", 123, 2, TimeUnit.SECONDS);
  28.         Integer i2 = f2.get();
  29.         assertNull(i2);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement