chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1455931 - in /chemistry/opencmis/trunk: chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/ chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apa...
Date Wed, 13 Mar 2013 13:32:50 GMT
Author: fmui
Date: Wed Mar 13 13:32:49 2013
New Revision: 1455931

URL: http://svn.apache.org/r1455931
Log:
minore fixes and TCK reorganization

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java
  (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.java
  (with props)
Removed:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/TypesTest.java
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntry.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/BasicsTestGroup.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/resources/cmis-tck-groups.txt

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java?rev=1455931&r1=1455930&r2=1455931&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
Wed Mar 13 13:32:49 2013
@@ -649,16 +649,21 @@ public class XMLConverter {
 
     public static void writeObject(XMLStreamWriter writer, CmisVersion cmisVersion, String
namespace, ObjectData source)
             throws XMLStreamException {
-        writeObject(writer, cmisVersion, TAG_OBJECT, namespace, source);
+        writeObject(writer, cmisVersion, false, TAG_OBJECT, namespace, source);
     }
 
-    public static void writeObject(XMLStreamWriter writer, CmisVersion cmisVersion, String
name, String namespace,
-            ObjectData source) throws XMLStreamException {
+    public static void writeObject(XMLStreamWriter writer, CmisVersion cmisVersion, boolean
root, String name,
+            String namespace, ObjectData source) throws XMLStreamException {
         if (source == null) {
             return;
         }
 
-        writer.writeStartElement(namespace, name);
+        if (root) {
+            writer.writeStartElement(PREFIX_CMIS, name, NAMESPACE_CMIS);
+            writer.writeNamespace(PREFIX_CMIS, NAMESPACE_CMIS);
+        } else {
+            writer.writeStartElement(namespace, name);
+        }
 
         if (source.getProperties() != null) {
             Properties properties = source.getProperties();
@@ -680,7 +685,7 @@ public class XMLConverter {
         if (source.getRelationships() != null) {
             for (ObjectData rel : source.getRelationships()) {
                 if (rel != null) {
-                    writeObject(writer, cmisVersion, TAG_OBJECT_RELATIONSHIP, NAMESPACE_CMIS,
rel);
+                    writeObject(writer, cmisVersion, false, TAG_OBJECT_RELATIONSHIP, NAMESPACE_CMIS,
rel);
                 }
             }
         }
@@ -833,7 +838,7 @@ public class XMLConverter {
         }
 
         if (root) {
-            writer.writeStartElement(NAMESPACE_CMIS, "allowableActions");
+            writer.writeStartElement(PREFIX_CMIS, "allowableActions", NAMESPACE_CMIS);
             writer.writeNamespace(PREFIX_CMIS, NAMESPACE_CMIS);
         } else {
             writer.writeStartElement(PREFIX_CMIS, TAG_OBJECT_ALLOWABLE_ACTIONS, NAMESPACE_CMIS);
@@ -861,7 +866,7 @@ public class XMLConverter {
         }
 
         if (root) {
-            writer.writeStartElement(NAMESPACE_CMIS, "acl");
+            writer.writeStartElement(PREFIX_CMIS, "acl", NAMESPACE_CMIS);
             writer.writeNamespace(PREFIX_CMIS, NAMESPACE_CMIS);
         } else {
             writer.writeStartElement(PREFIX_CMIS, TAG_OBJECT_ACL, NAMESPACE_CMIS);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntry.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntry.java?rev=1455931&r1=1455930&r2=1455931&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntry.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntry.java
Wed Mar 13 13:32:49 2013
@@ -90,8 +90,8 @@ public class AtomEntry extends AtomDocum
 
         writeContent(contentSrc, contentType);
 
-        XMLConverter.writeObject(getWriter(), cmisVersion, XMLConstants.TAG_OBJECT, XMLConstants.NAMESPACE_RESTATOM,
-                object);
+        XMLConverter.writeObject(getWriter(), cmisVersion, false, XMLConstants.TAG_OBJECT,
+                XMLConstants.NAMESPACE_RESTATOM, object);
 
         writePathSegment(pathSegment);
         writeRelativePathSegment(relativePathSegment);
@@ -113,8 +113,8 @@ public class AtomEntry extends AtomDocum
         writeTitle(object.getId());
         writeUpdated(now);
 
-        XMLConverter.writeObject(getWriter(), cmisVersion, XMLConstants.TAG_OBJECT, XMLConstants.NAMESPACE_RESTATOM,
-                object);
+        XMLConverter.writeObject(getWriter(), cmisVersion, false, XMLConstants.TAG_OBJECT,
+                XMLConstants.NAMESPACE_RESTATOM, object);
     }
 
     /**

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java?rev=1455931&r1=1455930&r2=1455931&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/DiscoveryService.java
Wed Mar 13 13:32:49 2013
@@ -207,7 +207,7 @@ public final class DiscoveryService {
         entry.writeUpdated(now);
 
         // write query result object
-        XMLConverter.writeObject(entry.getWriter(), cmisVersion, XMLConstants.TAG_OBJECT,
+        XMLConverter.writeObject(entry.getWriter(), cmisVersion, false, XMLConstants.TAG_OBJECT,
                 XMLConstants.NAMESPACE_RESTATOM, result);
 
         // we are done

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java?rev=1455931&r1=1455930&r2=1455931&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
Wed Mar 13 13:32:49 2013
@@ -1415,6 +1415,10 @@ public class FileShareRepository {
             // change token - always null
             addPropertyString(result, typeId, filter, PropertyIds.CHANGE_TOKEN, null);
 
+            // CMIS 1.1 properties
+            addPropertyString(result, typeId, filter, PropertyIds.DESCRIPTION, null);
+            addPropertyIdList(result, typeId, filter, PropertyIds.SECONDARY_OBJECT_TYPE_IDS,
null);
+
             // directory or file
             if (file.isDirectory()) {
                 // base type and type name
@@ -1507,7 +1511,7 @@ public class FileShareRepository {
         ObjectData obj = null;
         InputStream stream = null;
         try {
-            stream = new BufferedInputStream(new FileInputStream(file));
+            stream = new BufferedInputStream(new FileInputStream(propFile));
             XMLStreamReader parser = XMLUtils.createParser(stream);
             XMLUtils.findNextStartElemenet(parser);
             obj = XMLConverter.convertObject(parser);
@@ -1575,7 +1579,7 @@ public class FileShareRepository {
             }
 
             // add it
-            properties.addProperty(prop);
+            properties.replaceProperty(prop);
         }
     }
 
@@ -1871,7 +1875,7 @@ public class FileShareRepository {
         addAction(aas, Action.CAN_GET_OBJECT_PARENTS, !isRoot);
         addAction(aas, Action.CAN_GET_PROPERTIES, true);
         addAction(aas, Action.CAN_UPDATE_PROPERTIES, !userReadOnly && !isReadOnly);
-        addAction(aas, Action.CAN_MOVE_OBJECT, !userReadOnly);
+        addAction(aas, Action.CAN_MOVE_OBJECT, !userReadOnly && !isRoot);
         addAction(aas, Action.CAN_DELETE_OBJECT, !userReadOnly && !isReadOnly &&
!isRoot);
         addAction(aas, Action.CAN_GET_ACL, true);
 
@@ -1953,8 +1957,9 @@ public class FileShareRepository {
         try {
             stream = new BufferedOutputStream(new FileOutputStream(propFile));
             XMLStreamWriter writer = XMLUtils.createWriter(stream);
-            XMLConverter.writeObject(writer, CmisVersion.CMIS_1_1, XMLConstants.NAMESPACE_CMIS,
object);
-            writer.close();
+            XMLUtils.startXmlDocument(writer);
+            XMLConverter.writeObject(writer, CmisVersion.CMIS_1_1, true, "object", XMLConstants.NAMESPACE_CMIS,
object);
+            XMLUtils.endXmlDocument(writer);
         } catch (Exception e) {
             throw new CmisStorageException("Couldn't store properties!", e);
         } finally {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/BasicsTestGroup.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/basics/BasicsTestGroup.java?rev=1455931&r1=1455930&r2=1455931&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/BasicsTestGroup.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/basics/BasicsTestGroup.java
Wed Mar 13 13:32:49 2013
@@ -37,6 +37,5 @@ public class BasicsTestGroup extends Abs
         addTest(new SecurityTest());
         addTest(new RepositoryInfoTest());
         addTest(new RootFolderTest());
-        addTest(new TypesTest());
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.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/crud/CreateAndDeleteDocumentTest.java?rev=1455931&r1=1455930&r2=1455931&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java
Wed Mar 13 13:32:49 2013
@@ -19,6 +19,7 @@
 package org.apache.chemistry.opencmis.tck.tests.crud;
 
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.INFO;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
 
 import java.io.IOException;
@@ -31,6 +32,7 @@ import java.util.Set;
 
 import org.apache.chemistry.opencmis.client.api.CmisObject;
 import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.DocumentType;
 import org.apache.chemistry.opencmis.client.api.Folder;
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
 import org.apache.chemistry.opencmis.client.api.Session;
@@ -99,7 +101,13 @@ public class CreateAndDeleteDocumentTest
             }
 
             // check version series ids
-            f = createResult(FAILURE, "Although the created documents are independent, some
share a Version Series Id!");
+            if (Boolean.TRUE.equals(((DocumentType) documents.values().iterator().next().getType()).isVersionable()))
{
+                f = createResult(FAILURE,
+                        "Although the created documents are independent, some documents share
a Version Series Id!");
+            } else {
+                f = createResult(INFO, "Some documents share the same Version Series Id.");
+            }
+
             addResult(assertEquals(numOfDocuments, versionSeriesIds.size(), null, f));
 
             // check paging

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.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/types/BaseTypesTest.java?rev=1455931&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java
Wed Mar 13 13:32:49 2013
@@ -0,0 +1,259 @@
+/*
+ * 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.tests.types;
+
+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.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+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;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+public class BaseTypesTest extends AbstractSessionTest {
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Types Test");
+        setDescription("Checks all types exposed by the repository for specification compliance.");
+    }
+
+    @Override
+    public void run(Session session) {
+        CmisTestResult failure;
+
+        // check base types
+        Set<String> cmisTypes = new HashSet<String>();
+        cmisTypes.add(BaseTypeId.CMIS_DOCUMENT.value());
+        cmisTypes.add(BaseTypeId.CMIS_FOLDER.value());
+        cmisTypes.add(BaseTypeId.CMIS_RELATIONSHIP.value());
+        cmisTypes.add(BaseTypeId.CMIS_POLICY.value());
+
+        if (session.getRepositoryInfo().getCmisVersion() != CmisVersion.CMIS_1_0) {
+            cmisTypes.add(BaseTypeId.CMIS_ITEM.value());
+            cmisTypes.add(BaseTypeId.CMIS_SECONDARY.value());
+        }
+
+        for (TypeDefinition typeDef : session.getTypeChildren(null, false)) {
+            String typeId = typeDef.getId();
+
+            if (typeId == null || !cmisTypes.contains(typeId)) {
+                addResult(createResult(FAILURE, "Base type has an invalid id: " + typeId));
+            }
+
+            if (typeDef.getPropertyDefinitions() != null) {
+                addResult(createResult(WARNING, "Property type definitions were not requested
but delivered. Type id: "
+                        + typeId));
+            }
+        }
+
+        // document
+        try {
+            TypeDefinition documentType = session.getTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value());
+            addResult(checkTypeDefinition(session, documentType, "Document type spec compliance."));
+
+            failure = createResult(FAILURE, "Document type has the wrong base type: " + documentType.getBaseTypeId());
+            addResult(assertEquals(BaseTypeId.CMIS_DOCUMENT, documentType.getBaseTypeId(),
null, failure));
+        } catch (CmisObjectNotFoundException e) {
+            addResult(createResult(FAILURE, "Document type not available!", e, false));
+        }
+
+        // folder
+        try {
+            TypeDefinition folderType = session.getTypeDefinition(BaseTypeId.CMIS_FOLDER.value());
+
+            addResult(checkTypeDefinition(session, folderType, "Folder type spec compliance."));
+
+            failure = createResult(FAILURE, "Folder type has the wrong base type: " + folderType.getBaseTypeId());
+            addResult(assertEquals(BaseTypeId.CMIS_FOLDER, folderType.getBaseTypeId(), null,
failure));
+        } catch (CmisObjectNotFoundException e) {
+            addResult(createResult(FAILURE, "Folder type not available!", e, false));
+        }
+
+        // relationship
+        try {
+            TypeDefinition relationshipType = session.getTypeDefinition(BaseTypeId.CMIS_RELATIONSHIP.value());
+            addResult(checkTypeDefinition(session, relationshipType, "Relationship type spec
compliance."));
+
+            failure = createResult(FAILURE,
+                    "Relationship type has the wrong base type: " + relationshipType.getBaseTypeId());
+            addResult(assertEquals(BaseTypeId.CMIS_RELATIONSHIP, relationshipType.getBaseTypeId(),
null, failure));
+        } catch (CmisObjectNotFoundException e) {
+            addResult(createResult(WARNING, "Relationship type not available!", e, false));
+        }
+
+        // policy
+        try {
+            TypeDefinition policyType = session.getTypeDefinition(BaseTypeId.CMIS_POLICY.value());
+            addResult(checkTypeDefinition(session, policyType, "Policy type spec compliance."));
+
+            failure = createResult(FAILURE, "Policy type has the wrong base type: " + policyType.getBaseTypeId());
+            addResult(assertEquals(BaseTypeId.CMIS_POLICY, policyType.getBaseTypeId(), null,
failure));
+        } catch (CmisInvalidArgumentException e) {
+            addResult(createResult(WARNING, "Policy type not available!", e, false));
+        } catch (CmisObjectNotFoundException e) {
+            addResult(createResult(WARNING, "Policy type not available!", e, false));
+        }
+
+        // CMIS 1.1 types
+        if (session.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_1) {
+            // item
+            try {
+                TypeDefinition itemType = session.getTypeDefinition(BaseTypeId.CMIS_ITEM.value());
+                addResult(checkTypeDefinition(session, itemType, "Item type spec compliance."));
+
+                failure = createResult(FAILURE, "Item type has the wrong base type: " + itemType.getBaseTypeId());
+                addResult(assertEquals(BaseTypeId.CMIS_ITEM, itemType.getBaseTypeId(), null,
failure));
+            } catch (CmisInvalidArgumentException e) {
+                addResult(createResult(WARNING, "Item type not available!", e, false));
+            } catch (CmisObjectNotFoundException e) {
+                addResult(createResult(WARNING, "Item type not available!", e, false));
+            }
+
+            // secondary type
+            try {
+                TypeDefinition secondaryType = session.getTypeDefinition(BaseTypeId.CMIS_SECONDARY.value());
+                addResult(checkTypeDefinition(session, secondaryType, "Secondary type spec
compliance."));
+
+                failure = createResult(FAILURE,
+                        "Secondary type has the wrong base type: " + secondaryType.getBaseTypeId());
+                addResult(assertEquals(BaseTypeId.CMIS_SECONDARY, secondaryType.getBaseTypeId(),
null, failure));
+            } catch (CmisInvalidArgumentException e) {
+                addResult(createResult(WARNING, "Secondary type not available!", e, false));
+            } catch (CmisObjectNotFoundException e) {
+                addResult(createResult(WARNING, "Secondary type not available!", e, false));
+            }
+        }
+
+        int numOfTypes = runTypeChecks(session, session.getTypeDescendants(null, -1, true));
+
+        addResult(createInfoResult("Checked " + numOfTypes + " type definitions."));
+    }
+
+    private int runTypeChecks(Session session, List<Tree<ObjectType>> types)
{
+        if (types == null) {
+            return 0;
+        }
+
+        int numOfTypes = 0;
+        CmisTestResult failure;
+
+        for (Tree<ObjectType> tree : types) {
+            failure = createResult(FAILURE, "Types tree contains null leaf!");
+            addResult(assertNotNull(tree, null, failure));
+
+            if (tree != null) {
+                numOfTypes++;
+
+                addResult(checkTypeDefinition(session, tree.getItem(), "Type spec compliance:
"
+                        + tree.getItem().getId()));
+
+                // 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;
+    }
+
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/BaseTypesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.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/types/TypesTestGroup.java?rev=1455931&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.java
Wed Mar 13 13:32:49 2013
@@ -0,0 +1,38 @@
+/*
+ * 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.tests.types;
+
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTestGroup;
+
+/**
+ * This test group contains tests that check type operations.
+ */
+public class TypesTestGroup extends AbstractSessionTestGroup {
+    @Override
+    public void init(Map<String, String> parameters) throws Exception {
+        super.init(parameters);
+
+        setName("Types Test Group");
+        setDescription("Types tests.");
+
+        addTest(new BaseTypesTest());
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/types/TypesTestGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/resources/cmis-tck-groups.txt
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/resources/cmis-tck-groups.txt?rev=1455931&r1=1455930&r2=1455931&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/resources/cmis-tck-groups.txt
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/resources/cmis-tck-groups.txt
Wed Mar 13 13:32:49 2013
@@ -22,6 +22,7 @@
 ###############################################################
 
 org.apache.chemistry.opencmis.tck.tests.basics.BasicsTestGroup
+org.apache.chemistry.opencmis.tck.tests.types.TypesTestGroup
 org.apache.chemistry.opencmis.tck.tests.crud.CRUDTestGroup
 org.apache.chemistry.opencmis.tck.tests.versioning.VersioningTestGroup
 org.apache.chemistry.opencmis.tck.tests.filing.FilingTestGroup



Mime
View raw message