aboutsummaryrefslogtreecommitdiffstats
path: root/guava-tests/test/com/google/common/cache/CacheExpirationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'guava-tests/test/com/google/common/cache/CacheExpirationTest.java')
-rw-r--r--guava-tests/test/com/google/common/cache/CacheExpirationTest.java54
1 files changed, 27 insertions, 27 deletions
diff --git a/guava-tests/test/com/google/common/cache/CacheExpirationTest.java b/guava-tests/test/com/google/common/cache/CacheExpirationTest.java
index a2dd701..97677cf 100644
--- a/guava-tests/test/com/google/common/cache/CacheExpirationTest.java
+++ b/guava-tests/test/com/google/common/cache/CacheExpirationTest.java
@@ -18,7 +18,7 @@ import static com.google.common.cache.TestingCacheLoaders.identityLoader;
import static com.google.common.cache.TestingRemovalListeners.countingRemovalListener;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.truth0.Truth.ASSERT;
+import static org.junit.contrib.truth.Truth.ASSERT;
import com.google.common.cache.TestingCacheLoaders.IdentityLoader;
import com.google.common.cache.TestingRemovalListeners.CountingRemovalListener;
@@ -252,7 +252,7 @@ public class CacheExpirationTest extends TestCase {
IdentityLoader<Integer> loader = identityLoader();
LoadingCache<Integer, Integer> cache = CacheBuilder.newBuilder()
.concurrencyLevel(1)
- .expireAfterAccess(11, MILLISECONDS)
+ .expireAfterAccess(10, MILLISECONDS)
.ticker(ticker)
.build(loader);
for (int i = 0; i < 10; i++) {
@@ -260,42 +260,42 @@ public class CacheExpirationTest extends TestCase {
ticker.advance(1, MILLISECONDS);
}
Set<Integer> keySet = cache.asMap().keySet();
- ASSERT.that(keySet).has().allOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
// 0 expires
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(1, 2, 3, 4, 5, 6, 7, 8, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(1, 2, 3, 4, 5, 6, 7, 8, 9);
// reorder
getAll(cache, asList(0, 1, 2));
CacheTesting.drainRecencyQueues(cache);
ticker.advance(2, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(3, 4, 5, 6, 7, 8, 9, 0, 1, 2);
+ ASSERT.that(keySet).hasContentsAnyOrder(3, 4, 5, 6, 7, 8, 9, 0, 1, 2);
// 3 expires
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(4, 5, 6, 7, 8, 9, 0, 1, 2);
+ ASSERT.that(keySet).hasContentsAnyOrder(4, 5, 6, 7, 8, 9, 0, 1, 2);
// reorder
getAll(cache, asList(5, 7, 9));
CacheTesting.drainRecencyQueues(cache);
- ASSERT.that(keySet).has().allOf(4, 6, 8, 0, 1, 2, 5, 7, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(4, 6, 8, 0, 1, 2, 5, 7, 9);
// 4 expires
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(6, 8, 0, 1, 2, 5, 7, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(6, 8, 0, 1, 2, 5, 7, 9);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(6, 8, 0, 1, 2, 5, 7, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(6, 8, 0, 1, 2, 5, 7, 9);
// 6 expires
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(8, 0, 1, 2, 5, 7, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(8, 0, 1, 2, 5, 7, 9);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(8, 0, 1, 2, 5, 7, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(8, 0, 1, 2, 5, 7, 9);
// 8 expires
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(0, 1, 2, 5, 7, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(0, 1, 2, 5, 7, 9);
}
public void testExpirationOrder_write() throws ExecutionException {
@@ -304,7 +304,7 @@ public class CacheExpirationTest extends TestCase {
IdentityLoader<Integer> loader = identityLoader();
LoadingCache<Integer, Integer> cache = CacheBuilder.newBuilder()
.concurrencyLevel(1)
- .expireAfterWrite(11, MILLISECONDS)
+ .expireAfterWrite(10, MILLISECONDS)
.ticker(ticker)
.build(loader);
for (int i = 0; i < 10; i++) {
@@ -312,37 +312,37 @@ public class CacheExpirationTest extends TestCase {
ticker.advance(1, MILLISECONDS);
}
Set<Integer> keySet = cache.asMap().keySet();
- ASSERT.that(keySet).has().allOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
// 0 expires
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(1, 2, 3, 4, 5, 6, 7, 8, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(1, 2, 3, 4, 5, 6, 7, 8, 9);
// get doesn't stop 1 from expiring
getAll(cache, asList(0, 1, 2));
CacheTesting.drainRecencyQueues(cache);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(2, 3, 4, 5, 6, 7, 8, 9, 0);
+ ASSERT.that(keySet).hasContentsAnyOrder(2, 3, 4, 5, 6, 7, 8, 9, 0);
// get(K, Callable) doesn't stop 2 from expiring
cache.get(2, Callables.returning(-2));
CacheTesting.drainRecencyQueues(cache);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(3, 4, 5, 6, 7, 8, 9, 0);
+ ASSERT.that(keySet).hasContentsAnyOrder(3, 4, 5, 6, 7, 8, 9, 0);
// asMap.put saves 3
cache.asMap().put(3, -3);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(4, 5, 6, 7, 8, 9, 0, 3);
+ ASSERT.that(keySet).hasContentsAnyOrder(4, 5, 6, 7, 8, 9, 0, 3);
// asMap.replace saves 4
cache.asMap().replace(4, -4);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(5, 6, 7, 8, 9, 0, 3, 4);
+ ASSERT.that(keySet).hasContentsAnyOrder(5, 6, 7, 8, 9, 0, 3, 4);
// 5 expires
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(6, 7, 8, 9, 0, 3, 4);
+ ASSERT.that(keySet).hasContentsAnyOrder(6, 7, 8, 9, 0, 3, 4);
}
public void testExpirationOrder_writeAccess() throws ExecutionException {
@@ -351,8 +351,8 @@ public class CacheExpirationTest extends TestCase {
IdentityLoader<Integer> loader = identityLoader();
LoadingCache<Integer, Integer> cache = CacheBuilder.newBuilder()
.concurrencyLevel(1)
- .expireAfterWrite(5, MILLISECONDS)
- .expireAfterAccess(3, MILLISECONDS)
+ .expireAfterWrite(4, MILLISECONDS)
+ .expireAfterAccess(2, MILLISECONDS)
.ticker(ticker)
.build(loader);
for (int i = 0; i < 5; i++) {
@@ -365,33 +365,33 @@ public class CacheExpirationTest extends TestCase {
ticker.advance(1, MILLISECONDS);
Set<Integer> keySet = cache.asMap().keySet();
- ASSERT.that(keySet).has().allOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+ ASSERT.that(keySet).hasContentsAnyOrder(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
// get saves 1, 3; 0, 2, 4 expire
getAll(cache, asList(1, 3));
CacheTesting.drainRecencyQueues(cache);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(5, 6, 7, 8, 9, 1, 3);
+ ASSERT.that(keySet).hasContentsAnyOrder(5, 6, 7, 8, 9, 1, 3);
// get saves 6, 8; 5, 7, 9 expire
getAll(cache, asList(6, 8));
CacheTesting.drainRecencyQueues(cache);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(1, 3, 6, 8);
+ ASSERT.that(keySet).hasContentsAnyOrder(1, 3, 6, 8);
// get fails to save 1, put saves 3
cache.asMap().put(3, -3);
getAll(cache, asList(1));
CacheTesting.drainRecencyQueues(cache);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(6, 8, 3);
+ ASSERT.that(keySet).hasContentsAnyOrder(6, 8, 3);
// get(K, Callable) fails to save 8, replace saves 6
cache.asMap().replace(6, -6);
cache.get(8, Callables.returning(-8));
CacheTesting.drainRecencyQueues(cache);
ticker.advance(1, MILLISECONDS);
- ASSERT.that(keySet).has().allOf(3, 6);
+ ASSERT.that(keySet).hasContentsAnyOrder(3, 6);
}
private void runRemovalScheduler(LoadingCache<String, Integer> cache,