Skip to content

Commit

Permalink
✅ 修改 cache 测试类
Browse files Browse the repository at this point in the history
  • Loading branch information
xkcoding committed Aug 2, 2019
1 parent bed01ee commit c1f9e96
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/test/java/me/zhyd/oauth/cache/AuthStateCacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ public class AuthStateCacheTest {

@Test
public void cache1() throws InterruptedException {
AuthStateCache.cache("key", "value");
Assert.assertEquals(AuthStateCache.get("key"), "value");
AuthDefaultStateCache.INSTANCE.cache("key", "value");
Assert.assertEquals(AuthDefaultStateCache.INSTANCE.get("key"), "value");

TimeUnit.MILLISECONDS.sleep(4);
Assert.assertEquals(AuthStateCache.get("key"), "value");
Assert.assertEquals(AuthDefaultStateCache.INSTANCE.get("key"), "value");
}

@Test
public void cache2() throws InterruptedException {
AuthStateCache.cache("key", "value", 10);
Assert.assertEquals(AuthStateCache.get("key"), "value");
AuthDefaultStateCache.INSTANCE.cache("key", "value", 10);
Assert.assertEquals(AuthDefaultStateCache.INSTANCE.get("key"), "value");

// 没过期
TimeUnit.MILLISECONDS.sleep(5);
Assert.assertEquals(AuthStateCache.get("key"), "value");
Assert.assertEquals(AuthDefaultStateCache.INSTANCE.get("key"), "value");

// 过期
TimeUnit.MILLISECONDS.sleep(6);
Assert.assertNull(AuthStateCache.get("key"));
Assert.assertNull(AuthDefaultStateCache.INSTANCE.get("key"));
}
}

0 comments on commit c1f9e96

Please sign in to comment.