use of net.sf.ehcache.Ehcache in project pentaho-platform by pentaho.
the class PentahoEhCacheBasedUserCacheTest method testPutUserInCacheCaseInsensitive.
@Test
public void testPutUserInCacheCaseInsensitive() {
PentahoEhCacheBasedUserCache userCache = new PentahoEhCacheBasedUserCache();
UserDetails userDetails = mock(UserDetails.class);
Ehcache ehcache = mock(Ehcache.class);
String username = "USERNAME";
userCache.setCaseSensitive(false);
userCache.setCache(ehcache);
when(userDetails.getUsername()).thenReturn(username);
userCache.putUserInCache(userDetails);
verify(ehcache, times(1)).put(new Element(username.toLowerCase(), userDetails));
}
use of net.sf.ehcache.Ehcache in project pentaho-platform by pentaho.
the class PentahoEhCacheBasedUserCacheTest method testRemoveUserFromCacheCaseSensitive.
@Test
public void testRemoveUserFromCacheCaseSensitive() {
PentahoEhCacheBasedUserCache userCache = new PentahoEhCacheBasedUserCache();
Ehcache ehcache = mock(Ehcache.class);
String username = "USERNAME";
userCache.setCaseSensitive(true);
userCache.setCache(ehcache);
userCache.removeUserFromCache(username);
verify(ehcache, times(1)).remove(username);
}
use of net.sf.ehcache.Ehcache in project pentaho-platform by pentaho.
the class PentahoEhCacheBasedUserCacheTest method testGetUserFromCacheCaseInsensitive.
@Test
public void testGetUserFromCacheCaseInsensitive() {
PentahoEhCacheBasedUserCache userCache = new PentahoEhCacheBasedUserCache();
UserDetails userDetails = mock(UserDetails.class);
Ehcache ehcache = mock(Ehcache.class);
String username = "USERNAME";
userCache.setCaseSensitive(false);
userCache.setCache(ehcache);
assertEquals(null, userCache.getUserFromCache(username));
verify(ehcache, times(1)).get(username.toLowerCase());
}
use of net.sf.ehcache.Ehcache in project pentaho-platform by pentaho.
the class PentahoEhCacheBasedUserCacheTest method testRemoveUserFromCacheCaseInsensitive.
@Test
public void testRemoveUserFromCacheCaseInsensitive() {
PentahoEhCacheBasedUserCache userCache = new PentahoEhCacheBasedUserCache();
Ehcache ehcache = mock(Ehcache.class);
String username = "USERNAME";
userCache.setCaseSensitive(false);
userCache.setCache(ehcache);
userCache.removeUserFromCache(username);
verify(ehcache, times(1)).remove(username.toLowerCase());
}
Aggregations