You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/09/24 21:13:10 UTC
svn commit: r1389521 - in
/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud:
CRUDTestGroup.java CreateDocumentWithoutContent.java
SetAndDeleteContentTest.java
Author: fmui
Date: Mon Sep 24 19:13:10 2012
New Revision: 1389521
URL: http://svn.apache.org/viewvc?rev=1389521&view=rev
Log:
TCK: Added document without content test
Added:
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateDocumentWithoutContent.java
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/SetAndDeleteContentTest.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=1389521&r1=1389520&r2=1389521&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 Mon Sep 24 19:13:10 2012
@@ -36,6 +36,7 @@ public class CRUDTestGroup extends Abstr
addTest(new CreateAndDeleteFolderTest());
addTest(new CreateAndDeleteDocumentTest());
addTest(new CreateBigDocument());
+ addTest(new CreateDocumentWithoutContent());
addTest(new NameCharsetTest());
addTest(new CreateAndDeleteRelationshipTest());
addTest(new UpdateSmokeTest());
Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateDocumentWithoutContent.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/CreateDocumentWithoutContent.java?rev=1389521&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateDocumentWithoutContent.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateDocumentWithoutContent.java Mon Sep 24 19:13:10 2012
@@ -0,0 +1,112 @@
+/*
+ * 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 static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
+
+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.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Document without content test.
+ */
+public class CreateDocumentWithoutContent extends AbstractSessionTest {
+
+ @Override
+ public void init(Map<String, String> parameters) {
+ super.init(parameters);
+ setName("Create Document without Content Test");
+ setDescription("Creates a document without content and deletes it.");
+ }
+
+ @Override
+ public void run(Session session) {
+ CmisTestResult f;
+
+ String objectTypeId = getDocumentTestTypeId();
+
+ 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;
+
+ if (docType.getContentStreamAllowed() == ContentStreamAllowed.REQUIRED) {
+ addResult(createResult(SKIPPED,
+ "The test document type does not support documents without content. Test skipped!"));
+ return;
+ }
+
+ // create a test folder
+ Folder testFolder = createTestFolder(session);
+
+ try {
+ String name = "nocontent";
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(PropertyIds.NAME, name);
+ properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
+
+ VersioningState versioningState = (Boolean.TRUE.equals(docType.isVersionable()) ? VersioningState.MAJOR
+ : VersioningState.NONE);
+
+ // create and fetch the document
+ ObjectId id = session.createDocument(properties, testFolder, null, versioningState);
+ Document doc = (Document) session.getObject(id, SELECT_ALL_NO_CACHE_OC);
+
+ // check the new document
+ addResult(checkObject(session, doc, getAllProperties(doc), "New document object spec compliance"));
+
+ // check the MIME type
+ f = createResult(FAILURE, "The document has no content but a MIME type!", true);
+ assertNull(doc.getContentStreamMimeType(), null, f);
+
+ // check the content size
+ if (doc.getContentStreamLength() == 0) {
+ addResult(createResult(WARNING, "The document has no content but the content length is set to 0! "
+ + "The content length shouldn't be set."));
+ } else if (doc.getContentStreamLength() > 0) {
+ addResult(createResult(FAILURE, "The document has no content but the content length is set and >0! "
+ + "(content length: " + doc.getContentStreamLength() + ")"));
+ }
+
+ // delete it
+ doc.delete(true);
+ } finally {
+ // delete the test folder
+ deleteTestFolder();
+ }
+ }
+}
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=1389521&r1=1389520&r2=1389521&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 Mon Sep 24 19:13:10 2012
@@ -64,7 +64,7 @@ public class SetAndDeleteContentTest ext
CmisTestResult f;
if (getContentStreamUpdatesCapbility(session) == CapabilityContentStreamUpdates.NONE) {
- addResult(createInfoResult("Stream updates are not supported. Test skipped!"));
+ addResult(createResult(SKIPPED, "Stream updates are not supported. Test skipped!"));
return;
}