change test and fix Spring bug

This commit is contained in:
Looly
2021-06-13 23:46:45 +08:00
parent 5fe634935d
commit 878c0169ea
7 changed files with 54 additions and 20 deletions

View File

@@ -1,6 +1,5 @@
package cn.hutool.cache.test;
package cn.hutool.cache;
import cn.hutool.cache.Cache;
import cn.hutool.cache.impl.FIFOCache;
import cn.hutool.cache.impl.LRUCache;
import cn.hutool.cache.impl.WeakCache;

View File

@@ -1,10 +1,9 @@
package cn.hutool.cache.test;
package cn.hutool.cache;
import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.RandomUtil;
import org.junit.Assert;
import org.junit.Test;
@@ -34,6 +33,15 @@ public class CacheTest {
Assert.assertNull(value1);
}
@Test
public void fifoCacheCapacityTest(){
Cache<String,String> fifoCache = CacheUtil.newFIFOCache(100);
for (int i = 0; i < RandomUtil.randomInt(100, 1000); i++) {
fifoCache.put("key" + i, "value" + i);
}
Assert.assertEquals(100, fifoCache.size());
}
@Test
public void lfuCacheTest(){
Cache<String, String> lfuCache = CacheUtil.newLFUCache(3);

View File

@@ -1,4 +1,4 @@
package cn.hutool.cache.test;
package cn.hutool.cache;
import org.junit.Assert;
import org.junit.Test;