mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test
This commit is contained in:
parent
26c4a44adc
commit
2af4333ea1
@ -1,5 +1,6 @@
|
|||||||
package cn.hutool.core.lang;
|
package cn.hutool.core.lang;
|
||||||
|
|
||||||
|
import cn.hutool.core.thread.ConcurrencyTester;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -43,4 +44,17 @@ public class SimpleCacheTest {
|
|||||||
Assert.assertEquals("value5", cache.get("key5"));
|
Assert.assertEquals("value5", cache.get("key5"));
|
||||||
Assert.assertEquals("value6", cache.get("key6", ()-> "value6"));
|
Assert.assertEquals("value6", cache.get("key6", ()-> "value6"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getConcurrencyTest(){
|
||||||
|
final SimpleCache<String, String> cache = new SimpleCache<>();
|
||||||
|
final ConcurrencyTester tester = new ConcurrencyTester(9000);
|
||||||
|
tester.test(()-> cache.get("aaa", ()-> {
|
||||||
|
ThreadUtil.sleep(1000);
|
||||||
|
return "aaaValue";
|
||||||
|
}));
|
||||||
|
|
||||||
|
Assert.assertTrue(tester.getInterval() > 0);
|
||||||
|
Assert.assertEquals("aaaValue", cache.get("aaa"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user