mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-2827: Add Search Tests To CMIS-TAS (#1125)
* ACS-2827: Initial commit * ACS-2827: Fix build * ACS-2827: Rename test files * ACS-2827: Increase retry time
This commit is contained in:
committed by
GitHub
parent
5a92d7f013
commit
e3d56ad557
@@ -0,0 +1,76 @@
|
|||||||
|
package org.alfresco.cmis.search;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.alfresco.cmis.CmisProperties;
|
||||||
|
import org.alfresco.utility.Utility;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.testng.annotations.AfterMethod;
|
||||||
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
|
||||||
|
@ContextConfiguration("classpath:alfresco-cmis-context.xml")
|
||||||
|
@Component
|
||||||
|
@Scope(value = "prototype")
|
||||||
|
public abstract class AbstractCmisE2ETest extends AbstractE2EFunctionalTest
|
||||||
|
{
|
||||||
|
private static Logger LOGGER = LoggerFactory.getLogger(AbstractCmisE2ETest.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected CmisProperties cmisProperties;
|
||||||
|
|
||||||
|
public String documentContent = "CMIS document content";
|
||||||
|
|
||||||
|
@BeforeMethod(alwaysRun = true)
|
||||||
|
public void showStartTestInfo(Method method)
|
||||||
|
{
|
||||||
|
LOGGER.info(String.format("*** STARTING Test: [%s] ***", method.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterMethod(alwaysRun = true)
|
||||||
|
public void showEndTestInfo(Method method)
|
||||||
|
{
|
||||||
|
LOGGER.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getElasticWaitTimeInSeconds()
|
||||||
|
{
|
||||||
|
return cmisProperties.envProperty().getSolrWaitTimeInSeconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repeat Elastic Query till results count returns expectedCountResults
|
||||||
|
* @param query CMIS Query to be executed
|
||||||
|
* @param expectedCountResults Number of results expected
|
||||||
|
* @return true when results count is equals to expectedCountResults
|
||||||
|
*/
|
||||||
|
protected boolean waitForIndexing(String query, long expectedCountResults)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int searchCount = 1; searchCount <= SEARCH_MAX_ATTEMPTS; searchCount++)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cmisApi.withQuery(query).assertResultsCount().equals(expectedCountResults);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (AssertionError ae)
|
||||||
|
{
|
||||||
|
LOGGER.info(String.format("WaitForIndexing in Progress: %s", ae));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Utility.waitToLoopTime(getElasticWaitTimeInSeconds(), "Wait For Indexing");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,58 @@
|
|||||||
|
package org.alfresco.cmis.search;
|
||||||
|
|
||||||
|
import org.alfresco.cmis.CmisWrapper;
|
||||||
|
import org.alfresco.dataprep.SiteService.Visibility;
|
||||||
|
import org.alfresco.utility.data.DataContent;
|
||||||
|
import org.alfresco.utility.data.DataSite;
|
||||||
|
import org.alfresco.utility.data.DataUser;
|
||||||
|
import org.alfresco.utility.data.RandomData;
|
||||||
|
import org.alfresco.utility.model.SiteModel;
|
||||||
|
import org.alfresco.utility.model.UserModel;
|
||||||
|
import org.alfresco.utility.network.ServerHealth;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
|
||||||
|
@ContextConfiguration ("classpath:alfresco-cmis-context.xml")
|
||||||
|
public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringContextTests
|
||||||
|
{
|
||||||
|
/** The number of retries that a query will be tried before giving up. */
|
||||||
|
protected static final int SEARCH_MAX_ATTEMPTS = 20;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected ServerHealth serverHealth;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected DataSite dataSite;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected DataContent dataContent;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected CmisWrapper cmisApi;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected DataUser dataUser;
|
||||||
|
|
||||||
|
protected UserModel testUser, adminUserModel;
|
||||||
|
protected SiteModel testSite;
|
||||||
|
|
||||||
|
protected static String unique_searchString;
|
||||||
|
|
||||||
|
@BeforeClass (alwaysRun = true)
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
serverHealth.assertServerIsOnline();
|
||||||
|
|
||||||
|
adminUserModel = dataUser.getAdminUser();
|
||||||
|
testUser = dataUser.createRandomTestUser("UserSearch");
|
||||||
|
|
||||||
|
testSite = new SiteModel(RandomData.getRandomName("SiteSearch"));
|
||||||
|
testSite.setVisibility(Visibility.PRIVATE);
|
||||||
|
|
||||||
|
testSite = dataSite.usingUser(testUser).createSite(testSite);
|
||||||
|
|
||||||
|
unique_searchString = testSite.getTitle().replace("SiteSearch", "Unique");
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,62 @@
|
|||||||
|
package org.alfresco.cmis.search;
|
||||||
|
|
||||||
|
import org.alfresco.utility.Utility;
|
||||||
|
import org.alfresco.utility.data.provider.XMLDataConfig;
|
||||||
|
import org.alfresco.utility.data.provider.XMLTestDataProvider;
|
||||||
|
import org.alfresco.utility.model.FileModel;
|
||||||
|
import org.alfresco.utility.model.FileType;
|
||||||
|
import org.alfresco.utility.model.FolderModel;
|
||||||
|
import org.alfresco.utility.model.QueryModel;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
public class SearchInFolderTests extends AbstractCmisE2ETest
|
||||||
|
{
|
||||||
|
private FolderModel parentFolder, subFolder1, subFolder2, subFolder3;
|
||||||
|
private FileModel subFile1, subFile2, subFile3, subFile4, subFile5;
|
||||||
|
|
||||||
|
@BeforeClass(alwaysRun = true)
|
||||||
|
public void createTestData() throws Exception
|
||||||
|
{
|
||||||
|
// create input data
|
||||||
|
parentFolder = FolderModel.getRandomFolderModel();
|
||||||
|
subFolder1 = FolderModel.getRandomFolderModel();
|
||||||
|
subFolder2 = FolderModel.getRandomFolderModel();
|
||||||
|
subFolder3 = new FolderModel("subFolder");
|
||||||
|
subFile5 = new FileModel("fifthFile.txt",FileType.TEXT_PLAIN, "fifthFile content");
|
||||||
|
subFile1 = new FileModel("firstFile", FileType.MSEXCEL);
|
||||||
|
subFile2 = FileModel.getRandomFileModel(FileType.MSPOWERPOINT2007);
|
||||||
|
subFile3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||||
|
subFile4 = new FileModel("fourthFile", "fourthFileTitle", "fourthFileDescription", FileType.MSWORD2007);
|
||||||
|
|
||||||
|
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder)
|
||||||
|
.then().usingResource(parentFolder)
|
||||||
|
.createFile(subFile5).assertThat().contentIs("fifthFile content")
|
||||||
|
.createFolder(subFolder1)
|
||||||
|
.createFolder(subFolder2)
|
||||||
|
.createFolder(subFolder3)
|
||||||
|
.createFile(subFile1)
|
||||||
|
.createFile(subFile2)
|
||||||
|
.createFile(subFile3)
|
||||||
|
.createFile(subFile4);
|
||||||
|
// wait for index
|
||||||
|
Utility.waitToLoopTime(getElasticWaitTimeInSeconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass(alwaysRun = true)
|
||||||
|
public void cleanupEnvironment()
|
||||||
|
{
|
||||||
|
dataContent.deleteSite(testSite);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData")
|
||||||
|
@XMLDataConfig(file = "src/test/resources/search-in-folder.xml")
|
||||||
|
public void executeCMISQuery(QueryModel query)
|
||||||
|
{
|
||||||
|
String currentQuery = String.format(query.getValue(), parentFolder.getNodeRef());
|
||||||
|
cmisApi.authenticateUser(testUser);
|
||||||
|
Assert.assertTrue(waitForIndexing(currentQuery, query.getResults()), String.format("Result count not as expected for query: %s", currentQuery));
|
||||||
|
}
|
||||||
|
}
|
@@ -7,7 +7,7 @@ alfresco.port=8082
|
|||||||
admin.user=admin
|
admin.user=admin
|
||||||
admin.password=admin
|
admin.password=admin
|
||||||
|
|
||||||
solrWaitTimeInSeconds=30
|
solrWaitTimeInSeconds=60
|
||||||
|
|
||||||
# in containers we cannot access directly JMX, so we will use http://jolokia.org agent
|
# in containers we cannot access directly JMX, so we will use http://jolokia.org agent
|
||||||
# disabling this we will use direct JMX calls to server
|
# disabling this we will use direct JMX calls to server
|
||||||
|
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--CMIS Queries: passing the search query as first param and results expected -->
|
||||||
|
<testData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<queries>
|
||||||
|
<query value="SELECT cmis:name, cmis:parentId, cmis:path, cmis:allowedChildObjectTypeIds FROM cmis:folder where IN_FOLDER('%s') AND cmis:name = 'subFolder'" expectedResults="1" />
|
||||||
|
<query value="SELECT cmis:name, cmis:objectId, cmis:lastModifiedBy, cmis:creationDate, cmis:contentStreamFileName FROM cmis:document where IN_FOLDER('%s') AND cmis:name = 'fourthFile'" expectedResults="1" />
|
||||||
|
<query value="SELECT cmis:parentId FROM cmis:folder where IN_FOLDER('%s')" expectedResults="3" />
|
||||||
|
<query value="SELECT * FROM cmis:document where IN_FOLDER('%s')" expectedResults="5" />
|
||||||
|
<query value="SELECT * FROM cmis:document where IN_FOLDER('%s') ORDER BY cmis:name ASC" expectedResults="5" />
|
||||||
|
<query value="SELECT * FROM cmis:document where IN_FOLDER('%s') ORDER BY cmis:name DESC" expectedResults="5" />
|
||||||
|
<query value="SELECT * FROM cmis:folder where IN_FOLDER('%s') ORDER BY cmis:lastModificationDate ASC" expectedResults="3" />
|
||||||
|
<query value="SELECT * FROM cmis:folder where IN_FOLDER('%s') ORDER BY cmis:lastModificationDate DESC" expectedResults="3" />
|
||||||
|
<query value="SELECT * FROM cmis:document where IN_FOLDER('%s') ORDER BY cmis:createdBy DESC" expectedResults="5" />
|
||||||
|
<query value="SELECT * FROM cmis:document where IN_FOLDER('%s') AND cmis:name IS NOT NULL" expectedResults="5" />
|
||||||
|
<query value="SELECT * FROM cmis:folder where IN_FOLDER('%s') AND cmis:name IS NOT NULL" expectedResults="3" />
|
||||||
|
<query value="SELECT * FROM cmis:document where IN_FOLDER('%s') AND cmis:name LIKE 'fourthFile'" expectedResults="1" />
|
||||||
|
<query value="SELECT * FROM cmis:folder where IN_FOLDER('%s') AND NOT(cmis:name NOT IN ('subFolder'))" expectedResults="1" />
|
||||||
|
<query value="SELECT * FROM cmis:document where IN_FOLDER('%s') AND cmis:name IN ('fourthFile', 'fifthFile.txt')" expectedResults="2" />
|
||||||
|
<query value="SELECT * FROM cmis:document where IN_FOLDER('%s') AND cmis:name NOT IN ('fourthFile', 'fifthFile.txt')" expectedResults="3" />
|
||||||
|
<query value="SELECT * FROM cmis:folder where IN_FOLDER('%s') AND cmis:name <> 'subFolder'" expectedResults="2" />
|
||||||
|
<query value="SELECT cmis:secondaryObjectTypeIds FROM cmis:folder where IN_FOLDER('%s') AND cmis:name = 'subFolder'" expectedResults="1" />
|
||||||
|
</queries>
|
||||||
|
</testData>
|
Reference in New Issue
Block a user