Search in sources :

Example 1 with PrincipalCache

use of nl.uva.cs.lobcder.auth.PrincipalCache in project lobcder by skoulouzis.

the class PrincipalCacheTest method testCache.

@Test
public void testCache() throws InterruptedException {
    System.out.println("testCache");
    String token = "token";
    PrincipalCache instance = new PrincipalCache();
    MyPrincipal principal = getPrincipal("user1");
    instance.putPrincipal(token, principal, new Date().getTime() + 1000);
    Thread.sleep(500);
    MyPrincipal result = instance.getPrincipal(token);
    assertNotNull(result);
}
Also used : MyPrincipal(nl.uva.cs.lobcder.auth.MyPrincipal) Date(java.util.Date) PrincipalCache(nl.uva.cs.lobcder.auth.PrincipalCache) Test(org.junit.Test)

Example 2 with PrincipalCache

use of nl.uva.cs.lobcder.auth.PrincipalCache in project lobcder by skoulouzis.

the class PrincipalCacheTest method testCacheTimeout.

@Test
public void testCacheTimeout() throws InterruptedException {
    System.out.println("testCacheTimeout");
    String token = "token";
    PrincipalCache instance = new PrincipalCache();
    MyPrincipal principal = getPrincipal(token);
    instance.putPrincipal(token, principal, new Date().getTime() + 1000);
    Thread.sleep(1500);
    MyPrincipal result = instance.getPrincipal(token);
    assertNull(result);
}
Also used : MyPrincipal(nl.uva.cs.lobcder.auth.MyPrincipal) Date(java.util.Date) PrincipalCache(nl.uva.cs.lobcder.auth.PrincipalCache) Test(org.junit.Test)

Aggregations

Date (java.util.Date)2 MyPrincipal (nl.uva.cs.lobcder.auth.MyPrincipal)2 PrincipalCache (nl.uva.cs.lobcder.auth.PrincipalCache)2 Test (org.junit.Test)2