public void evictFromCache(Serializable pk) { Assert.notNull(pk, "Primary key (identifier) required"); MutableAcl acl = getFromCache(pk); if (acl != null) { cache.remove(acl.getId()); cache.remove(acl.getObjectIdentity()); } }
public void evictFromCache(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "ObjectIdentity required"); MutableAcl acl = getFromCache(objectIdentity); if (acl != null) { cache.remove(acl.getId()); cache.remove(acl.getObjectIdentity()); } }
@Test public void getFromCacheObjectIdentity() throws Exception { when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); assertThat(myCache.getFromCache(acl.getId())).isEqualTo(acl); }
@Test public void getFromCacheSerializable() throws Exception { when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); assertThat(myCache.getFromCache(acl.getId())).isEqualTo(acl); }
@Test public void getFromCacheSerializablePopulatesTransient() throws Exception { when(cache.get(acl.getId())).thenReturn(new Element(acl.getId(), acl)); myCache.putInCache(acl); ReflectionTestUtils.setField(acl, "permissionGrantingStrategy", null); ReflectionTestUtils.setField(acl, "aclAuthorizationStrategy", null); MutableAcl fromCache = myCache.getFromCache(acl.getId()); assertThat(ReflectionTestUtils.getField(fromCache, "aclAuthorizationStrategy")) .isNotNull(); assertThat(ReflectionTestUtils.getField(fromCache, "permissionGrantingStrategy")) .isNotNull(); }
@Test public void getFromCacheObjectIdentityPopulatesTransient() throws Exception { when(cache.get(acl.getObjectIdentity())) .thenReturn(new Element(acl.getId(), acl)); myCache.putInCache(acl); ReflectionTestUtils.setField(acl, "permissionGrantingStrategy", null); ReflectionTestUtils.setField(acl, "aclAuthorizationStrategy", null); MutableAcl fromCache = myCache.getFromCache(acl.getObjectIdentity()); assertThat(ReflectionTestUtils.getField(fromCache, "aclAuthorizationStrategy")) .isNotNull(); assertThat(ReflectionTestUtils.getField(fromCache, "permissionGrantingStrategy")) .isNotNull(); }
myCache.getFromCache(id); fail("It should have thrown IllegalArgumentException"); myCache.getFromCache(obj); fail("It should have thrown IllegalArgumentException");
public void evictFromCache(Serializable pk) { Assert.notNull(pk, "Primary key (identifier) required"); MutableAcl acl = getFromCache(pk); if (acl != null) { cache.remove(acl.getId()); cache.remove(acl.getObjectIdentity()); } }
public void evictFromCache(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "ObjectIdentity required"); MutableAcl acl = getFromCache(objectIdentity); if (acl != null) { cache.remove(acl.getId()); cache.remove(acl.getObjectIdentity()); } }