Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hazelcast.util;
- import com.hazelcast.core.Hazelcast;
- import java.util.concurrent.ExecutionException;
- import java.util.concurrent.Future;
- import java.util.concurrent.TimeUnit;
- import org.junit.*;
- import org.junit.runner.*;
- import static org.junit.Assert.*;
- public class AsyncTtlIMapTest {
- @After public void shutdown() {
- Hazelcast.shutdownAll();
- }
- @Test public void testPutAsync() throws ExecutionException, InterruptedException {
- AsyncTtlIMap<String, Integer> testMap = AsyncTtlIMaps.getMap("testMap");
- testMap.put("a", 42);
- Future<Integer> f = testMap.putAsync("a", 111, 2, TimeUnit.SECONDS);
- Integer i = f.get();
- assertNotNull(i);
- assertEquals(42, (int) i);
- TimeUnit.SECONDS.sleep(3);
- Future<Integer> f2 = testMap.putAsync("a", 123, 2, TimeUnit.SECONDS);
- Integer i2 = f2.get();
- assertNull(i2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement