[ACS-9167] Clear more caches

This commit is contained in:
cezary-witkowski
2025-03-21 17:11:38 +01:00
parent 0c17a1c617
commit 0e5b66c637

View File

@@ -29,9 +29,7 @@ import static org.junit.Assert.assertEquals;
import java.io.Serializable; import java.io.Serializable;
import java.time.Duration; import java.time.Duration;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.UUID;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@@ -42,7 +40,6 @@ import org.springframework.context.ApplicationContext;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.cache.TransactionalCache; import org.alfresco.repo.cache.TransactionalCache;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.permissions.AccessControlList;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
@@ -59,6 +56,7 @@ import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.testing.category.DBTests; import org.alfresco.util.testing.category.DBTests;
@Category({OwnJVMTestsCategory.class, DBTests.class}) @Category({OwnJVMTestsCategory.class, DBTests.class})
@SuppressWarnings({"PMD.JUnitTestsShouldIncludeAssert"})
public class ACS9167Test public class ACS9167Test
{ {
private NodeService nodeService; private NodeService nodeService;
@@ -67,11 +65,6 @@ public class ACS9167Test
private TransactionService transactionService; private TransactionService transactionService;
private RetryingTransactionHelper txnHelper; private RetryingTransactionHelper txnHelper;
private TransactionalCache<Serializable, AccessControlList> aclCache;
private TransactionalCache<Serializable, Object> aclEntityCache;
private TransactionalCache<Serializable, Object> permissionEntityCache;
private TransactionalCache<Serializable, Object> nodeOwnerCache;
@Before @Before
public void setUp() throws Exception public void setUp() throws Exception
{ {
@@ -81,7 +74,6 @@ public class ACS9167Test
txnHelper.setReadOnly(false); txnHelper.setReadOnly(false);
txnHelper.setMaxRetries(1); txnHelper.setMaxRetries(1);
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
dropCaches();
} }
private void setupServices() private void setupServices()
@@ -91,18 +83,20 @@ public class ACS9167Test
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
pubSearchService = (SearchService) ctx.getBean("SearchService"); pubSearchService = (SearchService) ctx.getBean("SearchService");
transactionService = (TransactionService) ctx.getBean("TransactionService"); transactionService = (TransactionService) ctx.getBean("TransactionService");
aclCache = (TransactionalCache) ctx.getBean("aclCache");
aclEntityCache = (TransactionalCache) ctx.getBean("aclEntityCache");
permissionEntityCache = (TransactionalCache) ctx.getBean("permissionEntityCache");
nodeOwnerCache = (TransactionalCache) ctx.getBean("nodeOwnerCache");
}
private void dropCaches() List<TransactionalCache<?, ?>> cachesToClear = new ArrayList<>();
{ cachesToClear.add((TransactionalCache<?, ?>) ctx.getBean("propertyValueCache"));
aclCache.clear(); cachesToClear.add((TransactionalCache<?, ?>) ctx.getBean("node.nodesCache"));
aclEntityCache.clear(); cachesToClear.add((TransactionalCache<?, ?>) ctx.getBean("node.propertiesCache"));
permissionEntityCache.clear(); cachesToClear.add((TransactionalCache<?, ?>) ctx.getBean("aclCache"));
nodeOwnerCache.clear(); cachesToClear.add((TransactionalCache<?, ?>) ctx.getBean("aclEntityCache"));
cachesToClear.add((TransactionalCache<?, ?>) ctx.getBean("permissionEntityCache"));
cachesToClear.add((TransactionalCache<?, ?>) ctx.getBean("nodeOwnerCache"));
for (TransactionalCache<?, ?> transactionalCache : cachesToClear)
{
transactionalCache.clear();
}
} }
@After @After
@@ -182,7 +176,7 @@ public class ACS9167Test
sp.setSkipCount(parameterSkipCount); sp.setSkipCount(parameterSkipCount);
sp.setMaxItems(parameterMaxItems); sp.setMaxItems(parameterMaxItems);
sp.setMaxPermissionChecks(Integer.MAX_VALUE); sp.setMaxPermissionChecks(Integer.MAX_VALUE);
sp.setMaxPermissionCheckTimeMillis(Duration.ofMinutes(2).toMillis()); sp.setMaxPermissionCheckTimeMillis(Duration.ofMinutes(10).toMillis());
// when // when
ResultSet resultSet = pubSearchService.query(sp); ResultSet resultSet = pubSearchService.query(sp);
// then // then