@Test
public void testAuthorizeWithCacheRefreshOnRemovedRole() {
RuntimeAuthorizationManager authorizationManager = new RuntimeAuthorizationManager();
RuntimeResource resource = new TestRuntimeResource("test1234", "admin", "author");
Subject john = new TestIdentity("john", "admin");
Subject mary = new TestIdentity("mary", "author");
assertTrue(resource instanceof Cacheable);
assertTrue(((Cacheable) resource).requiresRefresh());
boolean authorized = authorizationManager.authorize(resource, john);
assertTrue(authorized);
assertFalse(((Cacheable) resource).requiresRefresh());
authorized = authorizationManager.authorize(resource, mary);
assertTrue(authorized);
// now simulate remove of a role for the resource
RuntimeResource resource2 = new TestRuntimeResource("test1234", "author");
assertTrue(((Cacheable) resource2).requiresRefresh());
authorized = authorizationManager.authorize(resource2, john);
assertFalse(authorized);