chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1372076 - in /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests: crud/CreateAndDeleteDocumentTest.java versioning/VersioningSmokeTest.java
Date Sun, 12 Aug 2012 11:57:27 GMT
Author: fmui
Date: Sun Aug 12 11:57:26 2012
New Revision: 1372076

URL: http://svn.apache.org/viewvc?rev=1372076&view=rev
Log:
TCK improvements

Modified:
    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/versioning/VersioningSmokeTest.java

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=1372076&r1=1372075&r2=1372076&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
Sun Aug 12 11:57:26 2012
@@ -116,10 +116,10 @@ public class CreateAndDeleteDocumentTest
                 addResult(assertEquals((long) numOfDocuments, page1.getTotalNumItems(), null,
f));
             }
 
-            f = createResult(FAILURE, "hasMoreItems of the first test page must be 'true'!");
+            f = createResult(FAILURE, "hasMoreItems of the first test page must be TRUE!");
             addResult(assertEquals(true, page1.getHasMoreItems(), null, f));
 
-            // check escond page
+            // check second page
             count = 0;
             ItemIterable<CmisObject> page2 = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME)
                     .skipTo(pageSize - 1).getPage(pageSize);
@@ -143,31 +143,54 @@ public class CreateAndDeleteDocumentTest
                 addResult(assertEquals((long) numOfDocuments, page2.getTotalNumItems(), null,
f));
             }
 
-            f = createResult(FAILURE, "hasMoreItems of the second test page must be 'true'!");
+            f = createResult(FAILURE, "hasMoreItems of the second test page must be TRUE!");
             addResult(assertEquals(true, page2.getHasMoreItems(), null, f));
 
-            // check non-existing page
+            // check third page
             count = 0;
             ItemIterable<CmisObject> page3 = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME)
-                    .skipTo(100000).getPage(pageSize);
+                    .skipTo(numOfDocuments - 5).getPage(10);
             for (@SuppressWarnings("unused")
             CmisObject child : page3) {
                 count++;
             }
 
-            f = createResult(FAILURE, "The page size of a non-existing page must be 0!");
-            addResult(assertEquals(0, count, null, f));
+            f = createResult(FAILURE,
+                    "Returned number of children should be 5 because page startetd at (numOfDocuments
- 5).");
+            addResult(assertEquals(5, count, null, f));
 
             if (page3.getTotalNumItems() == -1) {
-                addResult(createResult(WARNING, "Repository did not return numItems for a
non-existing page."));
+                addResult(createResult(WARNING, "Repository did not return numItems for the
third test page."));
             } else {
                 f = createResult(FAILURE, "Returned numItems doesn't match the number of
documents!");
                 addResult(assertEquals((long) numOfDocuments, page3.getTotalNumItems(), null,
f));
             }
 
-            f = createResult(FAILURE, "hasMoreItems of a non-existing page must be 'false'!");
+            f = createResult(FAILURE, "hasMoreItems of the third test page must be FALSE!");
             addResult(assertEquals(false, page3.getHasMoreItems(), null, f));
 
+            // check non-existing page
+            count = 0;
+            ItemIterable<CmisObject> pageNotExisting = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME)
+                    .skipTo(100000).getPage(pageSize);
+            for (@SuppressWarnings("unused")
+            CmisObject child : pageNotExisting) {
+                count++;
+            }
+
+            f = createResult(FAILURE, "The page size of a non-existing page must be 0!");
+            addResult(assertEquals(0, count, null, f));
+
+            if (pageNotExisting.getTotalNumItems() == -1) {
+                addResult(createResult(WARNING, "Repository did not return numItems for a
non-existing page."));
+            } else {
+                f = createResult(FAILURE, "Returned numItems doesn't match the number of
documents!");
+                addResult(assertEquals((long) numOfDocuments, pageNotExisting.getTotalNumItems(),
null, f));
+            }
+
+            f = createResult(FAILURE, "hasMoreItems of a non-existing page must be FALSE!");
+            addResult(assertEquals(false, pageNotExisting.getHasMoreItems(), null, f));
+
             // check content
             for (Document document : documents.values()) {
                 ContentStream contentStream = document.getContentStream();

Modified: 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=1372076&r1=1372075&r2=1372076&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersioningSmokeTest.java
Sun Aug 12 11:57:26 2012
@@ -19,9 +19,11 @@
 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.OK;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -32,6 +34,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+import org.apache.chemistry.opencmis.tck.impl.CmisTestResultImpl;
 
 /**
  * Checked out test.
@@ -61,6 +64,14 @@ public class VersioningSmokeTest extends
                 return;
             }
 
+            // gather properties for later
+            String[] propertiesToCheck = new String[doc.getType().getPropertyDefinitions().size()];
+
+            int i = 0;
+            for (String propId : doc.getType().getPropertyDefinitions().keySet()) {
+                propertiesToCheck[i++] = propId;
+            }
+
             // check out
             ObjectId pwcId = doc.checkOut();
             Document pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC);
@@ -69,6 +80,11 @@ public class VersioningSmokeTest extends
 
             checkCheckedOut(pwc);
 
+            // check version series
+            // addResult(checkVersionSeries(session,
+            // pwc.getAllVersions(SELECT_ALL_NO_CACHE_OC), propertiesToCheck,
+            // "Test version series after check out"));
+
             // cancel checkout
             pwc.cancelCheckOut();
 
@@ -92,7 +108,7 @@ public class VersioningSmokeTest extends
             checkCheckedIn(newVersion);
 
             // check version history
-            List<Document> versions = newVersion.getAllVersions();
+            List<Document> versions = newVersion.getAllVersions(SELECT_ALL_NO_CACHE_OC);
             f = createResult(FAILURE, "Version series should have 2 versions but has " +
versions.size() + "!");
             addResult(assertEquals(2, versions.size(), null, f));
 
@@ -100,6 +116,14 @@ public class VersioningSmokeTest extends
                 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));
+
+                f = createResult(FAILURE,
+                        "The new version should be the latest version, but cmis:isLatestVersion
is not TRUE.");
+                addResult(assertEquals(true, versions.get(0).isLatestVersion(), null, f));
+
+                f = createResult(FAILURE,
+                        "The new version should be the latest major version, but cmis:isLatestMajorVersion
is not TRUE.");
+                addResult(assertEquals(true, versions.get(0).isLatestMajorVersion(), null,
f));
             }
 
             if (versions.size() > 1) {
@@ -108,6 +132,10 @@ public class VersioningSmokeTest extends
                 addResult(assertEquals(doc.getId(), versions.get(1).getId(), null, f));
             }
 
+            // check version series
+            addResult(checkVersionSeries(session, pwc.getAllVersions(SELECT_ALL_NO_CACHE_OC),
propertiesToCheck,
+                    "Test version series after check in"));
+
             // remove the document
             deleteObject(doc);
         } finally {
@@ -144,4 +172,27 @@ public class VersioningSmokeTest extends
         f = createResult(FAILURE, "Version series is not checked out but cmis:versionSeriesCheckedOutBy
has a value!");
         addResult(assertNull(doc.getVersionSeriesCheckedOutBy(), null, f));
     }
+
+    private CmisTestResult checkVersionSeries(Session session, List<Document> versions,
String[] properties,
+            String message) {
+        List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+
+        int countLatest = 0;
+        for (Document version : versions) {
+            addResult(results, checkObject(session, version, properties, "Version object
check: " + version.getId()));
+
+            if (Boolean.TRUE.equals(version.isLatestVersion())) {
+                countLatest++;
+            }
+        }
+
+        CmisTestResult f = createResult(FAILURE, "A version series should have one latest
version, but it has "
+                + countLatest + "!");
+        addResult(results, assertEquals(1, countLatest, null, f));
+
+        CmisTestResultImpl result = createResult(getWorst(results), message);
+        result.getChildren().addAll(results);
+
+        return (result.getStatus().getLevel() <= OK.getLevel() ? null : result);
+    }
 }



Mime
View raw message