chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1495042 - in /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck: impl/ tests/crud/ tests/versioning/
Date Thu, 20 Jun 2013 15:03:36 GMT
Author: fmui
Date: Thu Jun 20 15:03:36 2013
New Revision: 1495042

URL: http://svn.apache.org/r1495042
Log:
CMIS-678: TCK: only set OrderBy parameter if the repository supports it

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
    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/CheckedOutTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.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/impl/AbstractSessionTest.java?rev=1495042&r1=1495041&r2=1495042&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
Thu Jun 20 15:03:36 2013
@@ -23,6 +23,7 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.UNEXPECTED_EXCEPTION;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.INFO;
 
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
@@ -76,6 +77,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.Action;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityOrderBy;
 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
@@ -107,6 +109,7 @@ public abstract class AbstractSessionTes
         SELECT_ALL_NO_CACHE_OC.setIncludePolicies(true);
         SELECT_ALL_NO_CACHE_OC.setIncludeRelationships(IncludeRelationships.BOTH);
         SELECT_ALL_NO_CACHE_OC.setRenditionFilterString("*");
+        SELECT_ALL_NO_CACHE_OC.setOrderBy(null);
 
         SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME = new OperationContextImpl(SELECT_ALL_NO_CACHE_OC);
         SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME.setOrderBy("cmis:name");
@@ -759,6 +762,14 @@ public abstract class AbstractSessionTes
         return cap.isGetFolderTreeSupported().booleanValue();
     }
 
+    protected boolean isOrderByNameSupported(Session session) {
+        if (session.getRepositoryInfo().getCapabilities().getOrderByCapability() == CapabilityOrderBy.NONE)
{
+            return false;
+        }
+
+        return true;
+    }
+
     protected boolean hasRelationships(Session session) {
         if (supportsRelationships == null) {
             supportsRelationships = Boolean.FALSE;
@@ -1781,9 +1792,13 @@ public abstract class AbstractSessionTes
 
         // getChildren
 
+        boolean supportsOrderByName = isOrderByNameSupported(session);
+        OperationContext orderContext = (supportsOrderByName ? SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME
+                : SELECT_ALL_NO_CACHE_OC);
+
         long childrenCount = 0;
         long childrenFolderCount = 0;
-        ItemIterable<CmisObject> children = folder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME);
+        ItemIterable<CmisObject> children = folder.getChildren(orderContext);
 
         int orderByNameIssues = 0;
         String lastName = null;
@@ -1812,9 +1827,13 @@ public abstract class AbstractSessionTes
             addResult(results, createResult(WARNING, "getChildren did not report the total
number of items!"));
         }
 
-        f = createResult(WARNING,
-                "Children should be ordered by cmis:name, but they are not! (It might be
a collation mismtach.)");
-        addResult(results, assertEquals(0, orderByNameIssues, null, f));
+        if (supportsOrderByName) {
+            f = createResult(WARNING,
+                    "Children should be ordered by cmis:name, but they are not! (It might
be a collation mismtach.)");
+            addResult(results, assertEquals(0, orderByNameIssues, null, f));
+        } else {
+            addResult(results, createResult(INFO, "Repository doesn't support Order By for
getChildren()."));
+        }
 
         // getDescendants
 
@@ -2047,7 +2066,7 @@ public abstract class AbstractSessionTes
 
             f = createResult(FAILURE, "Query name contains invalid character: '\\n'");
             addResult(results, assertIsTrue(queryName.indexOf('\n') < 0, null, f));
-            
+
             f = createResult(FAILURE, "Query name contains invalid character: '\\r'");
             addResult(results, assertIsTrue(queryName.indexOf('\r') < 0, null, f));
         }

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=1495042&r1=1495041&r2=1495042&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
Thu Jun 20 15:03:36 2013
@@ -35,6 +35,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.DocumentType;
 import org.apache.chemistry.opencmis.client.api.Folder;
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
@@ -60,6 +61,9 @@ public class CreateAndDeleteDocumentTest
 
         int numOfDocuments = 20;
 
+        OperationContext orderContext = (isOrderByNameSupported(session) ? SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME
+                : SELECT_ALL_NO_CACHE_OC);
+        
         // create a test folder
         Folder testFolder = createTestFolder(session);
 
@@ -115,7 +119,7 @@ public class CreateAndDeleteDocumentTest
             CmisObject lastObject = null;
 
             int count = 0;
-            ItemIterable<CmisObject> page1 = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME).getPage(
+            ItemIterable<CmisObject> page1 = testFolder.getChildren(orderContext).getPage(
                     pageSize);
             for (CmisObject child : page1) {
                 count++;
@@ -137,7 +141,7 @@ public class CreateAndDeleteDocumentTest
 
             // check second page
             count = 0;
-            ItemIterable<CmisObject> page2 = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME)
+            ItemIterable<CmisObject> page2 = testFolder.getChildren(orderContext)
                     .skipTo(pageSize - 1).getPage(pageSize);
             for (CmisObject child : page2) {
                 count++;
@@ -164,7 +168,7 @@ public class CreateAndDeleteDocumentTest
 
             // check third page
             count = 0;
-            ItemIterable<CmisObject> page3 = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME)
+            ItemIterable<CmisObject> page3 = testFolder.getChildren(orderContext)
                     .skipTo(numOfDocuments - 5).getPage(10);
             for (@SuppressWarnings("unused")
             CmisObject child : page3) {
@@ -187,7 +191,7 @@ public class CreateAndDeleteDocumentTest
 
             // check non-existing page
             count = 0;
-            ItemIterable<CmisObject> pageNotExisting = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME)
+            ItemIterable<CmisObject> pageNotExisting = testFolder.getChildren(orderContext)
                     .skipTo(100000).getPage(pageSize);
             for (@SuppressWarnings("unused")
             CmisObject child : pageNotExisting) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/CheckedOutTest.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/CheckedOutTest.java?rev=1495042&r1=1495041&r2=1495042&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/CheckedOutTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/CheckedOutTest.java
Thu Jun 20 15:03:36 2013
@@ -19,6 +19,7 @@
 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.INFO;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
 
 import java.util.Map;
@@ -27,6 +28,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.Folder;
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
 import org.apache.chemistry.opencmis.client.api.ObjectId;
+import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
@@ -49,6 +51,10 @@ public class CheckedOutTest extends Abst
     public void run(Session session) {
         CmisTestResult f;
 
+        boolean supportsOrderByName = isOrderByNameSupported(session);
+        OperationContext orderContext = (supportsOrderByName ? SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME
+                : SELECT_ALL_NO_CACHE_OC);
+
         Document pwc = null;
         try {
             // create folder and a checked-out document
@@ -64,7 +70,7 @@ public class CheckedOutTest extends Abst
             }
 
             // test all checked-out documents
-            int sessionCheckedOut = checkPWCs(session, session.getCheckedOutDocs(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME));
+            int sessionCheckedOut = checkPWCs(session, session.getCheckedOutDocs(orderContext),
supportsOrderByName);
             addResult(createInfoResult(sessionCheckedOut + " checked out document(s) overall."));
 
             if (pwc != null) {
@@ -73,8 +79,8 @@ public class CheckedOutTest extends Abst
             }
 
             // test checked-out documents in the test folder
-            int testFolderCheckedOut = checkPWCs(session,
-                    testFolder.getCheckedOutDocs(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME));
+            int testFolderCheckedOut = checkPWCs(session, testFolder.getCheckedOutDocs(orderContext),
+                    supportsOrderByName);
             addResult(createInfoResult(testFolderCheckedOut + " checked out document(s) in
the test folder."));
 
             if (pwc != null) {
@@ -96,7 +102,7 @@ public class CheckedOutTest extends Abst
         }
     }
 
-    private int checkPWCs(Session session, ItemIterable<Document> pwcs) {
+    private int checkPWCs(Session session, ItemIterable<Document> pwcs, boolean checkOrder)
{
         if (pwcs == null) {
             return 0;
         }
@@ -139,9 +145,13 @@ public class CheckedOutTest extends Abst
             i++;
         }
 
-        f = createResult(WARNING,
-                "Checked-out documents should be ordered by cmis:name, but they are not!
(It might be a collation mismatch.)");
-        addResult(assertEquals(0, orderByNameIssues, null, f));
+        if (checkOrder) {
+            f = createResult(WARNING,
+                    "Checked-out documents should be ordered by cmis:name, but they are not!
(It might be a collation mismatch.)");
+            addResult(assertEquals(0, orderByNameIssues, null, f));
+        } else {
+            addResult(createResult(INFO, "Repository doesn't support Order By for getCheckedOutDocs()."));
+        }
 
         return i;
     }



Mime
View raw message