chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1033477 - in /incubator/chemistry/opencmis/trunk: chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/ chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemis...
Date Wed, 10 Nov 2010 14:07:45 GMT
Author: fmui
Date: Wed Nov 10 14:07:44 2010
New Revision: 1033477

URL: http://svn.apache.org/viewvc?rev=1033477&view=rev
Log:
- added more TCK code (shallow testing of getDescendants and getFolderTree)

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/CmisTestResultImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/RootFolderTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java

Modified: incubator/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/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java?rev=1033477&r1=1033476&r2=1033477&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
Wed Nov 10 14:07:44 2010
@@ -20,6 +20,7 @@ package org.apache.chemistry.opencmis.tc
 
 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.UNEXPECTED_EXCEPTION;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
 
@@ -36,10 +37,12 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.Property;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.client.api.SessionFactory;
+import org.apache.chemistry.opencmis.client.api.Tree;
 import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl;
 import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
@@ -307,6 +310,34 @@ public abstract class AbstractSessionTes
 
     // --- reusable checks ----
 
+    protected boolean isGetDescendantsSupported(Session session) {
+        RepositoryCapabilities cap = session.getRepositoryInfo().getCapabilities();
+
+        if (cap == null) {
+            return false;
+        }
+
+        if (cap.isGetDescendantsSupported() == null) {
+            return false;
+        }
+
+        return cap.isGetDescendantsSupported().booleanValue();
+    }
+
+    protected boolean isGetFolderTreeSupported(Session session) {
+        RepositoryCapabilities cap = session.getRepositoryInfo().getCapabilities();
+
+        if (cap == null) {
+            return false;
+        }
+
+        if (cap.isGetFolderTreeSupported() == null) {
+            return false;
+        }
+
+        return cap.isGetFolderTreeSupported().booleanValue();
+    }
+
     protected CmisTestResult checkObject(CmisObject object, String[] properties, String message)
{
         List<CmisTestResult> results = new ArrayList<CmisTestResult>();
 
@@ -470,87 +501,141 @@ public abstract class AbstractSessionTes
         return (result.getStatus().getLevel() <= OK.getLevel() ? null : result);
     }
 
-    protected CmisTestResult checkChildren(Folder folder, String message) {
+    protected CmisTestResult checkChildren(Session session, Folder folder, String message)
{
         List<CmisTestResult> results = new ArrayList<CmisTestResult>();
 
         CmisTestResult f;
 
-        f = createResult(FAILURE, "Folder is null!");
-        addResult(results, assertNotNull(folder, null, f));
+        if (folder == null) {
+            return createResult(FAILURE, "Folder is null!");
+        }
 
-        if (folder != null) {
-            long count = 0;
-            ItemIterable<CmisObject> children = folder.getChildren(SELECT_ALL_NO_CACHE_OC);
+        // getChildren
 
-            for (CmisObject child : children) {
-                count++;
+        long childrenCount = 0;
+        long childrenFolderCount = 0;
+        ItemIterable<CmisObject> children = folder.getChildren(SELECT_ALL_NO_CACHE_OC);
 
-                if (child == null) {
-                    addResult(results, createResult(FAILURE, "Folder contains a null child!"));
-                } else {
-                    String[] propertiesToCheck = new String[child.getType().getPropertyDefinitions().size()];
+        for (CmisObject child : children) {
+            childrenCount++;
+            if (child instanceof Folder) {
+                childrenFolderCount++;
+            }
 
-                    int i = 0;
-                    for (String propId : child.getType().getPropertyDefinitions().keySet())
{
-                        propertiesToCheck[i++] = propId;
-                    }
+            checkChild(results, folder, child);
+        }
 
-                    addResult(results, checkObject(child, propertiesToCheck, "Child check:
" + child.getId()));
+        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(FAILURE, "Child is not fileable! Id: " + child.getId()
+ " / Type: "
-                            + child.getType().getId());
-                    addResult(results, assertIsTrue(child instanceof FileableCmisObject,
null, f));
+        // getDescendants
 
-                    if (child instanceof FileableCmisObject) {
-                        FileableCmisObject fileableChild = (FileableCmisObject) child;
-                        List<Folder> parents = fileableChild.getParents();
+        if (isGetDescendantsSupported(session)) {
+            long descendantsCount = 0;
+            List<Tree<FileableCmisObject>> descendants = folder.getDescendants(1);
 
-                        f = createResult(FAILURE, "Child has no parents! Id: " + child.getId());
-                        addResult(results, assertIsTrue(parents.size() > 0, null, f));
+            for (Tree<FileableCmisObject> child : descendants) {
+                descendantsCount++;
 
-                        boolean foundParent = false;
-                        for (Folder parent : parents) {
-                            if (parent == null) {
-                                f = createResult(FAILURE, "One of childs parents is null!
Id: " + child.getId());
-                                addResult(results, assertIsTrue(parents.size() > 0, null,
f));
-                            }
-
-                            if (folder.getId().equals(parent.getId())) {
-                                foundParent = true;
-                                break;
-                            }
-                        }
+                if (child == null) {
+                    addResult(results, createResult(FAILURE, "Folder descendants contain
a null tree!"));
+                } else {
+                    checkChild(results, folder, child.getItem());
+                }
+            }
 
-                        if (!foundParent) {
-                            f = createResult(FAILURE, "Folder is not found in childs parents!
Id: " + child.getId());
-                            addResult(results, assertIsTrue(parents.size() > 0, null,
f));
-                        }
-                    } else {
-                        addResult(results, createResult(FAILURE, "Found a non-filealed child!
Id: " + child.getId()));
-                    }
+            f = createResult(FAILURE,
+                    "Number of descendants doesn't match the number of children returned
by getChildren!");
+            addResult(results, assertEquals(childrenCount, descendantsCount, null, f));
+        } else {
+            addResult(results, createResult(SKIPPED, "getDescendants is not supported."));
+        }
 
-                    f = createResult(FAILURE,
-                            "Child has no CAN_GET_OBJECT_PARENTS allowable action! Id: "
+ child.getId());
-                    addResult(results, assertAllowableAction(child, Action.CAN_GET_OBJECT_PARENTS,
null, f));
+        // getFolderTree
 
-                    if (child instanceof Folder) {
-                        f = createResult(FAILURE,
-                                "Child has no CAN_GET_FOLDER_PARENT allowable action! Id:
" + child.getId());
-                        addResult(results, assertAllowableAction(child, Action.CAN_GET_FOLDER_PARENT,
null, f));
-                    }
+        if (isGetFolderTreeSupported(session)) {
+            long folderTreeCount = 0;
+            List<Tree<FileableCmisObject>> folderTree = folder.getFolderTree(1);
+
+            for (Tree<FileableCmisObject> child : folderTree) {
+                folderTreeCount++;
+
+                if (child == null) {
+                    addResult(results, createResult(FAILURE, "Folder tree contains a null
tree!"));
+                } else {
+                    checkChild(results, folder, child.getItem());
                 }
             }
 
-            f = createResult(WARNING, "Number of children doesn't match the reported total
number of items!");
-            addResult(results, assertEquals(count, children.getTotalNumItems(), null, f));
+            f = createResult(FAILURE, "Number of folders doesn't match the number of folders
returned by getChildren!");
+            addResult(results, assertEquals(childrenFolderCount, folderTreeCount, null, f));
+        } else {
+            addResult(results, createResult(SKIPPED, "getFolderTree is not supported."));
         }
 
+        // --- wrap up ---
+
         CmisTestResultImpl result = createResult(getWorst(results), message);
         result.getChildren().addAll(results);
 
         return (result.getStatus().getLevel() <= OK.getLevel() ? null : result);
     }
 
+    private void checkChild(List<CmisTestResult> results, Folder folder, CmisObject
child) {
+        CmisTestResult f;
+
+        if (child == null) {
+            addResult(results, createResult(FAILURE, "Folder contains a null child!"));
+        } else {
+            String[] propertiesToCheck = new String[child.getType().getPropertyDefinitions().size()];
+
+            int i = 0;
+            for (String propId : child.getType().getPropertyDefinitions().keySet()) {
+                propertiesToCheck[i++] = propId;
+            }
+
+            addResult(results, checkObject(child, propertiesToCheck, "Child check: " + child.getId()));
+
+            f = createResult(FAILURE, "Child is not fileable! Id: " + child.getId() + " /
Type: "
+                    + child.getType().getId());
+            addResult(results, assertIsTrue(child instanceof FileableCmisObject, null, f));
+
+            if (child instanceof FileableCmisObject) {
+                FileableCmisObject fileableChild = (FileableCmisObject) child;
+                List<Folder> parents = fileableChild.getParents();
+
+                f = createResult(FAILURE, "Child has no parents! Id: " + child.getId());
+                addResult(results, assertIsTrue(parents.size() > 0, null, f));
+
+                boolean foundParent = false;
+                for (Folder parent : parents) {
+                    if (parent == null) {
+                        f = createResult(FAILURE, "One of childs parents is null! Id: " +
child.getId());
+                        addResult(results, assertIsTrue(parents.size() > 0, null, f));
+                    }
+
+                    if (folder.getId().equals(parent.getId())) {
+                        foundParent = true;
+                        break;
+                    }
+                }
+
+                if (!foundParent) {
+                    f = createResult(FAILURE, "Folder is not found in childs parents! Id:
" + child.getId());
+                    addResult(results, assertIsTrue(parents.size() > 0, null, f));
+                }
+            }
+
+            f = createResult(FAILURE, "Child has no CAN_GET_OBJECT_PARENTS allowable action!
Id: " + child.getId());
+            addResult(results, assertAllowableAction(child, Action.CAN_GET_OBJECT_PARENTS,
null, f));
+
+            if (child instanceof Folder) {
+                f = createResult(FAILURE, "Child has no CAN_GET_FOLDER_PARENT allowable action!
Id: " + child.getId());
+                addResult(results, assertAllowableAction(child, Action.CAN_GET_FOLDER_PARENT,
null, f));
+            }
+        }
+    }
+
     protected CmisTestResult assertShallowEquals(CmisObject expected, CmisObject actual,
CmisTestResult success,
             CmisTestResult failure) {
 
@@ -1241,5 +1326,4 @@ public abstract class AbstractSessionTes
             return (result.getStatus().getLevel() <= OK.getLevel() ? null : result);
         }
     }
-
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/CmisTestResultImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/CmisTestResultImpl.java?rev=1033477&r1=1033476&r2=1033477&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/CmisTestResultImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/CmisTestResultImpl.java
Wed Nov 10 14:07:44 2010
@@ -109,4 +109,9 @@ public class CmisTestResultImpl implemen
     public boolean isFatal() {
         return isFatal;
     }
+
+    @Override
+    public String toString() {
+        return status + ": " + groupName + "/" + testName + ": " + message;
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/RootFolderTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/RootFolderTest.java?rev=1033477&r1=1033476&r2=1033477&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/RootFolderTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/RootFolderTest.java
Wed Nov 10 14:07:44 2010
@@ -93,6 +93,6 @@ public class RootFolderTest extends Abst
         addResult(assertAllowableAction(rootFolder, Action.CAN_GET_CHILDREN, null, failure));
 
         // simple children test
-        addResult(checkChildren(rootFolder, "Root folder children check"));
+        addResult(checkChildren(session, rootFolder, "Root folder children check"));
     }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java?rev=1033477&r1=1033476&r2=1033477&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteFolderTest.java
Wed Nov 10 14:07:44 2010
@@ -65,7 +65,7 @@ public class CreateAndDeleteFolderTest e
         }
 
         // simple children test
-        addResult(checkChildren(testFolder, "Test folder children check"));
+        addResult(checkChildren(session, testFolder, "Test folder children check"));
 
         // check if all folders are there
         ItemIterable<CmisObject> children = testFolder.getChildren();

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java?rev=1033477&r1=1033476&r2=1033477&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
Wed Nov 10 14:07:44 2010
@@ -245,7 +245,7 @@ public class TckDialog {
 
         public void endGroup(CmisTestGroup group) {
             groupsProgressBar.setString("");
-            groupsProgressBar.setValue(testsProgressBar.getValue() + 1);
+            groupsProgressBar.setValue(groupsProgressBar.getValue() + 1);
         }
 
         public void startTest(CmisTest test) {



Mime
View raw message