🔖 v1.9.3,详细更新内容参考update.md
This commit is contained in:
32
src/test/java/me/zhyd/oauth/cache/AuthStateCacheTest.java
vendored
Normal file
32
src/test/java/me/zhyd/oauth/cache/AuthStateCacheTest.java
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
package me.zhyd.oauth.cache;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AuthStateCacheTest {
|
||||
|
||||
@Test
|
||||
public void cache1() throws InterruptedException {
|
||||
AuthStateCache.cache("key", "value");
|
||||
Assert.assertEquals(AuthStateCache.get("key"), "value");
|
||||
|
||||
TimeUnit.MILLISECONDS.sleep(4);
|
||||
Assert.assertEquals(AuthStateCache.get("key"), "value");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cache2() throws InterruptedException {
|
||||
AuthStateCache.cache("key", "value", 10);
|
||||
Assert.assertEquals(AuthStateCache.get("key"), "value");
|
||||
|
||||
// 没过期
|
||||
TimeUnit.MILLISECONDS.sleep(5);
|
||||
Assert.assertEquals(AuthStateCache.get("key"), "value");
|
||||
|
||||
// 过期
|
||||
TimeUnit.MILLISECONDS.sleep(6);
|
||||
Assert.assertNull(AuthStateCache.get("key"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user