1
0
mirror of synced 2026-04-21 00:48:37 +08:00

🔖 v1.9.3,详细更新内容参考update.md

This commit is contained in:
yadong.zhang
2019-07-30 09:12:28 +08:00
parent a2d6dfe707
commit 33076971fe
33 changed files with 561 additions and 30 deletions

View 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"));
}
}