Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

99377: BENCH-369: BM-0004: API and internals for Alfresco server
    - Move commons Math3 to 'core' project for general reuse
    - Clone NormalDistributionHelper class from Benchmark projects to Alfresco 'core'
    - API added: http://localhost:8080/alfresco/s/api/model/filefolder/load
      JSON:
      {
      "folderPath":"/Sites/t2/documentLibrary",
      "fileCount":"1",
      "minFileSize":"1024",
      "maxFileSize":"2048",
      "maxUniqueDocuments":"10000"
      }
    - Above JSON will create 1 file in the 't2' site document library with spoofed plain text
    - Change away from deprecated API for TransactionListenerAdapter
    - Fix imports and neatness
    - Improve FileNotFoundException details
    - Disable timestamp propagation on the parent folder to reduce CPU overhead
    - Document changes relating to the addition of cm:description properties
    - Add options to control generation of MLText cm:description fields
      - descriptionCount: number of cm:description translations to include
      - descriptionSize:  size in bytes of each cm:description translation
    - Use released 'alfresco-text-gen' V1.1
    - Use fixed text-gen component to prevent ArrayIndexOutOfBOunds
    - Tighten up error message when errors occur on reading content strings
    - Fix random seed generation bug


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@99503 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-03-16 13:36:33 +00:00
parent 9e3ae9c8e4
commit ebeea13b8b
14 changed files with 1441 additions and 688 deletions

View File

@@ -19,6 +19,7 @@
package org.alfresco.repo.model;
import org.alfresco.repo.model.filefolder.FileFolderDuplicateChildTest;
import org.alfresco.repo.model.filefolder.FileFolderLoaderTest;
import org.alfresco.repo.model.filefolder.FileFolderServiceImplTest;
import org.alfresco.repo.model.filefolder.FileFolderServicePropagationTest;
import org.alfresco.repo.model.filefolder.HiddenAspectTest;
@@ -52,7 +53,7 @@ import org.junit.runners.Suite.SuiteClasses;
// These need to come afterwards, as they insert extra
// interceptors which would otherwise confuse things
FileFolderServiceImplTest.class,
// TODO
FileFolderLoaderTest.class,
FileFolderDuplicateChildTest.class,
FileFolderServicePropagationTest.class
})

View File

@@ -0,0 +1,515 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.model.filefolder;
import java.util.List;
import java.util.Locale;
import junit.framework.TestCase;
import net.sf.acegisecurity.AuthenticationCredentialsNotFoundException;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.node.MLPropertyInterceptor;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.MLText;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.ApplicationContextHelper;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
import static org.junit.Assert.assertNotEquals;
/**
* @see org.alfresco.repo.model.filefolder.FileFolderLoader
* @author Derek Hulley
* @since 5.1
*/
@Category(OwnJVMTestsCategory.class)
public class FileFolderLoaderTest extends TestCase
{
private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
private FileFolderLoader fileFolderLoader;
private FileFolderService fileFolderService;
private PermissionService permissionService;
private TransactionService transactionService;
private NodeService nodeService;
private String sharedHomePath;
private NodeRef hiddenFolderNodeRef;
private String hiddenFolderPath;
private NodeRef readOnlyFolderNodeRef;
private String readOnlyFolderPath;
private NodeRef writeFolderNodeRef;
private String writeFolderPath;
@Override
public void setUp() throws Exception
{
AuthenticationUtil.pushAuthentication();
RunAsWork<Void> setUpWork = new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
fileFolderLoader = (FileFolderLoader) ctx.getBean("FileFolderLoader");
fileFolderService = (FileFolderService) ctx.getBean("FileFolderService");
permissionService = (PermissionService) ctx.getBean("PermissionService");
transactionService = (TransactionService) ctx.getBean("TransactionService");
nodeService = (NodeService) ctx.getBean("nodeService");
NodeRef companyHomeNodeRef = fileFolderLoader.getRepository().getCompanyHome();
NodeRef sharedHomeNodeRef = fileFolderLoader.getRepository().getSharedHome();
List<FileInfo> sharedHomeFileInfos = fileFolderService.getNamePath(companyHomeNodeRef, sharedHomeNodeRef);
sharedHomePath = "/" + sharedHomeFileInfos.get(0).getName();
// Create a folder that will be invisible to all normal users
FileInfo hiddenFolderInfo = fileFolderService.create(sharedHomeNodeRef, "HideThis", ContentModel.TYPE_FOLDER);
hiddenFolderNodeRef = hiddenFolderInfo.getNodeRef();
hiddenFolderPath = sharedHomePath + "/HideThis";
permissionService.setInheritParentPermissions(hiddenFolderNodeRef, false);
// Create a folder that will be read-only
FileInfo readOnlyFolderInfo = fileFolderService.create(sharedHomeNodeRef, "ReadOnlyThis", ContentModel.TYPE_FOLDER);
readOnlyFolderNodeRef = readOnlyFolderInfo.getNodeRef();
readOnlyFolderPath = sharedHomePath + "/ReadOnlyThis";
permissionService.setInheritParentPermissions(readOnlyFolderNodeRef, false);
permissionService.setPermission(readOnlyFolderNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true);
// Create a folder to write to
FileInfo writeFolderInfo = fileFolderService.create(sharedHomeNodeRef, "WriteThis", ContentModel.TYPE_FOLDER);
writeFolderNodeRef = writeFolderInfo.getNodeRef();
writeFolderPath = sharedHomePath + "/WriteThis";
// Done
return null;
}
};
AuthenticationUtil.runAsSystem(setUpWork);
}
@Override
public void tearDown() throws Exception
{
RunAsWork<Void> setUpWork = new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
fileFolderService.delete(hiddenFolderNodeRef);
fileFolderService.delete(readOnlyFolderNodeRef);
fileFolderService.delete(writeFolderNodeRef);
// Done
return null;
}
};
AuthenticationUtil.runAsSystem(setUpWork);
AuthenticationUtil.popAuthentication();
}
@Test
public void testBasic()
{
assertNotNull(fileFolderLoader);
assertNotNull(sharedHomePath);
}
@Test
public void testIllegalArgs_MinMax() throws Exception
{
try
{
fileFolderLoader.createFiles(
sharedHomePath,
1, 256, 100L, 10L, Long.MAX_VALUE, false,
10, 256);
fail("Should detect min/max size issue.");
}
catch (IllegalArgumentException e)
{
// Expected
}
}
@Test
public void testIllegalArgs_DescriptionCount() throws Exception
{
try
{
fileFolderLoader.createFiles(
sharedHomePath,
1, 256, 1024L, 10L, Long.MAX_VALUE, false,
Integer.MAX_VALUE, 256);
fail("Should detect description count issue.");
}
catch (IllegalArgumentException e)
{
// Expected
}
}
@Test
public void testIllegalArgs_DescriptionSize() throws Exception
{
try
{
fileFolderLoader.createFiles(
sharedHomePath,
1, 256, 1024L, 10L, Long.MAX_VALUE, false,
10, Long.MAX_VALUE);
fail("Should detect description size issue.");
}
catch (IllegalArgumentException e)
{
// Expected
}
}
@Test
public void testNoPermissionsAtAll() throws Exception
{
try
{
fileFolderLoader.createFiles(
sharedHomePath,
0, 256, 1024L, 1024L, Long.MAX_VALUE, false,
10, 256L);
fail("No permissions to see folder.");
}
catch (AuthenticationCredentialsNotFoundException e)
{
// Expected
}
}
@Test
public void testNoPermissionsToFindFolder() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser("BOB-1");
fileFolderLoader.createFiles(
hiddenFolderPath,
0, 256, 1024L, 1024L, Long.MAX_VALUE, false,
10, 256L);
fail("No permissions to see folder.");
}
catch (AccessDeniedException e)
{
// Expected
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
@Test
public void testFolderMissing() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
fileFolderLoader.createFiles(
sharedHomePath + "/Missing",
0, 256, 1024L, 1024L, Long.MAX_VALUE, false,
10, 256L);
fail("Folder does not exist");
}
catch (AlfrescoRuntimeException e)
{
// Expected
assertTrue(e.getCause() instanceof FileNotFoundException);
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
@Test
public void testNoPermissionsToWriteToFolder() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser("BOB-1");
fileFolderLoader.createFiles(
readOnlyFolderPath,
1, 256, 1024L, 1024L, Long.MAX_VALUE, false,
10, 256L);
fail("Folder is read only. Should not be able to write to it.");
}
catch (AccessDeniedException e)
{
// Expected
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
/**
* Zero files
*/
@Test
public void testLoad_ZeroFiles() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
int created = fileFolderLoader.createFiles(
writeFolderPath,
0, 256, 1024L, 1024L, Long.MAX_VALUE, false,
10, 256L);
assertEquals("Incorrect number of files generated.", 0, created);
// Count
assertEquals(0, nodeService.countChildAssocs(writeFolderNodeRef, true));
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
/**
* One file
*/
@Test
public void testLoad_OneFile() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
int created = fileFolderLoader.createFiles(
writeFolderPath,
1, 256, 1024L, 1024L, Long.MAX_VALUE, false,
10, 256L);
assertEquals("Incorrect number of files generated.", 1, created);
// Check the descriptions
RetryingTransactionCallback<Void> checkCallback = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
MLPropertyInterceptor.setMLAware(true);
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(writeFolderNodeRef);
// Count
assertEquals(1, childAssocs.size());
NodeRef fileNodeRef = childAssocs.get(0).getChildRef();
MLText descriptions = (MLText) nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION);
assertNotNull("No descriptions added", descriptions);
assertEquals("Incorrect number of unique descriptions added: ", 10, descriptions.size());
assertTrue("Expect the default language to be present. ",
descriptions.containsKey(new Locale(Locale.getDefault().getLanguage())));
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(checkCallback, true);
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
/**
* 100 files; 10 per txn
*/
@Test
public void testLoad_02() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
int created = fileFolderLoader.createFiles(
writeFolderPath,
100, 10, 1024L, 1024L, Long.MAX_VALUE, false,
10, 256L);
assertEquals("Incorrect number of files generated.", 100, created);
// Count
assertEquals(100, nodeService.countChildAssocs(writeFolderNodeRef, true));
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
/**
* 15 files; 10 per txn; spoofed; different
*/
@Test
public void testLoad_03() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
int created = fileFolderLoader.createFiles(
writeFolderPath,
15, 10, 1024L, 1024L, Long.MAX_VALUE, false,
10, 256L);
assertEquals("Incorrect number of files generated.", 15, created);
// Count
assertEquals(15, nodeService.countChildAssocs(writeFolderNodeRef, true));
// Check the files
List<FileInfo> fileInfos = fileFolderService.listFiles(writeFolderNodeRef);
String lastText = null;
String lastDescr = null;
String lastUrl = null;
for (FileInfo fileInfo : fileInfos)
{
NodeRef fileNodeRef = fileInfo.getNodeRef();
// The URLs must all be unique as we wrote the physical binaries
ContentReader reader = fileFolderService.getReader(fileNodeRef);
assertEquals("UTF-8", reader.getEncoding());
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, reader.getMimetype());
assertEquals(1024L, reader.getSize());
if (lastUrl == null)
{
lastUrl = reader.getContentUrl();
}
else
{
assertNotEquals("We expect different URLs: ", lastUrl, reader.getContentUrl());
lastUrl = reader.getContentUrl();
}
// Check content
if (lastText == null)
{
lastText = reader.getContentString();
}
else
{
String currentStr = reader.getContentString();
assertNotEquals("All text must differ due to varying seed. ", lastText, currentStr);
lastText = currentStr;
}
// Check description
if (lastDescr == null)
{
lastDescr = (String) nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION);
assertEquals("cm:description length is incorrect. ", 256, lastDescr.getBytes().length);
}
else
{
String currentDescr = (String) nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION);
assertNotEquals("All descriptions must differ due to varying seed. ", lastDescr, currentDescr);
lastDescr = currentDescr;
}
}
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
/**
* 10 files; 10 per txn; force storage; identical
*/
@Test
public void testLoad_04() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
int created = fileFolderLoader.createFiles(
writeFolderPath,
10, 10, 1024L, 1024L, 1L, true,
10, 256L);
assertEquals("Incorrect number of files generated.", 10, created);
// Count
assertEquals(10, nodeService.countChildAssocs(writeFolderNodeRef, true));
// Check the files
List<FileInfo> fileInfos = fileFolderService.listFiles(writeFolderNodeRef);
String lastText = null;
String lastDescr = null;
String lastUrl = null;
for (FileInfo fileInfo : fileInfos)
{
NodeRef fileNodeRef = fileInfo.getNodeRef();
// The URLs must all be unique as we wrote the physical binaries
ContentReader reader = fileFolderService.getReader(fileNodeRef);
assertEquals("UTF-8", reader.getEncoding());
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, reader.getMimetype());
assertEquals(1024L, reader.getSize());
if (lastUrl == null)
{
lastUrl = reader.getContentUrl();
}
else
{
assertNotEquals("We expect unique URLs: ", lastUrl, reader.getContentUrl());
lastUrl = reader.getContentUrl();
}
// Check content
if (lastText == null)
{
lastText = reader.getContentString();
}
else
{
String currentStr = reader.getContentString();
assertEquals("All text must be identical due to same seed. ", lastText, currentStr);
lastText = currentStr;
}
// Check description
if (lastDescr == null)
{
lastDescr = (String) nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION);
assertEquals("cm:description length is incorrect. ", 256, lastDescr.getBytes().length);
}
else
{
String currentDescr = (String) nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION);
assertEquals("All descriptions must be identical due to varying seed. ", lastDescr, currentDescr);
lastDescr = currentDescr;
}
}
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
}

View File

@@ -186,12 +186,12 @@ public class FileFolderServiceImplTest extends TestCase
QName.createQName(NamespaceService.ALFRESCO_URI, "working root1"),
QName.createQName("http://www.alfresco.org/test/filefoldertest/1.0", "folder")).getChildRef();
nodeService.createNode(
workingRootNodeRef1,
workingRootNodeRef1,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.ALFRESCO_URI, "node1"),
ContentModel.TYPE_CONTENT).getChildRef();
nodeService.createNode(
workingRootNodeRef1,
workingRootNodeRef1,
QName.createQName("http://www.alfresco.org/test/filefoldertest/1.0", "contains1"),
QName.createQName(NamespaceService.ALFRESCO_URI, "node2"),
ContentModel.TYPE_CONTENT).getChildRef();
@@ -265,20 +265,20 @@ public class FileFolderServiceImplTest extends TestCase
public void testShallowFilesAndFoldersListWithLocale() throws Exception
{
Locale savedLocale = I18NUtil.getContentLocaleOrNull();
try
{
I18NUtil.setContentLocale(Locale.CANADA);
List<FileInfo> files = fileFolderService.list(workingRootNodeRef);
// check
String[] expectedNames = new String[]
{ NAME_L0_FILE_A, NAME_L0_FILE_B, NAME_L0_FOLDER_A, NAME_L0_FOLDER_B, NAME_L0_FOLDER_C };
checkFileList(files, 2, 3, expectedNames);
}
finally
{
I18NUtil.setContentLocale(savedLocale);
}
Locale savedLocale = I18NUtil.getContentLocaleOrNull();
try
{
I18NUtil.setContentLocale(Locale.CANADA);
List<FileInfo> files = fileFolderService.list(workingRootNodeRef);
// check
String[] expectedNames = new String[]
{ NAME_L0_FILE_A, NAME_L0_FILE_B, NAME_L0_FOLDER_A, NAME_L0_FOLDER_B, NAME_L0_FOLDER_C };
checkFileList(files, 2, 3, expectedNames);
}
finally
{
I18NUtil.setContentLocale(savedLocale);
}
}
public void testShallowFilesOnlyList() throws Exception
@@ -1046,17 +1046,17 @@ public class FileFolderServiceImplTest extends TestCase
*/
public void testGetType() throws Exception
{
Locale savedLocale = I18NUtil.getContentLocaleOrNull();
try
{
I18NUtil.setContentLocale(Locale.CANADA);
FileFolderServiceType type = fileFolderService.getType(ContentModel.TYPE_FOLDER);
assertEquals("Type incorrect for folder", FileFolderServiceType.FOLDER, type);
}
finally
{
Locale savedLocale = I18NUtil.getContentLocaleOrNull();
try
{
I18NUtil.setContentLocale(Locale.CANADA);
FileFolderServiceType type = fileFolderService.getType(ContentModel.TYPE_FOLDER);
assertEquals("Type incorrect for folder", FileFolderServiceType.FOLDER, type);
}
finally
{
I18NUtil.setContentLocale(savedLocale);
}
}
}
public void testETHREEOH_3088_MoveIntoSelf() throws Exception
@@ -1348,7 +1348,7 @@ public class FileFolderServiceImplTest extends TestCase
{
// sanity checks only (see also GetChildrenCannedQueryTest)
I18NUtil.setContentLocale(Locale.CANADA);
I18NUtil.setContentLocale(Locale.CANADA);
// test 1
PagingRequest pagingRequest = new PagingRequest(100, null);
@@ -1397,7 +1397,7 @@ public class FileFolderServiceImplTest extends TestCase
public void testALF12758()
{
// test that the FileFolderService returns only cm:contains children
// test that the FileFolderService returns only cm:contains children
PagingRequest pagingRequest = new PagingRequest(0, Integer.MAX_VALUE);
PagingResults<FileInfo> pagingResults = fileFolderService.list(workingRootNodeRef1, true, true, null, null, null, pagingRequest);
assertNotNull(pagingResults);
@@ -1438,47 +1438,47 @@ public class FileFolderServiceImplTest extends TestCase
public void testList_HiddenFiles()
{
// Test that hidden files are not returned for clients that should not be able to see them,
// and that the total result count is correct.
// Test that hidden files are not returned for clients that should not be able to see them,
// and that the total result count is correct.
Client saveClient = FileFilterMode.setClient(Client.webdav);
try
{
// create some hidden files
NodeRef nodeRef = fileFolderService.create(workingRootNodeRef, "" + System.currentTimeMillis(), ContentModel.TYPE_CONTENT).getNodeRef();
NodeRef nodeRef1 = fileFolderService.create(nodeRef, "parent", ContentModel.TYPE_CONTENT).getNodeRef();
for(int i = 0; i < 10; i++)
{
fileFolderService.create(nodeRef1, ".child" + i, ContentModel.TYPE_CONTENT).getNodeRef();
}
// and some visible files
for(int i = 0; i < 10; i++)
{
fileFolderService.create(nodeRef1, "visiblechild" + i, ContentModel.TYPE_CONTENT).getNodeRef();
}
Client saveClient = FileFilterMode.setClient(Client.webdav);
try
{
// create some hidden files
NodeRef nodeRef = fileFolderService.create(workingRootNodeRef, "" + System.currentTimeMillis(), ContentModel.TYPE_CONTENT).getNodeRef();
NodeRef nodeRef1 = fileFolderService.create(nodeRef, "parent", ContentModel.TYPE_CONTENT).getNodeRef();
for(int i = 0; i < 10; i++)
{
fileFolderService.create(nodeRef1, ".child" + i, ContentModel.TYPE_CONTENT).getNodeRef();
}
// and some visible files
for(int i = 0; i < 10; i++)
{
fileFolderService.create(nodeRef1, "visiblechild" + i, ContentModel.TYPE_CONTENT).getNodeRef();
}
// switch to a client that should not see the hidden files
saveClient = FileFilterMode.setClient(Client.cmis);
PagingRequest pagingRequest = new PagingRequest(0, Integer.MAX_VALUE);
pagingRequest.setRequestTotalCountMax(10000); // need this so that total count is set
// switch to a client that should not see the hidden files
saveClient = FileFilterMode.setClient(Client.cmis);
PagingRequest pagingRequest = new PagingRequest(0, Integer.MAX_VALUE);
pagingRequest.setRequestTotalCountMax(10000); // need this so that total count is set
PagingResults<FileInfo> results = fileFolderService.list(nodeRef1, true, true, null, null, pagingRequest);
Pair<Integer, Integer> totalResultCount = results.getTotalResultCount();
assertNotNull(totalResultCount.getFirst());
assertEquals("Total result lower count should be 10", 10, totalResultCount.getFirst().intValue());
assertNotNull(totalResultCount.getSecond());
assertEquals("Total result upper count should be 10", 10, totalResultCount.getSecond().intValue());
for(FileInfo fileInfo : results.getPage())
{
assertTrue(fileInfo.getName().startsWith("visiblechild"));
}
assertEquals("Expected only 10 results", 10, results.getPage().size());
}
finally
{
FileFilterMode.setClient(saveClient);
}
PagingResults<FileInfo> results = fileFolderService.list(nodeRef1, true, true, null, null, pagingRequest);
Pair<Integer, Integer> totalResultCount = results.getTotalResultCount();
assertNotNull(totalResultCount.getFirst());
assertEquals("Total result lower count should be 10", 10, totalResultCount.getFirst().intValue());
assertNotNull(totalResultCount.getSecond());
assertEquals("Total result upper count should be 10", 10, totalResultCount.getSecond().intValue());
for(FileInfo fileInfo : results.getPage())
{
assertTrue(fileInfo.getName().startsWith("visiblechild"));
}
assertEquals("Expected only 10 results", 10, results.getPage().size());
}
finally
{
FileFilterMode.setClient(saveClient);
}
}
public void testList_notCheckedOut_ALF_13602()
@@ -1637,7 +1637,7 @@ public class FileFolderServiceImplTest extends TestCase
assertFalse(copyInfo.getName().contains("(Working Copy)"));
assertTrue(copyInfo.getName().substring(0, copyExtIndex).startsWith(checkedOutName.substring(0, origExtIndex)));
}
public void testSortingCustomFields()
{
// Test sorting based on MNT-11120
@@ -1734,5 +1734,5 @@ public class FileFolderServiceImplTest extends TestCase
results = fileFolderService.list(parentTestRef, true, false, null, sortProps, pagingRequest);
expectedNames = new String[] { "B-null", "A-foo", "A-bar", "B-baz", "A-null", "B-biz" };
checkFileList(pageRes, 6, 0, expectedNames);
}
}
}

View File

@@ -52,6 +52,7 @@ import org.alfresco.service.transaction.TransactionService;
import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.Pair;
import org.alfresco.util.transaction.TransactionListenerAdapter;
import org.apache.commons.lang.mutable.MutableInt;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -725,8 +726,11 @@ public class RetryingTransactionHelperTest extends TestCase
assertFalse("New transaction has not started", txnId.equals(listener.newTxnId));
}
private void runThreads(final RetryingTransactionHelper txnHelper, final List<Throwable> caughtExceptions,
Pair<Integer, Integer>... startDurationPairs)
@SuppressWarnings("unchecked")
private void runThreads(
final RetryingTransactionHelper txnHelper,
final List<Throwable> caughtExceptions,
final Pair<Integer, Integer>... startDurationPairs)
{
ExecutorService executorService = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>(10));