Search in sources :

Example 56 with Ehcache

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));
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) Element(net.sf.ehcache.Element) Ehcache(net.sf.ehcache.Ehcache) Test(org.junit.Test)

Example 57 with Ehcache

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);
}
Also used : Ehcache(net.sf.ehcache.Ehcache) Test(org.junit.Test)

Example 58 with Ehcache

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());
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) Ehcache(net.sf.ehcache.Ehcache) Test(org.junit.Test)

Example 59 with Ehcache

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());
}
Also used : Ehcache(net.sf.ehcache.Ehcache) Test(org.junit.Test)

Aggregations

Ehcache (net.sf.ehcache.Ehcache)59 Test (org.junit.Test)21 Element (net.sf.ehcache.Element)15 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)14 ResourcesElementsProvider (org.jasig.resourceserver.utils.aggr.ResourcesElementsProvider)9 Cache (net.sf.ehcache.Cache)7 CacheManager (net.sf.ehcache.CacheManager)7 CacheException (net.sf.ehcache.CacheException)6 Configuration (net.sf.ehcache.config.Configuration)5 DiskStoreConfiguration (net.sf.ehcache.config.DiskStoreConfiguration)5 CachedResource (org.apereo.portal.utils.cache.resource.CachedResource)5 CachingResourceLoaderImpl (org.apereo.portal.utils.cache.resource.CachingResourceLoaderImpl)5 LoadedResource (org.apereo.portal.utils.cache.resource.LoadedResource)5 CacheKey (org.apereo.portal.utils.cache.CacheKey)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 Resource (org.springframework.core.io.Resource)4 UserDetails (org.springframework.security.core.userdetails.UserDetails)4 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 FileReader (java.io.FileReader)3