Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D00CD9FBB for ; Mon, 17 Oct 2011 11:19:29 +0000 (UTC) Received: (qmail 87569 invoked by uid 500); 17 Oct 2011 11:19:29 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 87533 invoked by uid 500); 17 Oct 2011 11:19:29 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 87524 invoked by uid 99); 17 Oct 2011 11:19:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2011 11:19:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2011 11:19:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9EB61238889B; Mon, 17 Oct 2011 11:19:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1185106 - /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java Date: Mon, 17 Oct 2011 11:19:00 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111017111900.9EB61238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmui Date: Mon Oct 17 11:19:00 2011 New Revision: 1185106 URL: http://svn.apache.org/viewvc?rev=1185106&view=rev Log: TCK: CMIS-451: added a check if setContentStream() created a new version Modified: 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/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=1185106&r1=1185105&r2=1185106&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 Oct 17 11:19:00 2011 @@ -26,13 +26,16 @@ 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; 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.data.ContentStream; import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition; +import org.apache.chemistry.opencmis.commons.enums.BindingType; import org.apache.chemistry.opencmis.commons.enums.CapabilityContentStreamUpdates; import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed; import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException; @@ -110,11 +113,47 @@ public class SetAndDeleteContentTest ext ContentStream contentStream = new ContentStreamImpl(workDoc.getName(), BigInteger.valueOf(contentBytes.length), "text/plain", new ByteArrayInputStream(contentBytes)); - workDoc.setContentStream(contentStream, true, true); + ObjectId newObjectId = workDoc.setContentStream(contentStream, true, true); + + // setContentStream may have created a new version + Document contentDoc = workDoc; + if (newObjectId != null) { + // -> Non AtomPub binding + if (!workDoc.getId().equals(newObjectId.getId())) { + if (checkedout) { + addResult(createResult(FAILURE, "setContentStream() created a new version from a PWC!")); + } else { + contentDoc = (Document) session.getObject(newObjectId, SELECT_ALL_NO_CACHE_OC); + addResult(checkObject(session, contentDoc, getAllProperties(contentDoc), + "Version created by setContentStream() compliance")); + } + } + } else { + if (getBinding() != BindingType.ATOMPUB) { + addResult(createResult(FAILURE, "setContentStream() did not return an object id!")); + } + + // -> AtomPub binding or incompliant other binding + if (checkedout) { + // we cannot check if the repository does the right thing, + // but if there is a problem the versioning tests should + // catch it + } else if (Boolean.TRUE.equals(docType.isVersionable())) { + List versions = workDoc.getAllVersions(); + if (versions == null || versions.isEmpty()) { + addResult(createResult(FAILURE, + "setContentStream() created a new version but the version history is empty!")); + } else if (!workDoc.getId().equals(versions.get(0).getId())) { + contentDoc = (Document) session.getObject(versions.get(0), SELECT_ALL_NO_CACHE_OC); + addResult(checkObject(session, contentDoc, getAllProperties(contentDoc), + "Version created by setContentStream() compliance")); + } + } + } // test new content try { - String content = getStringFromContentStream(workDoc.getContentStream()); + String content = getStringFromContentStream(contentDoc.getContentStream()); f = createResult(FAILURE, "Document content doesn't match the content set by setContentStream()!"); addResult(assertEquals(CONTENT2, content, null, f)); } catch (IOException e) {