chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1161200 - in /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests: crud/ versioning/
Date Wed, 24 Aug 2011 16:47:57 GMT
Author: fmui
Date: Wed Aug 24 16:47:56 2011
New Revision: 1161200

URL: http://svn.apache.org/viewvc?rev=1161200&view=rev
Log:
added more TCK tests (versioning and updateProperties)

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java
  (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.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/versioning/VersioningTestGroup.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=1161200&r1=1161199&r2=1161200&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 Aug 24 16:47:56 2011
@@ -35,6 +35,7 @@ public class CRUDTestGroup extends Abstr
 
         addTest(new CreateAndDeleteFolderTest());
         addTest(new CreateAndDeleteDocumentTest());
+        addTest(new UpdateSmokeTest());
         addTest(new SetAndDeleteContentTest());
         addTest(new CopyTest());
         addTest(new MoveTest());

Added: 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=1161200&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/UpdateSmokeTest.java
Wed Aug 24 16:47:56 2011
@@ -0,0 +1,80 @@
+/*
+ * 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.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.Session;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Copy test.
+ */
+public class UpdateSmokeTest extends AbstractSessionTest {
+
+    private static final String NAME1 = "updatetest1.txt";
+    private static final String NAME2 = "updatetest2.txt";
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Update Smoke Test");
+        setDescription("Creates a document, updates its name and finally deletes it.");
+    }
+
+    @Override
+    public void run(Session session) {
+        CmisTestResult f;
+
+        try {
+            // create folders
+            Folder testFolder = createTestFolder(session);
+
+            // create document
+            Document doc1 = createDocument(session, testFolder, NAME1, "rename me!");
+
+            f = createResult(FAILURE, "Document name doesn't match with given name!");
+            addResult(assertEquals(NAME1, doc1.getName(), null, f));
+
+            // update
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put(PropertyIds.NAME, NAME2);
+
+            Document doc2 = (Document) doc1.updateProperties(properties);
+
+            addResult(checkObject(session, doc2, getAllProperties(doc2), "Updated document
compliance"));
+
+            f = createResult(FAILURE, "Document name doesn't match updated value!");
+            addResult(assertEquals(NAME2, doc2.getName(), null, f));
+
+            // delete
+            deleteObject(doc2);
+        } finally {
+            // clean up
+            deleteTestFolder();
+        }
+    }
+}

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

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.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/versioning/VersioningSmokeTest.java?rev=1161200&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.java
Wed Aug 24 16:47:56 2011
@@ -0,0 +1,143 @@
+/*
+ * 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.versioning;
+
+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.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.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Checked out test.
+ */
+public class VersioningSmokeTest extends AbstractSessionTest {
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Versioning Smoke Test");
+        setDescription("Creates a document, checks it out, cancels the check out, checks
it out again and finally checks it in.");
+    }
+
+    @Override
+    public void run(Session session) {
+        CmisTestResult f;
+
+        try {
+            // create folder and document
+            Folder testFolder = createTestFolder(session);
+            Document doc = createDocument(session, testFolder, "versioningtest.txt", "versioning");
+            DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType();
+
+            if (!docType.isVersionable()) {
+                addResult(createResult(SKIPPED, "Test type is not versionable. Test skipped!"));
+                doc.delete(true);
+                return;
+            }
+
+            // check out
+            ObjectId pwcId = doc.checkOut();
+            Document pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC);
+
+            addResult(checkObject(session, pwc, getAllProperties(pwc), "PWC spec compliance
- test 1"));
+
+            checkCheckedOut(pwc);
+
+            // cancel checkout
+            pwc.cancelCheckOut();
+
+            doc.refresh();
+            checkCheckedIn(doc);
+
+            // check out again
+            pwcId = doc.checkOut();
+            pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC);
+
+            addResult(checkObject(session, pwc, getAllProperties(pwc), "PWC spec compliance
- test 2"));
+
+            checkCheckedOut(pwc);
+
+            // check in
+            ObjectId newVersionId = pwc.checkIn(true, null, null, "Test Version 2");
+            Document newVersion = (Document) session.getObject(newVersionId, SELECT_ALL_NO_CACHE_OC);
+
+            addResult(checkObject(session, newVersion, getAllProperties(newVersion), "New
version compliance"));
+
+            checkCheckedIn(newVersion);
+
+            // check version history
+            List<Document> versions = newVersion.getAllVersions();
+            f = createResult(FAILURE, "Version series should have 2 versions but has " +
versions.size() + "!");
+            addResult(assertEquals(2, versions.size(), null, f));
+
+            if (versions.size() > 0) {
+                f = createResult(FAILURE,
+                        "Version history order is incorrect! The first version should be
the new version.");
+                addResult(assertEquals(newVersion.getId(), versions.get(0).getId(), null,
f));
+            }
+
+            if (versions.size() > 1) {
+                f = createResult(FAILURE,
+                        "Version history order is incorrect! The second version should be
the origin document.");
+                addResult(assertEquals(doc.getId(), versions.get(1).getId(), null, f));
+            }
+
+            // remove the document
+            deleteObject(doc);
+        } finally {
+            deleteTestFolder();
+        }
+    }
+
+    private void checkCheckedOut(Document pwc) {
+        CmisTestResult f;
+
+        f = createResult(FAILURE, "Version series has a PWC but cmis:isVersionSeriesCheckedOut
is not TRUE!");
+        addResult(assertIsTrue(pwc.isVersionSeriesCheckedOut(), null, f));
+
+        f = createResult(FAILURE, "PWC id and cmis:versionSeriesCheckedOutId don't match!");
+        addResult(assertEquals(pwc.getId(), pwc.getVersionSeriesCheckedOutId(), null, f));
+
+        f = createResult(WARNING, "PWC does not have a value for cmis:versionSeriesCheckedOutBy!");
+        addResult(assertStringNotEmpty(pwc.getVersionSeriesCheckedOutBy(), null, f));
+    }
+
+    private void checkCheckedIn(Document doc) {
+        CmisTestResult f;
+
+        f = createResult(FAILURE, "Version series is not checked out but cmis:isVersionSeriesCheckedOut
is not FALSE!");
+        addResult(assertIsFalse(doc.isVersionSeriesCheckedOut(), null, f));
+
+        f = createResult(FAILURE, "Version series is not checked out but cmis:versionSeriesCheckedOutId
has a value!");
+        addResult(assertNull(doc.getVersionSeriesCheckedOutId(), null, f));
+
+        f = createResult(FAILURE, "Version series is not checked out but cmis:versionSeriesCheckedOutBy
has a value!");
+        addResult(assertNull(doc.getVersionSeriesCheckedOutBy(), null, f));
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.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/versioning/VersioningTestGroup.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/versioning/VersioningTestGroup.java?rev=1161200&r1=1161199&r2=1161200&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningTestGroup.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningTestGroup.java
Wed Aug 24 16:47:56 2011
@@ -33,6 +33,7 @@ public class VersioningTestGroup extends
         setName("Versioning Test Group");
         setDescription("Versioning tests.");
 
+        addTest(new VersioningSmokeTest());
         addTest(new CheckedOutTest());
     }
 }



Mime
View raw message