diff --git a/source/test-java/org/alfresco/rest/api/tests/AbstractEnterpriseOpenCMIS11TCKTest.java b/source/test-java/org/alfresco/rest/api/tests/AbstractEnterpriseOpenCMIS11TCKTest.java
index e88860dddc..9c7b2f2086 100644
--- a/source/test-java/org/alfresco/rest/api/tests/AbstractEnterpriseOpenCMIS11TCKTest.java
+++ b/source/test-java/org/alfresco/rest/api/tests/AbstractEnterpriseOpenCMIS11TCKTest.java
@@ -1,28 +1,28 @@
-/*
- * #%L
- * Alfresco Remote API
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * 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 .
- * #L%
- */
+/*
+ * #%L
+ * Alfresco Remote API
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * 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 .
+ * #L%
+ */
package org.alfresco.rest.api.tests;
import java.util.Map;
@@ -34,13 +34,28 @@ import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTestGroup;
import org.apache.chemistry.opencmis.tck.impl.JUnitHelper;
import org.apache.chemistry.opencmis.tck.tests.basics.BasicsTestGroup;
import org.apache.chemistry.opencmis.tck.tests.control.ControlTestGroup;
-import org.apache.chemistry.opencmis.tck.tests.crud.CRUDTestGroup;
+import org.apache.chemistry.opencmis.tck.tests.crud.BulkUpdatePropertiesTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.ChangeTokenTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.ContentRangesTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.CopyTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.CreateAndDeleteDocumentTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.CreateAndDeleteFolderTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.CreateAndDeleteItemTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.CreateAndDeleteRelationshipTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.CreateBigDocument;
+import org.apache.chemistry.opencmis.tck.tests.crud.CreateDocumentWithoutContent;
+import org.apache.chemistry.opencmis.tck.tests.crud.DeleteTreeTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.MoveTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.NameCharsetTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.OperationContextTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.SetAndDeleteContentTest;
+import org.apache.chemistry.opencmis.tck.tests.crud.UpdateSmokeTest;
import org.apache.chemistry.opencmis.tck.tests.filing.FilingTestGroup;
import org.apache.chemistry.opencmis.tck.tests.query.ContentChangesSmokeTest;
import org.apache.chemistry.opencmis.tck.tests.query.QuerySmokeTest;
-import org.apache.chemistry.opencmis.tck.tests.versioning.VersionDeleteTest;
-import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningSmokeTest;
-import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningStateCreateTest;
+import org.apache.chemistry.opencmis.tck.tests.versioning.VersionDeleteTest;
+import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningSmokeTest;
+import org.apache.chemistry.opencmis.tck.tests.versioning.VersioningStateCreateTest;
import org.junit.Test;
public abstract class AbstractEnterpriseOpenCMIS11TCKTest extends AbstractEnterpriseOpenCMISTCKTest
@@ -55,14 +70,14 @@ public abstract class AbstractEnterpriseOpenCMIS11TCKTest extends AbstractEnterp
@Test
public void testCMISTCKCRUD() throws Exception
{
- CRUDTestGroup crudTestGroup = new CRUDTestGroup();
+ CRUDTestGroup crudTestGroup = new CRUDTestGroup();
JUnitHelper.run(crudTestGroup);
}
@Test
public void testCMISTCKVersioning() throws Exception
{
- OverrideVersioningTestGroup versioningTestGroup = new OverrideVersioningTestGroup();
+ OverrideVersioningTestGroup versioningTestGroup = new OverrideVersioningTestGroup();
JUnitHelper.run(versioningTestGroup);
}
@@ -87,54 +102,53 @@ public abstract class AbstractEnterpriseOpenCMIS11TCKTest extends AbstractEnterp
JUnitHelper.run(queryTestGroup);
}
- class OverrideVersioningTestGroup extends AbstractSessionTestGroup
- {
- @Override
- public void init(Map parameters) throws Exception
- {
- super.init(parameters);
-
- setName("Versioning Test Group");
- setDescription("Versioning tests.");
-
- addTest(new VersioningSmokeTest());
- addTest(new VersionDeleteTest());
- addTest(new VersioningStateCreateTest());
- // relies on Solr being available
-// addTest(new CheckedOutTest());
- }
- }
-
-// class OverrideCRUDTestGroup extends AbstractSessionTestGroup
-// {
-// @Override
-// public void init(Map parameters) throws Exception
-// {
-// super.init(parameters);
-//
-// setName("CRUD Test Group");
-// setDescription("Create, Read, Update, and Delete tests.");
-//
-// addTest(new CreateAndDeleteFolderTest());
-// addTest(new CreateAndDeleteDocumentTest());
-// addTest(new CreateBigDocument());
-// addTest(new CreateDocumentWithoutContent());
-// addTest(new NameCharsetTest());
-// addTest(new CreateAndDeleteRelationshipTest());
-// addTest(new CreateAndDeleteItemTest());
-// addTest(new UpdateSmokeTest());
-// // TCK fails because we support only 1 object in bulk update at present
-// // See ACE-34
-// //addTest(new BulkUpdatePropertiesTest());
-// addTest(new SetAndDeleteContentTest());
-// addTest(new ChangeTokenTest());
-// addTest(new ContentRangesTest());
-// addTest(new CopyTest());
-// addTest(new MoveTest());
-// addTest(new DeleteTreeTest());
-// addTest(new OperationContextTest());
-// }
-// }
+ class OverrideVersioningTestGroup extends AbstractSessionTestGroup
+ {
+ @Override
+ public void init(Map parameters) throws Exception
+ {
+ super.init(parameters);
+
+ setName("Versioning Test Group");
+ setDescription("Versioning tests.");
+
+ addTest(new VersioningSmokeTest());
+ addTest(new VersionDeleteTest());
+ addTest(new VersioningStateCreateTest());
+ // relies on Solr being available
+// addTest(new CheckedOutTest());
+ }
+ }
+
+ class OverrideCRUDTestGroup extends AbstractSessionTestGroup
+ {
+ @Override
+ public void init(Map parameters) throws Exception
+ {
+ super.init(parameters);
+
+ setName("CRUD Test Group");
+ setDescription("Create, Read, Update, and Delete tests.");
+
+ addTest(new CreateAndDeleteFolderTest());
+ addTest(new CreateAndDeleteDocumentTest());
+ addTest(new CreateBigDocument());
+ addTest(new CreateDocumentWithoutContent());
+ addTest(new NameCharsetTest());
+ addTest(new CreateAndDeleteRelationshipTest());
+ addTest(new CreateAndDeleteItemTest());
+ addTest(new UpdateSmokeTest());
+ addTest(new BulkUpdatePropertiesTest());
+ addTest(new BulkUpdatePropertiesCustomTest());
+ addTest(new SetAndDeleteContentTest());
+ addTest(new ChangeTokenTest());
+ addTest(new ContentRangesTest());
+ addTest(new CopyTest());
+ addTest(new MoveTest());
+ addTest(new DeleteTreeTest());
+ addTest(new OperationContextTest());
+ }
+ }
public class OverrideQueryTestGroup extends AbstractSessionTestGroup
{
diff --git a/source/test-java/org/alfresco/rest/api/tests/BulkUpdatePropertiesCustomTest.java b/source/test-java/org/alfresco/rest/api/tests/BulkUpdatePropertiesCustomTest.java
new file mode 100644
index 0000000000..b3fbddea7b
--- /dev/null
+++ b/source/test-java/org/alfresco/rest/api/tests/BulkUpdatePropertiesCustomTest.java
@@ -0,0 +1,144 @@
+package org.alfresco.rest.api.tests;
+
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.INFO;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
+import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Class to test if bulk properties update works for the
+ * description(cmis:description) property
+ *
+ * This test checks the fix from MNT-16376 is valid but only if the change in
+ * MNT-13670 is not present in the code base. The fix from MNT-16376 ensures
+ * that the correct call context is available to the working threads that
+ * process bulk update. The fix from MNT-13670 added the description to the CMIS
+ * version 1.0 mapping in RuntimePropertyAccessorMapping and that masks the
+ * problem of the missing call context of the bulk update working threads for
+ * the description property.
+ *
+ * Currently all of the properties in the RuntimePropertyAccessorMapping are
+ * added to the CMIS version 1.0, except for isSecondaryTypesProperty and
+ * IsPrivateWorkingCopy. I am not sure if/how and what would be the consequences
+ * if we update in the bulk update operation the two properties that are
+ * missing for version CMIS 1.0.
+ *
+ */
+public class BulkUpdatePropertiesCustomTest extends AbstractSessionTest
+{
+ private static final String CONTENT = "Custom Bluk update test content.";
+ private static final String NEW_DESCRIPTION_VALUE = "new description value";
+
+ @Override
+ public void init(Map parameters)
+ {
+ super.init(parameters);
+ setName("Custom Bulk Update Properties Test");
+ setDescription("Creates a few folders and documents,bulk update the description and check that it has been updated, and deletes all created objects.");
+ }
+
+ @Override
+ public void run(Session session)
+ {
+ if (session.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_0)
+ {
+ addResult(createResult(SKIPPED, "Bulk Update Properties is not supported by CMIS 1.0. Test skipped!"));
+ return;
+ }
+
+ CmisTestResult failure = null;
+ int numOfObjects = 25;
+
+ // create a test folder
+ Folder testFolder = createTestFolder(session);
+
+ try
+ {
+ Map folders = new HashMap();
+ Map documents = new HashMap();
+
+ // create folders and documents
+ for (int i = 0; i < numOfObjects; i++)
+ {
+ Folder newFolder = createFolder(session, testFolder, "bufolder" + i);
+ folders.put(newFolder.getId(), newFolder);
+ Document newDocument = createDocument(session, newFolder, "budoc" + i + ".txt", CONTENT);
+ documents.put(newDocument.getId(), newDocument);
+ }
+
+ // update cmis:description of all the documents
+ List objects = new ArrayList(documents.values());
+ Map properties = new HashMap();
+ properties.put(PropertyIds.DESCRIPTION, NEW_DESCRIPTION_VALUE);
+
+ List updatedIds = session.bulkUpdateProperties(objects, properties, null, null);
+
+ // check the result
+ if (getBinding() == BindingType.WEBSERVICES)
+ {
+ addResult(createResult(INFO, "The Web Services binding does not return the updated ids."
+ + " This issue has to be clarified by the CMIS TC and the test to adopted later."));
+ }
+ else
+ {
+ if (updatedIds == null || updatedIds.isEmpty())
+ {
+ addResult(createResult(FAILURE, "Bulk Update Properties did not update any documents!"));
+ }
+ else
+ {
+ failure = createResult(FAILURE, "Bulk Update Properties did not update all test documents!");
+ addResult(assertEquals(documents.size(), updatedIds.size(), null, failure));
+ }
+ }
+
+ // check all documents
+ for (Folder folder : folders.values())
+ {
+ List children = new ArrayList();
+ for (CmisObject child : folder.getChildren(SELECT_ALL_NO_CACHE_OC))
+ {
+ children.add(child);
+ }
+
+ if (children.size() != 1)
+ {
+ String errorMessage = "Test folder should have exactly one child, but it has " + children.size() + "!";
+ addResult(createResult(FAILURE, errorMessage));
+ }
+ else
+ {
+ failure = createResult(FAILURE, "Document does not have the new description! Id: " + children.get(0).getId());
+ addResult(assertEquals(NEW_DESCRIPTION_VALUE, children.get(0).getDescription(), null, failure));
+ }
+ }
+
+ // delete folders and documents
+ for (Folder folder : folders.values())
+ {
+ folder.deleteTree(true, null, true);
+ }
+ }
+ finally
+ {
+ // delete the test folder
+ deleteTestFolder();
+ }
+
+ }
+}
\ No newline at end of file