Skip to content

Commit 89afa05

Browse files
committed
✅ Adding tests.
1 parent a59792b commit 89afa05

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/com/crossoverjie/guava/CacheLoaderTest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class CacheLoaderTest {
3131
private void init() throws InterruptedException {
3232
loadingCache = CacheBuilder.newBuilder()
3333
.expireAfterWrite(2, TimeUnit.SECONDS)
34-
.maximumSize(3)
3534

3635
.build(new CacheLoader<Integer, AtomicLong>() {
3736
@Override
@@ -49,9 +48,9 @@ public AtomicLong load(Integer key) throws Exception {
4948
private void checkAlert(Integer integer) {
5049
try {
5150

52-
loadingCache.put(integer,new AtomicLong(integer));
51+
//loadingCache.put(integer,new AtomicLong(integer));
5352

54-
//TimeUnit.SECONDS.sleep(5);
53+
TimeUnit.SECONDS.sleep(5);
5554

5655

5756
LOGGER.info("当前缓存值={},缓存大小={}", loadingCache.get(KEY),loadingCache.size());
@@ -60,6 +59,8 @@ private void checkAlert(Integer integer) {
6059

6160
} catch (ExecutionException e ) {
6261
LOGGER.error("Exception", e);
62+
} catch (InterruptedException e) {
63+
e.printStackTrace();
6364
}
6465
}
6566
public static void main(String[] args) throws InterruptedException {

0 commit comments

Comments
 (0)