chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1459212 - in /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud: BulkUpdatePropertiesTest.java CRUDTestGroup.java
Date Thu, 21 Mar 2013 09:59:48 GMT
Author: fmui
Date: Thu Mar 21 09:59:47 2013
New Revision: 1459212

URL: http://svn.apache.org/r1459212
Log:
TCK: added bulk update properties test

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/BulkUpdatePropertiesTest.java
  (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/BulkUpdatePropertiesTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/BulkUpdatePropertiesTest.java?rev=1459212&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/BulkUpdatePropertiesTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/BulkUpdatePropertiesTest.java
Thu Mar 21 09:59:47 2013
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.tck.tests.crud;
+
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+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.CmisVersion;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+public class BulkUpdatePropertiesTest extends AbstractSessionTest {
+
+    private static final String CONTENT = "Bluk update test content.";
+    private static final String NEW_NAME = "bunewname.txt";
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Bulk Update Properties Test");
+        setDescription("Creates a few folders and documents, renames all documents at once,
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 supporetd by CMIS
1.0. Test skipped!"));
+            return;
+        }
+
+        CmisTestResult failure = null;
+        int numOfObjects = 20;
+
+        // create a test folder
+        Folder testFolder = createTestFolder(session);
+
+        try {
+            Map<String, Folder> folders = new HashMap<String, Folder>();
+            Map<String, Document> documents = new HashMap<String, Document>();
+
+            // 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:name of all the documents
+            List<CmisObject> objects = new ArrayList<CmisObject>(documents.values());
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put(PropertyIds.NAME, NEW_NAME);
+
+            List<BulkUpdateObjectIdAndChangeToken> updatedIds = session.bulkUpdateProperties(objects,
properties, null,
+                    null);
+
+            // check the result
+            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<CmisObject> children = new ArrayList<CmisObject>();
+                for (CmisObject child : folder.getChildren(SELECT_ALL_NO_CACHE_OC)) {
+                    children.add(child);
+                }
+
+                if (children.size() != 1) {
+                    addResult(createResult(FAILURE,
+                            "Test folder should have exactly one child, but it has " + children.size()
+ "!"));
+                } else {
+                    failure = createResult(FAILURE, "Document does not have the new name!
Id: "
+                            + children.get(0).getId());
+                    addResult(assertEquals(NEW_NAME, children.get(0).getName(), null, failure));
+                }
+            }
+
+            // delete folders and documents
+            for (Folder folder : folders.values()) {
+                folder.deleteTree(true, null, true);
+            }
+        } finally {
+            // delete the test folder
+            deleteTestFolder();
+        }
+
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/BulkUpdatePropertiesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java?rev=1459212&r1=1459211&r2=1459212&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
Thu Mar 21 09:59:47 2013
@@ -41,6 +41,7 @@ public class CRUDTestGroup extends Abstr
         addTest(new CreateAndDeleteRelationshipTest());
         addTest(new CreateAndDeleteItemTest());
         addTest(new UpdateSmokeTest());
+        addTest(new BulkUpdatePropertiesTest());
         addTest(new SetAndDeleteContentTest());
         addTest(new ContentRangesTest());
         addTest(new CopyTest());



Mime
View raw message