mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
[ACS-9167] Improved integration test
This commit is contained in:
@@ -25,13 +25,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.search.impl.querymodel.impl.db;
|
package org.alfresco.repo.search.impl.querymodel.impl.db;
|
||||||
|
|
||||||
|
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.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
@@ -55,10 +59,8 @@ 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})
|
||||||
public class ACS9167Test extends TestCase
|
public class ACS9167Test
|
||||||
{
|
{
|
||||||
private ApplicationContext ctx;
|
|
||||||
|
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
private SearchService pubSearchService;
|
private SearchService pubSearchService;
|
||||||
@@ -70,7 +72,7 @@ public class ACS9167Test extends TestCase
|
|||||||
private TransactionalCache<Serializable, Object> permissionEntityCache;
|
private TransactionalCache<Serializable, Object> permissionEntityCache;
|
||||||
private TransactionalCache<Serializable, Object> nodeOwnerCache;
|
private TransactionalCache<Serializable, Object> nodeOwnerCache;
|
||||||
|
|
||||||
@Override
|
@Before
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
setupServices();
|
setupServices();
|
||||||
@@ -84,7 +86,7 @@ public class ACS9167Test extends TestCase
|
|||||||
|
|
||||||
private void setupServices()
|
private void setupServices()
|
||||||
{
|
{
|
||||||
ctx = ApplicationContextHelper.getApplicationContext();
|
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
||||||
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
||||||
pubSearchService = (SearchService) ctx.getBean("SearchService");
|
pubSearchService = (SearchService) ctx.getBean("SearchService");
|
||||||
@@ -103,12 +105,13 @@ public class ACS9167Test extends TestCase
|
|||||||
nodeOwnerCache.clear();
|
nodeOwnerCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@After
|
||||||
protected void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
authenticationComponent.clearCurrentSecurityContext();
|
authenticationComponent.clearCurrentSecurityContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testPagination()
|
public void testPagination()
|
||||||
{
|
{
|
||||||
String searchMarker = UUID.randomUUID().toString();
|
String searchMarker = UUID.randomUUID().toString();
|
||||||
@@ -127,6 +130,7 @@ public class ACS9167Test extends TestCase
|
|||||||
prepareParametersQueryAndAssertResult(searchMarker, 0, 200, contentFilesCount, contentFilesCount);
|
prepareParametersQueryAndAssertResult(searchMarker, 0, 200, contentFilesCount, contentFilesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testLargeFilesCount()
|
public void testLargeFilesCount()
|
||||||
{
|
{
|
||||||
String searchMarker = UUID.randomUUID().toString();
|
String searchMarker = UUID.randomUUID().toString();
|
||||||
@@ -138,14 +142,32 @@ public class ACS9167Test extends TestCase
|
|||||||
|
|
||||||
private void createFolderWithContentNodes(String searchMarker, int contentFilesCount)
|
private void createFolderWithContentNodes(String searchMarker, int contentFilesCount)
|
||||||
{
|
{
|
||||||
txnHelper.doInTransaction(() -> {
|
NodeRef testFolder = txnHelper.doInTransaction(this::createFolderNode, false, false);
|
||||||
NodeRef testFolder = createFolderNode();
|
int batchSize = 1000;
|
||||||
for (int c = 1; c <= contentFilesCount; c++)
|
int fullBatches = contentFilesCount / batchSize;
|
||||||
{
|
int remainingItems = contentFilesCount % batchSize;
|
||||||
createContentNode(searchMarker, testFolder);
|
|
||||||
}
|
for (int i = 0; i < fullBatches; i++)
|
||||||
return null;
|
{
|
||||||
}, false, false);
|
txnHelper.doInTransaction(() -> {
|
||||||
|
for (int j = 0; j < batchSize; j++)
|
||||||
|
{
|
||||||
|
createContentNode(searchMarker, testFolder);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remainingItems > 0)
|
||||||
|
{
|
||||||
|
txnHelper.doInTransaction(() -> {
|
||||||
|
for (int j = 0; j < remainingItems; j++)
|
||||||
|
{
|
||||||
|
createContentNode(searchMarker, testFolder);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareParametersQueryAndAssertResult(String searchMarker, int parameterSkipCount, int parameterMaxItems, int expectedLength, int expectedNumberFound)
|
private void prepareParametersQueryAndAssertResult(String searchMarker, int parameterSkipCount, int parameterMaxItems, int expectedLength, int expectedNumberFound)
|
||||||
@@ -160,7 +182,7 @@ public class ACS9167Test extends TestCase
|
|||||||
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.ofSeconds(60).toMillis());
|
sp.setMaxPermissionCheckTimeMillis(Duration.ofMinutes(2).toMillis());
|
||||||
// when
|
// when
|
||||||
ResultSet resultSet = pubSearchService.query(sp);
|
ResultSet resultSet = pubSearchService.query(sp);
|
||||||
// then
|
// then
|
||||||
|
Reference in New Issue
Block a user