Extracted removeUserFromCache(String) to UserCache interface.
This commit is contained in:
@@ -54,4 +54,20 @@ public interface UserCache {
|
||||
* cache
|
||||
*/
|
||||
public void putUserInCache(UserDetails user);
|
||||
|
||||
/**
|
||||
* Removes the specified user from the cache. The <code>username</code> is
|
||||
* the key used to remove the user. If the user is not found, the method
|
||||
* should simply return (not thrown an exception).
|
||||
*
|
||||
* <P>
|
||||
* Some cache implementations may not support eviction from the cache, in
|
||||
* which case they should provide appropriate behaviour to alter the user
|
||||
* in either its documentation, via an exception, or through a log
|
||||
* message.
|
||||
* </p>
|
||||
*
|
||||
* @param username to be evicted from the cache
|
||||
*/
|
||||
public void removeUserFromCache(String username);
|
||||
}
|
||||
|
||||
@@ -33,4 +33,6 @@ public class NullUserCache implements UserCache {
|
||||
}
|
||||
|
||||
public void putUserInCache(UserDetails user) {}
|
||||
|
||||
public void removeUserFromCache(String username) {}
|
||||
}
|
||||
|
||||
@@ -354,5 +354,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
||||
public void putUserInCache(UserDetails user) {
|
||||
cache.put(user.getUsername(), user);
|
||||
}
|
||||
|
||||
public void removeUserFromCache(String username) {}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -53,6 +53,7 @@ public class NullUserCacheTests extends TestCase {
|
||||
NullUserCache cache = new NullUserCache();
|
||||
cache.putUserInCache(getUser());
|
||||
assertNull(cache.getUserFromCache(null));
|
||||
cache.removeUserFromCache(null);
|
||||
}
|
||||
|
||||
private User getUser() {
|
||||
|
||||
Reference in New Issue
Block a user