chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1235823 - /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/
Date Wed, 25 Jan 2012 17:00:14 GMT
Author: fmui
Date: Wed Jan 25 17:00:13 2012
New Revision: 1235823

URL: http://svn.apache.org/viewvc?rev=1235823&view=rev
Log:
- TCK enhancements

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateBigDocument.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
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java

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=1235823&r1=1235822&r2=1235823&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
Wed Jan 25 17:00:13 2012
@@ -35,6 +35,7 @@ public class CRUDTestGroup extends Abstr
 
         addTest(new CreateAndDeleteFolderTest());
         addTest(new CreateAndDeleteDocumentTest());
+        addTest(new CreateBigDocument());
         addTest(new CreateAndDeleteRelationshipTest());
         addTest(new UpdateSmokeTest());
         addTest(new SetAndDeleteContentTest());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.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/CreateAndDeleteDocumentTest.java?rev=1235823&r1=1235822&r2=1235823&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java
Wed Jan 25 17:00:13 2012
@@ -20,6 +20,7 @@ package org.apache.chemistry.opencmis.tc
 
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -92,12 +93,48 @@ public class CreateAndDeleteDocumentTest
                 }
             }
 
+            // check paging
+            int pageSize = 5;
+            CmisObject lastObject = null;
+
+            int count = 0;
+            ItemIterable<CmisObject> page1 = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME).getPage(
+                    pageSize);
+            for (CmisObject child : page1) {
+                count++;
+                lastObject = child;
+            }
+
+            f = createResult(FAILURE, "Returned number of children doesn't match the page
size!");
+            addResult(assertEquals(pageSize, count, null, f));
+
+            count = 0;
+            ItemIterable<CmisObject> page2 = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME)
+                    .getPage(pageSize).skipTo(pageSize - 1);
+            for (CmisObject child : page2) {
+                count++;
+
+                if (count == 1) {
+                    f = createResult(FAILURE,
+                            "Last object of the first page doesn't match the first object
of the second page.");
+                    addResult(assertEquals(lastObject.getId(), child.getId(), null, f));
+                }
+            }
+
+            f = createResult(FAILURE, "Returned number of children doesn't match the page
size!");
+            addResult(assertEquals(pageSize, count, null, f));
+
             // check content
             for (Document document : documents.values()) {
                 ContentStream contentStream = document.getContentStream();
-                if (contentStream == null) {
+                if (contentStream == null || contentStream.getStream() == null) {
                     addResult(createResult(FAILURE, "Document has no content! Id: " + document.getId()));
                     continue;
+                } else {
+                    try {
+                        contentStream.getStream().close();
+                    } catch (IOException e) {
+                    }
                 }
 
                 // TODO: content checks

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateBigDocument.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/CreateBigDocument.java?rev=1235823&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateBigDocument.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateBigDocument.java
Wed Jan 25 17:00:13 2012
@@ -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 java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Big document test.
+ */
+public class CreateBigDocument extends AbstractSessionTest {
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Create Big Document Test");
+        setDescription("Creates a 10 MiB document and deletes it.");
+    }
+
+    @Override
+    public void run(Session session) {
+        CmisTestResult f;
+
+        // create a test folder
+        Folder testFolder = createTestFolder(session);
+
+        try {
+            String name = "bigdoc";
+            String objectTypeId = getDocumentTestTypeId();
+            String mimetype = "application/octet-stream";
+
+            final long size = 10 * 1024 * 1024; // 10 MiB
+            InputStream in = new InputStream() {
+                private int counter = -1;
+
+                @Override
+                public int read() throws IOException {
+                    counter++;
+                    if (counter >= size) {
+                        return -1;
+                    }
+
+                    return '0' + (counter / 10);
+                }
+            };
+
+            // create stream and properties
+            ContentStream contentStream = session.getObjectFactory().createContentStream(name,
size, mimetype, in);
+
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put(PropertyIds.NAME, name);
+            properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
+
+            // check type
+            TypeDefinition type = session.getTypeDefinition(objectTypeId);
+            if (!(type instanceof DocumentTypeDefinition)) {
+                addResult(createResult(FAILURE, "Type is not a document type! Type: " + objectTypeId,
true));
+                return;
+            }
+
+            DocumentTypeDefinition docType = (DocumentTypeDefinition) type;
+            VersioningState versioningState = (Boolean.TRUE.equals(docType.isVersionable())
? VersioningState.MAJOR
+                    : VersioningState.NONE);
+
+            // create and fetch the document
+            ObjectId id = session.createDocument(properties, testFolder, contentStream, versioningState);
+            Document doc = (Document) session.getObject(id);
+
+            // check the new document
+            addResult(checkObject(session, doc, getAllProperties(doc), "New document object
spec compliance"));
+
+            // check the size
+            f = createResult(FAILURE, "Content stream length doesn't match the uploaded content!",
true);
+            assertEquals(size, doc.getContentStreamLength(), null, f);
+
+            // delete it
+            doc.delete(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/CreateBigDocument.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/UpdateSmokeTest.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/UpdateSmokeTest.java?rev=1235823&r1=1235822&r2=1235823&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java
Wed Jan 25 17:00:13 2012
@@ -19,6 +19,7 @@
 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.WARNING;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -85,6 +86,15 @@ public class UpdateSmokeTest extends Abs
             f = createResult(FAILURE, "Document name doesn't match updated value!");
             addResult(assertEquals(NAME2, doc2.getName(), null, f));
 
+            // update nothing
+            try {
+                properties = new HashMap<String, Object>();
+                doc2.updateProperties(properties, false);
+            } catch (Exception e) {
+                addResult(createResult(WARNING,
+                        "updateProperties without property changes returned an error: " +
e.getMessage(), e, false));
+            }
+
             // cancel a possible check out
             if (checkedout) {
                 workDoc.cancelCheckOut();



Mime
View raw message