You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2011/07/31 23:02:44 UTC

svn commit: r1152634 - in /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl: AbstractCmisTest.java AbstractSessionTest.java

Author: fmui
Date: Sun Jul 31 21:02:43 2011
New Revision: 1152634

URL: http://svn.apache.org/viewvc?rev=1152634&view=rev
Log:
TCK: added allowable action checks

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractCmisTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractCmisTest.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/AbstractCmisTest.java?rev=1152634&r1=1152633&r2=1152634&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractCmisTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractCmisTest.java Sun Jul 31 21:02:43 2011
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.chemistry.opencmis.tck.CmisTest;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
@@ -274,11 +275,41 @@ public abstract class AbstractCmisTest i
         }
 
         for (int i = 0; i < expected.size(); i++) {
-            if (!isEqual(expected, actual)) {
+            if (!isEqual(expected.get(i), actual.get(i))) {
                 return addResultChild(
                         failure,
-                        createResult(CmisTestResultStatus.INFO, "expected list item[" + i + "]: " + expected
-                                + " / actual list item[" + i + "]: " + actual));
+                        createResult(CmisTestResultStatus.INFO, "expected list item[" + i + "]: " + expected.get(i)
+                                + " / actual list item[" + i + "]: " + actual.get(i)));
+            }
+        }
+
+        return success;
+    }
+
+    protected CmisTestResult assertEqualSet(Set<?> expected, Set<?> actual, CmisTestResult success,
+            CmisTestResult failure) {
+        if (expected == null && actual == null) {
+            return success;
+        }
+
+        if (expected == null) {
+            return addResultChild(failure, createResult(CmisTestResultStatus.INFO, "Expected set is null!"));
+        }
+
+        if (actual == null) {
+            return addResultChild(failure, createResult(CmisTestResultStatus.INFO, "Actual set is null!"));
+        }
+
+        if (expected.size() != actual.size()) {
+            return addResultChild(
+                    failure,
+                    createResult(CmisTestResultStatus.INFO, "Set sizes don't match! expected: " + expected.size()
+                            + " / actual: " + actual.size()));
+        }
+
+        for (Object o : expected) {
+            if (!actual.contains(o)) {
+                return addResultChild(failure, createResult(CmisTestResultStatus.INFO, "Item not in actual set: " + o));
             }
         }
 

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=1152634&r1=1152633&r2=1152634&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 Sun Jul 31 21:02:43 2011
@@ -94,6 +94,9 @@ public abstract class AbstractSessionTes
     private final SessionFactory factory = SessionFactoryImpl.newInstance();
     private Folder testFolder;
 
+    private Boolean supportsRelationships;
+    private Boolean supportsPolicies;
+
     public BindingType getBinding() {
         if (getParameters() == null) {
             return null;
@@ -429,6 +432,32 @@ public abstract class AbstractSessionTes
         return cap.isGetFolderTreeSupported().booleanValue();
     }
 
+    protected boolean hasRelationships(Session session) {
+        if (supportsRelationships == null) {
+            try {
+                session.getTypeDefinition(BaseTypeId.CMIS_RELATIONSHIP.value());
+                supportsRelationships = Boolean.TRUE;
+            } catch (CmisObjectNotFoundException e) {
+                supportsRelationships = Boolean.FALSE;
+            }
+        }
+
+        return supportsRelationships.booleanValue();
+    }
+
+    protected boolean hasPolicies(Session session) {
+        if (supportsPolicies == null) {
+            try {
+                session.getTypeDefinition(BaseTypeId.CMIS_POLICY.value());
+                supportsPolicies = Boolean.TRUE;
+            } catch (CmisObjectNotFoundException e) {
+                supportsPolicies = Boolean.FALSE;
+            }
+        }
+
+        return supportsPolicies.booleanValue();
+    }
+
     protected CmisTestResult checkObject(Session session, CmisObject object, String[] properties, String message) {
         List<CmisTestResult> results = new ArrayList<CmisTestResult>();
 
@@ -637,6 +666,22 @@ public abstract class AbstractSessionTes
                     f = createResult(FAILURE, "Non-Fileable object has CAN_MOVE_OBJECT allowable action!");
                     addResult(results, assertNotAllowableAction(object, Action.CAN_MOVE_OBJECT, null, f));
                 }
+
+                // get allowable actions again
+                AllowableActions allowableActions = session.getBinding().getObjectService()
+                        .getAllowableActions(session.getRepositoryInfo().getId(), object.getId(), null);
+
+                if (allowableActions.getAllowableActions() == null) {
+                    addResult(results,
+                            createResult(FAILURE, "getAllowableActions() didn't returned allowable actions!"));
+                } else {
+                    f = createResult(FAILURE,
+                            "Object allowable actions don't match the allowable actions returned by getAllowableActions()!");
+                    addResult(
+                            results,
+                            assertEqualSet(object.getAllowableActions().getAllowableActions(),
+                                    allowableActions.getAllowableActions(), null, f));
+                }
             }
 
             // check relationships