chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1160206 - in /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck: impl/AbstractSessionTest.java tests/versioning/CheckedOutTest.java
Date Mon, 22 Aug 2011 11:18:46 GMT
Author: fmui
Date: Mon Aug 22 11:18:46 2011
New Revision: 1160206

URL: http://svn.apache.org/viewvc?rev=1160206&view=rev
Log:
TCK: added orderBy check and extended check-out documents test

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/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=1160206&r1=1160205&r2=1160206&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
Mon Aug 22 11:18:46 2011
@@ -80,6 +80,7 @@ import org.apache.chemistry.opencmis.tck
 public abstract class AbstractSessionTest extends AbstractCmisTest {
 
     public static final OperationContext SELECT_ALL_NO_CACHE_OC = new OperationContextImpl();
+    public static final OperationContext SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME;
     static {
         SELECT_ALL_NO_CACHE_OC.setFilterString("*");
         SELECT_ALL_NO_CACHE_OC.setCacheEnabled(false);
@@ -89,6 +90,9 @@ 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_ORDER_BY_NAME = new OperationContextImpl(SELECT_ALL_NO_CACHE_OC);
+        SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME.setOrderBy("cmis:name");
     }
 
     private final SessionFactory factory = SessionFactoryImpl.newInstance();
@@ -1179,7 +1183,10 @@ public abstract class AbstractSessionTes
 
         long childrenCount = 0;
         long childrenFolderCount = 0;
-        ItemIterable<CmisObject> children = folder.getChildren(SELECT_ALL_NO_CACHE_OC);
+        ItemIterable<CmisObject> children = folder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME);
+
+        int orderByNameIssues = 0;
+        String lastName = null;
 
         for (CmisObject child : children) {
             childrenCount++;
@@ -1188,11 +1195,23 @@ public abstract class AbstractSessionTes
             }
 
             checkChild(session, results, folder, child);
+
+            if (lastName != null && child.getName() != null) {
+                if (child.getName().compareToIgnoreCase(lastName) < 0) {
+                    orderByNameIssues++;
+                }
+            }
+
+            lastName = child.getName();
         }
 
         f = createResult(WARNING, "Number of children doesn't match the reported total number
of items!");
         addResult(results, assertEquals(childrenCount, children.getTotalNumItems(), null,
f));
 
+        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));
+
         // getDescendants
 
         if (isGetDescendantsSupported(session)) {

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=1160206&r1=1160205&r2=1160206&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
Mon Aug 22 11:18:46 2011
@@ -19,12 +19,14 @@
 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.WARNING;
 
 import java.util.Map;
 
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
 import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
 
 /**
@@ -41,24 +43,51 @@ public class CheckedOutTest extends Abst
 
     @Override
     public void run(Session session) {
-        ItemIterable<Document> pwcs = session.getCheckedOutDocs(SELECT_ALL_NO_CACHE_OC);
-        if (pwcs != null) {
+        // test all checked-out documents
+        int sessionCheckedOut = checkPWCs(session, session.getCheckedOutDocs(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME));
+        addResult(createInfoResult(sessionCheckedOut + " checked out documents overall."));
+
+        // test checked-out documents in root folder
+        int rootFolderCheckedOut = checkPWCs(session,
+                session.getRootFolder().getCheckedOutDocs(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME));
+        addResult(createInfoResult(rootFolderCheckedOut + " checked out documents in the
root folder."));
+    }
+
+    private int checkPWCs(Session session, ItemIterable<Document> pwcs) {
+        if (pwcs == null) {
+            return 0;
+        }
 
-            int i = 0;
-            for (Document pwc : pwcs) {
-                String[] propertiesToCheck = getAllProperties(pwc);
-                addResult(checkObject(session, pwc, propertiesToCheck, "PWC check: " + pwc.getId()));
-
-                if (pwc != null) {
-                    if (!pwc.isLatestMajorVersion()) {
-                        addResult(createResult(FAILURE, "PWC is not latest version! Id: "
+ pwc.getId()));
+        CmisTestResult f;
+
+        int i = 0;
+        int orderByNameIssues = 0;
+        String lastName = null;
+
+        for (Document pwc : pwcs) {
+            String[] propertiesToCheck = getAllProperties(pwc);
+            addResult(checkObject(session, pwc, propertiesToCheck, "PWC check: " + pwc.getId()));
+
+            if (pwc != null) {
+                f = createResult(FAILURE, "PWC is not latest version! Id: " + pwc.getId());
+                addResult(assertIsTrue(pwc.isLatestVersion(), null, f));
+
+                if (lastName != null && pwc.getName() != null) {
+                    if (pwc.getName().compareToIgnoreCase(lastName) < 0) {
+                        orderByNameIssues++;
                     }
                 }
 
-                i++;
+                lastName = pwc.getName();
             }
 
-            addResult(createInfoResult(i + " checked out documents."));
+            i++;
         }
+
+        f = createResult(WARNING,
+                "Checked-out documents should be ordered by cmis:name, but they are not!
(It might be a collation mismtach.)");
+        addResult(assertEquals(0, orderByNameIssues, null, f));
+
+        return i;
     }
 }



Mime
View raw message