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 2010/10/29 14:08:41 UTC

svn commit: r1028710 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck: impl/AbstractSessionTest.java report/HtmlReport.java tests/basics/TypesTest.java

Author: fmui
Date: Fri Oct 29 12:08:40 2010
New Revision: 1028710

URL: http://svn.apache.org/viewvc?rev=1028710&view=rev
Log:
- completed type test (can someone please verfiy?!)
- made HTML reports *a bit* nicer

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/report/HtmlReport.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/TypesTest.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=1028710&r1=1028709&r2=1028710&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 Fri Oct 29 12:08:40 2010
@@ -679,6 +679,192 @@ public abstract class AbstractSessionTes
         return (result.getStatus().getLevel() <= OK.getLevel() ? null : result);
     }
 
+    protected CmisTestResult assertEquals(TypeDefinition expected, TypeDefinition actual, CmisTestResult success,
+            CmisTestResult failure) {
+
+        List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+
+        CmisTestResult f;
+
+        if ((expected == null) && (actual == null)) {
+            return success;
+        }
+
+        if (expected == null) {
+            f = createResult(FAILURE, "Expected type defintion is null, but actual type defintion is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        if (actual == null) {
+            f = createResult(FAILURE, "Actual type defintion is null, but expected type defintion is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        f = createResult(FAILURE, "Type ids don't match!");
+        addResult(results, assertEquals(expected.getId(), actual.getId(), null, f));
+
+        f = createResult(FAILURE, "Base type ids don't match!");
+        addResult(results, assertEquals(expected.getBaseTypeId(), actual.getBaseTypeId(), null, f));
+
+        f = createResult(FAILURE, "Parent type ids don't match!");
+        addResult(results, assertEquals(expected.getParentTypeId(), actual.getParentTypeId(), null, f));
+
+        f = createResult(FAILURE, "Query names don't match!");
+        addResult(results, assertEquals(expected.getQueryName(), actual.getQueryName(), null, f));
+
+        f = createResult(FAILURE, "Local names don't match!");
+        addResult(results, assertEquals(expected.getLocalName(), actual.getLocalName(), null, f));
+
+        f = createResult(FAILURE, "Local namespaces don't match!");
+        addResult(results, assertEquals(expected.getLocalNamespace(), actual.getLocalNamespace(), null, f));
+
+        f = createResult(FAILURE, "Display names don't match!");
+        addResult(results, assertEquals(expected.getDisplayName(), actual.getDisplayName(), null, f));
+
+        f = createResult(FAILURE, "Descriptions don't match!");
+        addResult(results, assertEquals(expected.getDescription(), actual.getDescription(), null, f));
+
+        f = createResult(FAILURE, "Controllable ACl flags don't match!");
+        addResult(results, assertEquals(expected.isControllableAcl(), actual.isControllableAcl(), null, f));
+
+        f = createResult(FAILURE, "Controllable Policy flags don't match!");
+        addResult(results, assertEquals(expected.isControllablePolicy(), actual.isControllablePolicy(), null, f));
+
+        f = createResult(FAILURE, "Creatable flags don't match!");
+        addResult(results, assertEquals(expected.isCreatable(), actual.isCreatable(), null, f));
+
+        f = createResult(FAILURE, "Fileable flags don't match!");
+        addResult(results, assertEquals(expected.isFileable(), actual.isFileable(), null, f));
+
+        f = createResult(FAILURE, "Fulltext indexed flags don't match!");
+        addResult(results, assertEquals(expected.isFulltextIndexed(), actual.isFulltextIndexed(), null, f));
+
+        f = createResult(FAILURE, "Queryable flags don't match!");
+        addResult(results, assertEquals(expected.isQueryable(), actual.isQueryable(), null, f));
+
+        f = createResult(FAILURE, "Included in supertype query flags don't match!");
+        addResult(results,
+                assertEquals(expected.isIncludedInSupertypeQuery(), actual.isIncludedInSupertypeQuery(), null, f));
+
+        if ((expected.getPropertyDefinitions() != null) && (actual.getPropertyDefinitions() != null)) {
+            Map<String, PropertyDefinition<?>> epd = expected.getPropertyDefinitions();
+            Map<String, PropertyDefinition<?>> apd = actual.getPropertyDefinitions();
+
+            f = createResult(FAILURE, "Different number of property defintions!");
+            addResult(results, assertEquals(epd.size(), apd.size(), null, f));
+
+            for (PropertyDefinition<?> pd : epd.values()) {
+                f = createResult(FAILURE, "Property definition mismatch: " + pd.getId());
+                addResult(results, assertEquals(pd, apd.get(pd.getId()), null, f));
+            }
+        }
+
+        if (getWorst(results).getLevel() <= OK.getLevel()) {
+            for (CmisTestResult result : results) {
+                addResultChild(success, result);
+            }
+
+            return success;
+        } else {
+            for (CmisTestResult result : results) {
+                addResultChild(failure, result);
+            }
+
+            return failure;
+        }
+    }
+
+    protected CmisTestResult assertEquals(PropertyDefinition<?> expected, PropertyDefinition<?> actual,
+            CmisTestResult success, CmisTestResult failure) {
+
+        List<CmisTestResult> results = new ArrayList<CmisTestResult>();
+
+        CmisTestResult f;
+
+        if ((expected == null) && (actual == null)) {
+            return success;
+        }
+
+        if (expected == null) {
+            f = createResult(FAILURE, "Expected property defintion is null, but actual property defintion is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        if (actual == null) {
+            f = createResult(FAILURE, "Actual property defintion is null, but expected property defintion is not!");
+            addResultChild(failure, f);
+
+            return failure;
+        }
+
+        f = createResult(FAILURE, "Property ids don't match!");
+        addResult(results, assertEquals(expected.getId(), actual.getId(), null, f));
+
+        f = createResult(FAILURE, "Local names don't match!");
+        addResult(results, assertEquals(expected.getLocalName(), actual.getLocalName(), null, f));
+
+        f = createResult(FAILURE, "Local namespaces don't match!");
+        addResult(results, assertEquals(expected.getLocalNamespace(), actual.getLocalNamespace(), null, f));
+
+        f = createResult(FAILURE, "Display names don't match!");
+        addResult(results, assertEquals(expected.getDisplayName(), actual.getDisplayName(), null, f));
+
+        f = createResult(FAILURE, "Query names don't match!");
+        addResult(results, assertEquals(expected.getQueryName(), actual.getQueryName(), null, f));
+
+        f = createResult(FAILURE, "Property types don't match!");
+        addResult(results, assertEquals(expected.getPropertyType(), actual.getPropertyType(), null, f));
+
+        f = createResult(FAILURE, "Cardinalities don't match!");
+        addResult(results, assertEquals(expected.getCardinality(), actual.getCardinality(), null, f));
+
+        f = createResult(FAILURE, "Descriptions don't match!");
+        addResult(results, assertEquals(expected.getDescription(), actual.getDescription(), null, f));
+
+        f = createResult(FAILURE, "Updatability flags don't match!");
+        addResult(results, assertEquals(expected.getUpdatability(), actual.getUpdatability(), null, f));
+
+        f = createResult(FAILURE, "Default values don't match!");
+        addResult(results, assertEqualLists(expected.getDefaultValue(), actual.getDefaultValue(), null, f));
+
+        f = createResult(FAILURE, "Inherited flags don't match!");
+        addResult(results, assertEquals(expected.isInherited(), actual.isInherited(), null, f));
+
+        f = createResult(FAILURE, "Required flags don't match!");
+        addResult(results, assertEquals(expected.isRequired(), actual.isRequired(), null, f));
+
+        f = createResult(FAILURE, "Queryable flags don't match!");
+        addResult(results, assertEquals(expected.isQueryable(), actual.isQueryable(), null, f));
+
+        f = createResult(FAILURE, "Orderable flags don't match!");
+        addResult(results, assertEquals(expected.isOrderable(), actual.isOrderable(), null, f));
+
+        f = createResult(FAILURE, "Open choice flags don't match!");
+        addResult(results, assertEquals(expected.isOpenChoice(), actual.isOpenChoice(), null, f));
+
+        if (getWorst(results).getLevel() <= OK.getLevel()) {
+            for (CmisTestResult result : results) {
+                addResultChild(success, result);
+            }
+
+            return success;
+        } else {
+            for (CmisTestResult result : results) {
+                addResultChild(failure, result);
+            }
+
+            return failure;
+        }
+    }
+
+    // --- helpers ---
+
     protected void addResult(List<CmisTestResult> results, CmisTestResult result) {
         if (result != null) {
             if (result instanceof CmisTestResultImpl) {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/HtmlReport.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/report/HtmlReport.java?rev=1028710&r1=1028709&r2=1028710&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/HtmlReport.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/report/HtmlReport.java Fri Oct 29 12:08:40 2010
@@ -20,6 +20,7 @@ package org.apache.chemistry.opencmis.tc
 
 import java.io.IOException;
 import java.io.Writer;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
@@ -39,9 +40,20 @@ public class HtmlReport extends Abstract
     public void createReport(Map<String, String> parameters, List<CmisTestGroup> groups, Writer writer)
             throws IOException {
         writer.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n");
-        writer.write("<html><head><title>Report</title></head><body>\n");
+        writer.write("<html><head>\n<title>Report</title>\n");
+        writer.write("<style TYPE=\"text/css\">\n");
+        writer.write(".tckResultINFO { margin-left: 5px; margin-right: 5px; }\n");
+        writer.write(".tckResultSKIPPED { margin-left: 5px; margin-right: 5px; background-color: #FFFFFF; }\n");
+        writer.write(".tckResultOK { margin-left: 5px; margin-right: 5px; background-color: #00FF00; }\n");
+        writer.write(".tckResultWARNING { margin-left: 5px; margin-right: 5px; background-color: #FFFF00; }\n");
+        writer.write(".tckResultFAILURE { margin-left: 5px; margin-right: 5px; background-color: #FF6000; }\n");
+        writer.write(".tckResultUNEXPECTED_EXCEPTION { margin-left: 5px; margin-right: 5px; background-color: #FF0000; }\n");
+        writer.write("</style>");
 
-        writer.write("\n<h1>Report</h1>\n");
+        writer.write("</head><body>\n");
+
+        writer.write("\n<h1>OpenCMIS TCK Report</h1>\n");
+        writer.write((new Date()) + "\n");
 
         writer.write("\n<h2>Parameters</h2>\n");
 
@@ -81,13 +93,15 @@ public class HtmlReport extends Abstract
 
         if (test.getResults() != null) {
             for (CmisTestResult result : test.getResults()) {
+                writer.write("<div style=\"padding: 5px;\">\n");
                 printResult(result, writer);
+                writer.write("</div>\n");
             }
         }
     }
 
     private void printResult(CmisTestResult result, Writer writer) throws IOException {
-        writer.write("<div style=\"padding:5px\">\n");
+        writer.write("<div class=\"tckResult" + result.getStatus().name() + "\">\n");
 
         writer.write("<b>" + result.getStatus() + "</b>: " + result.getMessage());
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/TypesTest.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/TypesTest.java?rev=1028710&r1=1028709&r2=1028710&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/TypesTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/TypesTest.java Fri Oct 29 12:08:40 2010
@@ -21,9 +21,11 @@ package org.apache.chemistry.opencmis.tc
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.chemistry.opencmis.client.api.ItemIterable;
 import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.client.api.Tree;
@@ -93,14 +95,17 @@ public class TypesTest extends AbstractS
             addResult(createResult(WARNING, "Policy type not available!", e, false));
         }
 
-        runTypeChecks(session, session.getTypeDescendants(null, -1, true));
+        int numOfTypes = runTypeChecks(session, session.getTypeDescendants(null, -1, true));
+
+        addResult(createInfoResult("Checked " + numOfTypes + " type definitions."));
     }
 
-    private void runTypeChecks(Session session, List<Tree<ObjectType>> types) {
+    private int runTypeChecks(Session session, List<Tree<ObjectType>> types) {
         if (types == null) {
-            return;
+            return 0;
         }
 
+        int numOfTypes = 0;
         CmisTestResult failure;
 
         for (Tree<ObjectType> tree : types) {
@@ -108,10 +113,87 @@ public class TypesTest extends AbstractS
             addResult(assertNotNull(tree, null, failure));
 
             if (tree != null) {
+                numOfTypes++;
+
                 addResult(checkTypeDefinition(session, tree.getItem(), "Type spec compliance: "
                         + tree.getItem().getId()));
-                runTypeChecks(session, tree.getChildren());
+
+                // clear the cache to ensure that the type definition is
+                // reloaded from the repository
+                session.clear();
+
+                try {
+                    TypeDefinition reloadedType = session.getTypeDefinition(tree.getItem().getId());
+
+                    addResult(checkTypeDefinition(session, reloadedType, "Type spec compliance: "
+                            + (reloadedType == null ? "?" : reloadedType.getId())));
+
+                    failure = createResult(FAILURE,
+                            "Type fetched via getTypeDescendants() is does not macth type fetched via getTypeDefinition(): "
+                                    + tree.getItem().getId());
+                    addResult(assertEquals(tree.getItem(), reloadedType, null, failure));
+                } catch (CmisObjectNotFoundException e) {
+                    addResult(createResult(FAILURE,
+                            "Type fetched via getTypeDescendants() is not available via getTypeDefinition(): "
+                                    + tree.getItem().getId(), e, false));
+                }
+
+                // clear the cache again to ensure that the type definition
+                // children are reloaded from the repository
+                session.clear();
+
+                try {
+                    ItemIterable<ObjectType> reloadedTypeChildren = session.getTypeChildren(tree.getItem().getId(),
+                            true);
+
+                    // check type children
+                    Map<String, ObjectType> typeChilden = new HashMap<String, ObjectType>();
+                    for (ObjectType childType : reloadedTypeChildren) {
+                        addResult(checkTypeDefinition(session, childType, "Type spec compliance: "
+                                + (childType == null ? "?" : childType.getId())));
+
+                        if (childType != null) {
+                            typeChilden.put(childType.getId(), childType);
+                        }
+                    }
+
+                    // compare type children and type descendants
+                    if (tree.getChildren() == null) {
+                        failure = createResult(FAILURE,
+                                "Type children fetched via getTypeDescendants() don't match type children fetched via getTypeChildren(): "
+                                        + tree.getItem().getId());
+                        addResult(assertEquals(0, typeChilden.size(), null, failure));
+                    } else {
+                        // collect the children
+                        Map<String, ObjectType> typeDescendants = new HashMap<String, ObjectType>();
+                        for (Tree<ObjectType> childType : tree.getChildren()) {
+                            if ((childType != null) && (childType.getItem() != null)) {
+                                typeDescendants.put(childType.getItem().getId(), childType.getItem());
+                            }
+                        }
+
+                        failure = createResult(FAILURE,
+                                "Type children fetched via getTypeDescendants() don't match type children fetched via getTypeChildren(): "
+                                        + tree.getItem().getId());
+                        addResult(assertEquals(typeDescendants.size(), typeChilden.size(), null, failure));
+
+                        for (ObjectType compareType : typeDescendants.values()) {
+                            failure = createResult(FAILURE,
+                                    "Type fetched via getTypeDescendants() doesn't match type fetched via getTypeChildren(): "
+                                            + tree.getItem().getId());
+                            addResult(assertEquals(compareType, typeChilden.get(compareType.getId()), null, failure));
+                        }
+                    }
+                } catch (CmisObjectNotFoundException e) {
+                    addResult(createResult(FAILURE,
+                            "Type children fetched via getTypeDescendants() is not available via getTypeChildren(): "
+                                    + tree.getItem().getId(), e, false));
+                }
+
+                numOfTypes += runTypeChecks(session, tree.getChildren());
             }
         }
+
+        return numOfTypes;
     }
 }