chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1028268 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck: impl/ tests/basics/
Date Thu, 28 Oct 2010 12:03:08 GMT
Author: fmui
Date: Thu Oct 28 12:03:08 2010
New Revision: 1028268

URL: http://svn.apache.org/viewvc?rev=1028268&view=rev
Log:
- added more property TCK tests
- improved JUnit runner

Added:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/PropertyCheckEnum.java
  (with props)
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/JUnitHelper.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/RootFolderTest.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=1028268&r1=1028267&r2=1028268&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
Thu Oct 28 12:03:08 2010
@@ -30,9 +30,11 @@ import java.util.Map;
 import org.apache.chemistry.opencmis.client.api.CmisObject;
 import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
 import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.OperationContext;
 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.runtime.OperationContextImpl;
 import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
@@ -42,6 +44,8 @@ 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.Cardinality;
+import org.apache.chemistry.opencmis.commons.enums.PropertyType;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.CmisTestResultStatus;
 
@@ -100,9 +104,9 @@ public abstract class AbstractSessionTes
         return ri;
     }
 
-    // --- checks ----
+    // --- reusable checks ----
 
-    protected CmisTestResult checkObject(CmisObject object, String message) {
+    protected CmisTestResult checkObject(CmisObject object, String[] properties, String message)
{
         List<CmisTestResult> results = new ArrayList<CmisTestResult>();
 
         CmisTestResult f;
@@ -115,30 +119,51 @@ public abstract class AbstractSessionTes
             addResult(results, assertStringNotEmpty(object.getId(), null, f));
 
             // properties
-            Property<?> prop;
-            prop = object.getProperty(PropertyIds.OBJECT_ID);
-            addResult(results, checkProperty(prop, "Property " + PropertyIds.OBJECT_ID));
+            for (String propId : properties) {
+                Property<?> prop = object.getProperty(propId);
 
-            prop = object.getProperty(PropertyIds.BASE_TYPE_ID);
-            addResult(results, checkProperty(prop, "Property " + PropertyIds.BASE_TYPE_ID));
+                // values of non-spec properties are not checked here
+                PropertyCheckEnum propertyCheck = PropertyCheckEnum.NO_VALUE_CHECK;
 
-            prop = object.getProperty(PropertyIds.OBJECT_TYPE_ID);
-            addResult(results, checkProperty(prop, "Property " + PropertyIds.OBJECT_TYPE_ID));
-
-            prop = object.getProperty(PropertyIds.NAME);
-            addResult(results, checkProperty(prop, "Property " + PropertyIds.NAME));
+                // known properties that are strings and must be set
+                if (PropertyIds.OBJECT_ID.equals(propId) || PropertyIds.BASE_TYPE_ID.equals(propId)
+                        || PropertyIds.OBJECT_TYPE_ID.equals(propId) || PropertyIds.CREATED_BY.equals(propId)
+                        || PropertyIds.LAST_MODIFIED_BY.equals(propId) || PropertyIds.CHANGE_TOKEN.equals(propId)
+                        || PropertyIds.PATH.equals(propId)) {
+                    propertyCheck = PropertyCheckEnum.STRING_MUST_NOT_BE_EMPTY;
+                }
 
-            prop = object.getProperty(PropertyIds.CREATED_BY);
-            addResult(results, checkProperty(prop, "Property " + PropertyIds.CREATED_BY));
+                // known properties that are strings and should be set
+                if (PropertyIds.NAME.equals(propId) || PropertyIds.SOURCE_ID.equals(propId)
+                        || PropertyIds.TARGET_ID.equals(propId)) {
+                    propertyCheck = PropertyCheckEnum.STRING_SHOULD_NOT_BE_EMPTY;
+                }
 
-            prop = object.getProperty(PropertyIds.CREATION_DATE);
-            addResult(results, checkProperty(prop, "Property " + PropertyIds.CREATION_DATE));
+                // known properties that are not strings and must be set
+                if (PropertyIds.CREATION_DATE.equals(propId) || PropertyIds.LAST_MODIFICATION_DATE.equals(propId)
+                        || PropertyIds.IS_IMMUTABLE.equals(propId)) {
+                    propertyCheck = PropertyCheckEnum.MUST_BE_SET;
+                }
 
-            prop = object.getProperty(PropertyIds.LAST_MODIFIED_BY);
-            addResult(results, checkProperty(prop, "Property " + PropertyIds.LAST_MODIFIED_BY));
+                // special cases
+                if (PropertyIds.PARENT_ID.equals(propId)) {
+                    if (object instanceof Folder) {
+                        if (((Folder) object).isRootFolder()) {
+                            propertyCheck = PropertyCheckEnum.MUST_NOT_BE_SET;
+                        } else {
+                            propertyCheck = PropertyCheckEnum.STRING_MUST_NOT_BE_EMPTY;
+                        }
+                    } else {
+                        addResult(
+                                results,
+                                createResult(FAILURE, "Property " + PropertyIds.PARENT_ID
+                                        + " is only defined for folders!"));
+                    }
+                }
 
-            prop = object.getProperty(PropertyIds.LAST_MODIFICATION_DATE);
-            addResult(results, checkProperty(prop, "Property " + PropertyIds.LAST_MODIFICATION_DATE));
+                // check property
+                addResult(results, checkProperty(prop, "Property " + propId, propertyCheck));
+            }
 
             // allowable actions
             f = createResult(FAILURE, "Object has no CAN_GET_PROPERTIES allowable action!");
@@ -173,7 +198,7 @@ public abstract class AbstractSessionTes
         return failure;
     }
 
-    protected CmisTestResult checkProperty(Property<?> property, String message) {
+    protected CmisTestResult checkProperty(Property<?> property, String message, PropertyCheckEnum
propertyCheck) {
         List<CmisTestResult> results = new ArrayList<CmisTestResult>();
 
         CmisTestResult f;
@@ -193,6 +218,49 @@ public abstract class AbstractSessionTes
 
             f = createResult(WARNING, "Local name is not set!");
             addResult(results, assertNotNull(property.getLocalName(), null, f));
+
+            if ((propertyCheck == PropertyCheckEnum.MUST_BE_SET)
+                    || (propertyCheck == PropertyCheckEnum.STRING_MUST_NOT_BE_EMPTY)
+                    || (propertyCheck == PropertyCheckEnum.STRING_SHOULD_NOT_BE_EMPTY)) {
+                f = createResult(FAILURE, "Property has no value!");
+                addResult(results, assertIsTrue(property.getValues().size() > 0, null,
f));
+            } else if (propertyCheck == PropertyCheckEnum.MUST_NOT_BE_SET) {
+                f = createResult(FAILURE, "Property has a value!");
+                addResult(results, assertIsTrue(property.getValues().size() == 0, null, f));
+            }
+
+            boolean isString = ((property.getDefinition().getPropertyType() == PropertyType.STRING)
+                    || (property.getDefinition().getPropertyType() == PropertyType.ID)
+                    || (property.getDefinition().getPropertyType() == PropertyType.URI) ||
(property.getDefinition()
+                    .getPropertyType() == PropertyType.HTML));
+            for (Object value : property.getValues()) {
+                if (value == null) {
+                    addResult(results, createResult(FAILURE, "Property values contain a null
value!"));
+                    break;
+                } else if (isString) {
+                    if (propertyCheck == PropertyCheckEnum.STRING_MUST_NOT_BE_EMPTY) {
+                        f = createResult(FAILURE, "Property values contain an empty string!");
+                        addResult(results, assertStringNotEmpty(value.toString(), null, f));
+                    } else if (propertyCheck == PropertyCheckEnum.STRING_SHOULD_NOT_BE_EMPTY)
{
+                        f = createResult(WARNING, "Property values contain an empty string!");
+                        addResult(results, assertStringNotEmpty(value.toString(), null, f));
+                    }
+                }
+            }
+
+            if (property.getDefinition().getCardinality() == Cardinality.SINGLE) {
+                f = createResult(FAILURE, "Property cardinality is SINGLE but property has
more than one value!");
+                addResult(results, assertIsTrue(property.getValues().size() <= 1, null,
f));
+            }
+
+            if (property.getDefinition().isRequired() == null) {
+                addResult(results, createResult(FAILURE, "Property definition doesn't contain
the required flag!!"));
+            } else {
+                if (property.getDefinition().isRequired().booleanValue()) {
+                    f = createResult(FAILURE, "Property is required but has no value!");
+                    addResult(results, assertIsTrue(property.getValues().size() > 0, null,
f));
+                }
+            }
         }
 
         CmisTestResultImpl result = createResult(getWorst(results), message);
@@ -210,10 +278,24 @@ public abstract class AbstractSessionTes
         addResult(results, assertNotNull(folder, null, f));
 
         if (folder != null) {
-            for (CmisObject child : folder.getChildren()) {
-                addResult(results, checkObject(folder, "Child check: " + (child == null ?
"?" : child.getId())));
+            OperationContext oc = new OperationContextImpl();
+            oc.setFilterString("*");
+            oc.setCacheEnabled(false);
+            oc.setIncludeAllowableActions(true);
+
+            for (CmisObject child : folder.getChildren(oc)) {
+                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(folder, propertiesToCheck, "Child check:
" + child.getId()));
 
-                if (child != null) {
                     f = createResult(FAILURE, "Child is not fileable! Id: " + child.getId()
+ " / Type: "
                             + child.getType().getId());
                     addResult(results, assertIsTrue(child instanceof FileableCmisObject,
null, f));

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/JUnitHelper.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/JUnitHelper.java?rev=1028268&r1=1028267&r2=1028268&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/JUnitHelper.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/JUnitHelper.java
Thu Oct 28 12:03:08 2010
@@ -25,6 +25,8 @@ import org.apache.chemistry.opencmis.tck
 import org.apache.chemistry.opencmis.tck.CmisTestGroup;
 import org.apache.chemistry.opencmis.tck.CmisTestProgressMonitor;
 import org.apache.chemistry.opencmis.tck.CmisTestReport;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.CmisTestResultStatus;
 import org.apache.chemistry.opencmis.tck.report.TextReport;
 import org.apache.chemistry.opencmis.tck.runner.AbstractRunner;
 import org.junit.Assert;
@@ -60,11 +62,25 @@ public class JUnitHelper {
 
             CmisTestReport report = new TextReport();
             report.createReport(runner.getParameters(), runner.getGroups(), new PrintWriter(System.out));
+
+            checkForFailures(runner);
         } catch (Exception e) {
             Assert.fail(e.getMessage());
         }
     }
 
+    private static void checkForFailures(JUnitRunner runner) {
+        for (CmisTestGroup group : runner.getGroups()) {
+            for (CmisTest test : group.getTests()) {
+                for (CmisTestResult result : test.getResults()) {
+                    if (result.getStatus().getLevel() >= CmisTestResultStatus.FAILURE.getLevel())
{
+                        Assert.fail(result.getMessage());
+                    }
+                }
+            }
+        }
+    }
+
     private static class JUnitRunner extends AbstractRunner {
     }
 

Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/PropertyCheckEnum.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/PropertyCheckEnum.java?rev=1028268&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/PropertyCheckEnum.java
(added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/PropertyCheckEnum.java
Thu Oct 28 12:03:08 2010
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.tck.impl;
+
+public enum PropertyCheckEnum {
+    NO_VALUE_CHECK, MUST_NOT_BE_SET, MUST_BE_SET, STRING_SHOULD_NOT_BE_EMPTY, STRING_MUST_NOT_BE_EMPTY;
+}

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/PropertyCheckEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=1028268&r1=1028267&r2=1028268&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
Thu Oct 28 12:03:08 2010
@@ -26,6 +26,7 @@ import java.util.Map;
 
 import org.apache.chemistry.opencmis.client.api.Folder;
 import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.enums.Action;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
@@ -57,7 +58,11 @@ public class RootFolderTest extends Abst
         // get the root folder
         Folder rootFolder = session.getRootFolder();
 
-        addResult(checkObject(rootFolder, "Root folder object spec compliance"));
+        String[] propertiesToCheck = new String[] { PropertyIds.OBJECT_ID, PropertyIds.OBJECT_TYPE_ID,
+                PropertyIds.BASE_TYPE_ID, PropertyIds.NAME, PropertyIds.CREATED_BY, PropertyIds.CREATION_DATE,
+                PropertyIds.LAST_MODIFIED_BY, PropertyIds.LAST_MODIFICATION_DATE };
+
+        addResult(checkObject(rootFolder, propertiesToCheck, "Root folder object spec compliance"));
 
         if (rootFolder == null) {
             return;



Mime
View raw message