chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1431361 - in /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests: basics/TypesTest.java crud/SetAndDeleteContentTest.java
Date Thu, 10 Jan 2013 13:54:21 GMT
Author: fmui
Date: Thu Jan 10 13:54:20 2013
New Revision: 1431361

URL: http://svn.apache.org/viewvc?rev=1431361&view=rev
Log:
TCK: added more CMIS 1.1 tests

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/TypesTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/TypesTest.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/basics/TypesTest.java?rev=1431361&r1=1431360&r2=1431361&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/TypesTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/TypesTest.java
Thu Jan 10 13:54:20 2013
@@ -22,8 +22,10 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
 import org.apache.chemistry.opencmis.client.api.ObjectType;
@@ -52,6 +54,31 @@ public class TypesTest extends AbstractS
     public void run(Session session) {
         CmisTestResult failure;
 
+        // check base types
+        Set<String> cmisTypes = new HashSet<String>();
+        cmisTypes.add(BaseTypeId.CMIS_DOCUMENT.value());
+        cmisTypes.add(BaseTypeId.CMIS_FOLDER.value());
+        cmisTypes.add(BaseTypeId.CMIS_RELATIONSHIP.value());
+        cmisTypes.add(BaseTypeId.CMIS_POLICY.value());
+
+        if (session.getRepositoryInfo().getCmisVersion() != CmisVersion.CMIS_1_0) {
+            cmisTypes.add(BaseTypeId.CMIS_ITEM.value());
+            cmisTypes.add(BaseTypeId.CMIS_SECONDARY.value());
+        }
+
+        for (TypeDefinition typeDef : session.getTypeChildren(null, false)) {
+            String typeId = typeDef.getId();
+
+            if (typeId == null || !cmisTypes.contains(typeId)) {
+                addResult(createResult(FAILURE, "Base type has an invalid id: " + typeId));
+            }
+
+            if (typeDef.getPropertyDefinitions() != null) {
+                addResult(createResult(WARNING, "Property type definitions were not requested
but delivered. Type id: "
+                        + typeId));
+            }
+        }
+
         // document
         try {
             TypeDefinition documentType = session.getTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.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/SetAndDeleteContentTest.java?rev=1431361&r1=1431360&r2=1431361&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java
Thu Jan 10 13:54:20 2013
@@ -25,7 +25,6 @@ import static org.apache.chemistry.openc
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.math.BigInteger;
 import java.util.List;
 import java.util.Map;
 
@@ -38,9 +37,9 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.Action;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
 import org.apache.chemistry.opencmis.commons.enums.CapabilityContentStreamUpdates;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
 
@@ -51,12 +50,13 @@ public class SetAndDeleteContentTest ext
 
     private static final String CONTENT1 = "one";
     private static final String CONTENT2 = "two";
+    private static final String CONTENT3 = "three";
 
     @Override
     public void init(Map<String, String> parameters) {
         super.init(parameters);
-        setName("Set and Delete content Test");
-        setDescription("Creates a new document and tries to set and delete its content.");
+        setName("Set, Append, and Delete Content Test");
+        setDescription("Creates a new document and tries to set, append, and delete its content.");
     }
 
     @Override
@@ -126,8 +126,8 @@ public class SetAndDeleteContentTest ext
             } catch (Exception e) {
             }
 
-            ContentStream contentStream = new ContentStreamImpl(workDoc.getName(),
-                    BigInteger.valueOf(contentBytes.length), "text/plain", new ByteArrayInputStream(contentBytes));
+            ContentStream contentStream = session.getObjectFactory().createContentStream(workDoc.getName(),
+                    contentBytes.length, "text/plain", new ByteArrayInputStream(contentBytes));
 
             ObjectId newObjectId = workDoc.setContentStream(contentStream, true, true);
 
@@ -149,6 +149,35 @@ public class SetAndDeleteContentTest ext
                         "Document content couldn't be read! Exception: " + e.getMessage(),
e, true));
             }
 
+            // test appendContentStream
+            if (session.getRepositoryInfo().getCmisVersion() != CmisVersion.CMIS_1_0) {
+                contentBytes = new byte[0];
+                try {
+                    contentBytes = CONTENT3.getBytes("UTF-8");
+                } catch (Exception e) {
+                }
+
+                contentStream = session.getObjectFactory().createContentStream(contentDoc.getName(),
+                        contentBytes.length, "text/plain", new ByteArrayInputStream(contentBytes));
+
+                newObjectId = contentDoc.appendContentStream(contentStream, true);
+
+                // appendContentStream may have created a new version
+                Document contentDoc2 = getNewVersion(session, contentDoc, checkedout, newObjectId,
+                        "appendContentStream()");
+
+                // test new content
+                try {
+                    String content = getStringFromContentStream(contentDoc2.getContentStream());
+                    f = createResult(FAILURE,
+                            "Document content doesn't match the content set by setContentStream()
followed by appendContentStream()!");
+                    addResult(assertEquals(CONTENT2 + CONTENT3, content, null, f));
+                } catch (IOException e) {
+                    addResult(createResult(UNEXPECTED_EXCEPTION,
+                            "Document content couldn't be read! Exception: " + e.getMessage(),
e, true));
+                }
+            }
+
             // cancel a possible check out
             if (checkedout) {
                 workDoc.cancelCheckOut();



Mime
View raw message