Skip to content

Commit

Permalink
added test for issue hazelcast#670
Browse files Browse the repository at this point in the history
  • Loading branch information
notz committed Aug 14, 2013
1 parent a508cf6 commit f1e6671
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions hazelcast/src/test/java/com/hazelcast/core/HazelcastTest.java
Expand Up @@ -22,6 +22,7 @@
import com.hazelcast.config.NearCacheConfig;
import com.hazelcast.util.Clock;
import com.hazelcast.impl.GroupProperties;

import org.junit.*;
import org.junit.runner.RunWith;

Expand Down Expand Up @@ -1424,6 +1425,35 @@ public void testIssue585SetWithoutTtl() throws InterruptedException {
assertEquals(1, map.size());
h.getLifecycleService().shutdown();
}

/*
* github issue 670
*/
@Test
public void testIssue670PutTtl() throws Exception {
Config config = new Config();
MapConfig mapConfig = new MapConfig("ttl-test");
mapConfig.setTimeToLiveSeconds(5);
config.addMapConfig(mapConfig);

HazelcastInstance h = Hazelcast.newHazelcastInstance(config);
IMap<Integer, Boolean> imap = h.getMap("ttl-test");
HashMap<Integer, Boolean> putAllEntries = new HashMap<Integer, Boolean>();
putAllEntries.put(1, true);
putAllEntries.put(2, false);
imap.putAll(putAllEntries);
imap.put(3, true);
imap.put(4, false, 5, TimeUnit.SECONDS);
imap.put(5, false, 35, TimeUnit.SECONDS);
imap.put(6, false, 0, TimeUnit.SECONDS);
Thread.sleep(10000);
assertTrue("putAll entries should have been evicted", !imap.containsKey(1));
assertTrue("put entry should have been evicted", !imap.containsKey(3));
assertTrue("put entry with ttl should have been evicted", !imap.containsKey(4));
assertTrue("put entry with long ttl should not have been evicted", imap.containsKey(5));
assertTrue("put entry with zero ttl should not have been evicted", imap.containsKey(6));
h.getLifecycleService().shutdown();
}

/*
github issue 304
Expand Down

0 comments on commit f1e6671

Please sign in to comment.