@Test(expected = UnsupportedTokenException.class) public void beforeAttemptRealmDoesntSupportToken() { Realm notSupportingRealm = new AuthorizingRealm() { public boolean supports(AuthenticationToken token) { return false; } protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { return null; } protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principal) { return null; } }; strategy.beforeAttempt(notSupportingRealm, null, null); }