chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1162032 - in /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/chemistry/opencm...
Date Fri, 26 Aug 2011 08:56:53 GMT
Author: fmui
Date: Fri Aug 26 08:56:52 2011
New Revision: 1162032

URL: http://svn.apache.org/viewvc?rev=1162032&view=rev
Log:
added more TCK test (relationships, multifiling, unfiling, policy checks)

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteRelationshipTest.java
  (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/FilingTestGroup.java
  (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/MultifilingTest.java
  (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/UnfilingTest.java
  (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/control/ACLSmokeTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/resources/cmis-tck-groups.txt
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java?rev=1162032&r1=1162031&r2=1162032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
Fri Aug 26 08:56:52 2011
@@ -32,6 +32,7 @@ import java.io.InputStreamReader;
 import java.io.Reader;
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -44,6 +45,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
 import org.apache.chemistry.opencmis.client.api.Folder;
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.ObjectId;
 import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Policy;
 import org.apache.chemistry.opencmis.client.api.Property;
@@ -59,6 +61,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
@@ -75,6 +78,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
@@ -375,6 +379,51 @@ public abstract class AbstractSessionTes
     }
 
     /**
+     * Creates a relationship.
+     */
+    protected Relationship createRelationship(Session session, String name, ObjectId source,
ObjectId target) {
+        String objectTypeId = getParameters().get(TestParameters.DEFAULT_RELATIONSHIP_TYPE);
+        if (objectTypeId == null) {
+            objectTypeId = TestParameters.DEFAULT_RELATIONSHIP_TYPE_VALUE;
+        }
+
+        return createRelationship(session, name, source, target, objectTypeId);
+    }
+
+    /**
+     * Creates a relationship.
+     */
+    protected Relationship createRelationship(Session session, String name, ObjectId source,
ObjectId target,
+            String objectTypeId) {
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(PropertyIds.NAME, name);
+        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
+        properties.put(PropertyIds.SOURCE_ID, source.getId());
+        properties.put(PropertyIds.TARGET_ID, target.getId());
+
+        ObjectId relId;
+        Relationship result = null;
+
+        try {
+            relId = session.createRelationship(properties);
+            result = (Relationship) session.getObject(relId, SELECT_ALL_NO_CACHE_OC);
+        } catch (Exception e) {
+            addResult(createResult(UNEXPECTED_EXCEPTION,
+                    "Relationship could not be created! Exception: " + e.getMessage(), e,
true));
+        }
+
+        try {
+            // check the new relationship
+            addResult(checkObject(session, result, getAllProperties(result), "New document
object spec compliance"));
+        } catch (CmisBaseException e) {
+            addResult(createResult(UNEXPECTED_EXCEPTION,
+                    "Newly created document is invalid! Exception: " + e.getMessage(), e,
true));
+        }
+
+        return result;
+    }
+
+    /**
      * Deletes an object and checks if it is deleted.
      */
     protected void deleteObject(CmisObject object) {
@@ -771,6 +820,30 @@ public abstract class AbstractSessionTes
                 addResult(results, checkACL(session, object.getAcl(), "ACL"));
             }
 
+            // check policies
+            if (hasPolicies(session)) {
+                try {
+                    List<ObjectData> appliedPolicies = session.getBinding().getPolicyService()
+                            .getAppliedPolicies(session.getRepositoryInfo().getId(), object.getId(),
"*", null);
+
+                    if (appliedPolicies == null) {
+                        appliedPolicies = Collections.emptyList();
+                    }
+
+                    List<Policy> objectPolicies = object.getPolicies();
+                    if (objectPolicies == null) {
+                        objectPolicies = Collections.emptyList();
+                    }
+
+                    f = createResult(FAILURE,
+                            "The number of policies returned by getAppliedPolicies() and
the number of object policies don't match!");
+                    addResult(results, assertEquals(appliedPolicies.size(), objectPolicies.size(),
null, f));
+                } catch (CmisNotSupportedException e) {
+                    addResult(results,
+                            createResult(WARNING, "getAppliedPolicies() not supported for
object: " + object.getId()));
+                }
+            }
+
             // check relationships
             checkRelationships(session, results, object);
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java?rev=1162032&r1=1162031&r2=1162032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/TestParameters.java
Fri Aug 26 08:56:52 2011
@@ -25,6 +25,9 @@ public class TestParameters {
     public static final String DEFAULT_DOCUMENT_TYPE = "org.apache.chemistry.opencmis.tck.default.documentType";
     public static final String DEFAULT_DOCUMENT_TYPE_VALUE = "cmis:document";
 
+    public static final String DEFAULT_RELATIONSHIP_TYPE = "org.apache.chemistry.opencmis.tck.default.relationshipType";
+    public static final String DEFAULT_RELATIONSHIP_TYPE_VALUE = "cmis:relationship";
+
     public static final String DEFAULT_TEST_FOLDER_PARENT = "org.apache.chemistry.opencmis.tck.default.testFolderParent";
     public static final String DEFAULT_TEST_FOLDER_PARENT_VALUE = "/";
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/control/ACLSmokeTest.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/control/ACLSmokeTest.java?rev=1162032&r1=1162031&r2=1162032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/control/ACLSmokeTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/control/ACLSmokeTest.java
Fri Aug 26 08:56:52 2011
@@ -45,7 +45,7 @@ public class ACLSmokeTest extends Abstra
     public void init(Map<String, String> parameters) {
         super.init(parameters);
         setName("ACL Test");
-        setDescription("Creates an object and check if the cmis:read ACE is applied!");
+        setDescription("Creates a document and checks its ACL.");
     }
 
     @Override

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.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/CRUDTestGroup.java?rev=1162032&r1=1162031&r2=1162032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
Fri Aug 26 08:56:52 2011
@@ -35,6 +35,7 @@ public class CRUDTestGroup extends Abstr
 
         addTest(new CreateAndDeleteFolderTest());
         addTest(new CreateAndDeleteDocumentTest());
+        addTest(new CreateAndDeleteRelationshipTest());
         addTest(new UpdateSmokeTest());
         addTest(new SetAndDeleteContentTest());
         addTest(new CopyTest());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.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/CopyTest.java?rev=1162032&r1=1162031&r2=1162032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CopyTest.java
Fri Aug 26 08:56:52 2011
@@ -82,6 +82,9 @@ public class CopyTest extends AbstractSe
             int count2 = countFolderChildren(folder2);
             f = createResult(FAILURE, "Target folder should have exactly one child but has
" + count2 + " children!");
             addResult(assertEquals(1, count2, null, f));
+            
+            deleteObject(doc2);
+            deleteObject(doc1);
         } finally {
             // clean up
             deleteTestFolder();

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteRelationshipTest.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/CreateAndDeleteRelationshipTest.java?rev=1162032&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteRelationshipTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteRelationshipTest.java
Fri Aug 26 08:56:52 2011
@@ -0,0 +1,152 @@
+/*
+ * 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.crud;
+
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.Relationship;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Simple folder test.
+ */
+public class CreateAndDeleteRelationshipTest extends AbstractSessionTest {
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Create and Delete Relationship Test");
+        setDescription("Creates a relationship between two documents, checks the newly created
relationship finally deletes the created relationship.");
+    }
+
+    @Override
+    public void run(Session session) {
+        CmisTestResult f;
+        boolean found;
+
+        if (hasRelationships(session)) {
+            // create a test folder
+            Folder testFolder = createTestFolder(session);
+
+            try {
+                // create documents
+                Document doc1 = createDocument(session, testFolder, "doc1.txt", "doc1");
+                Document doc2 = createDocument(session, testFolder, "doc2.txt", "doc2");
+
+                // create relationship
+                Relationship rel = createRelationship(session, "rel1", doc1, doc2);
+
+                f = createResult(FAILURE, "Source document id does not match relationship
source id!");
+                addResult(assertEquals(doc1.getId(), rel.getSourceId().getId(), null, f));
+
+                f = createResult(FAILURE, "Target document id does not match relationship
target id!");
+                addResult(assertEquals(doc2.getId(), rel.getTarget().getId(), null, f));
+
+                // check the source document
+                doc1.refresh();
+                List<Relationship> doc1rels = doc1.getRelationships();
+
+                f = createResult(FAILURE, "Source document has no relationships but must
have at least one!");
+                addResult(assertListNotEmpty(doc1rels, null, f));
+
+                if (doc1rels != null) {
+                    found = false;
+                    for (Relationship r : doc1rels) {
+                        if (rel.getId().equals(r.getId())) {
+                            found = true;
+                            break;
+                        }
+                    }
+
+                    f = createResult(FAILURE,
+                            "Newly created relationship not found in the relationships of
the source document!");
+                    addResult(assertIsTrue(found, null, f));
+                }
+
+                found = false;
+                for (Relationship r : session.getRelationships(doc1, true, RelationshipDirection.SOURCE,
null,
+                        SELECT_ALL_NO_CACHE_OC)) {
+                    if (rel.getId().equals(r.getId())) {
+                        found = true;
+                        break;
+                    }
+                }
+
+                f = createResult(
+                        FAILURE,
+                        "Newly created relationship not found in the relationships returned
by getObjectRelationships() for the source document!");
+                addResult(assertIsTrue(found, null, f));
+
+                // check the target document
+                doc2.refresh();
+                List<Relationship> doc2rels = doc2.getRelationships();
+
+                f = createResult(FAILURE, "Target document has no relationships but must
have at least one!");
+                addResult(assertListNotEmpty(doc2rels, null, f));
+
+                if (doc2rels != null) {
+                    found = false;
+                    for (Relationship r : doc2rels) {
+                        if (rel.getId().equals(r.getId())) {
+                            found = true;
+                            break;
+                        }
+                    }
+
+                    f = createResult(FAILURE,
+                            "Newly created relationship not found in the relationships of
the target document!");
+                    addResult(assertIsTrue(found, null, f));
+                }
+
+                found = false;
+                for (Relationship r : session.getRelationships(doc2, true, RelationshipDirection.TARGET,
null,
+                        SELECT_ALL_NO_CACHE_OC)) {
+                    if (rel.getId().equals(r.getId())) {
+                        found = true;
+                        break;
+                    }
+                }
+
+                f = createResult(
+                        FAILURE,
+                        "Newly created relationship not found in the relationships returned
by getObjectRelationships() for the target document!");
+                addResult(assertIsTrue(found, null, f));
+
+                // remove
+                deleteObject(rel);
+                deleteObject(doc2);
+                deleteObject(doc1);
+            } finally {
+                // delete the test folder
+                deleteTestFolder();
+            }
+        } else {
+            addResult(createResult(SKIPPED, "Relationships not supported. Test Skipped!"));
+        }
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteRelationshipTest.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/filing/FilingTestGroup.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/filing/FilingTestGroup.java?rev=1162032&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/FilingTestGroup.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/FilingTestGroup.java
Fri Aug 26 08:56:52 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.filing;
+
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTestGroup;
+
+/**
+ * This test group contains multifiling and unfiling tests.
+ */
+public class FilingTestGroup extends AbstractSessionTestGroup {
+    @Override
+    public void init(Map<String, String> parameters) throws Exception {
+        super.init(parameters);
+
+        setName("Filing Test Group");
+        setDescription("Multifiling anf Unfiling tests.");
+
+        addTest(new MultifilingTest());
+        addTest(new UnfilingTest());
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/FilingTestGroup.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/filing/MultifilingTest.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/filing/MultifilingTest.java?rev=1162032&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/MultifilingTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/MultifilingTest.java
Fri Aug 26 08:56:52 2011
@@ -0,0 +1,137 @@
+/*
+ * 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.filing;
+
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
+
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Multifiling test.
+ */
+public class MultifilingTest extends AbstractSessionTest {
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Multifiling Test");
+        setDescription("Creates two folders and a document in one of the folders, "
+                + "adds the document to the second folder and then removes it again for the
second folder.");
+    }
+
+    @Override
+    public void run(Session session) {
+        if (supportsMultifiling(session)) {
+            CmisTestResult f;
+
+            int count1;
+            int count2;
+            int parents;
+
+            try {
+                // create folders
+                Folder testFolder = createTestFolder(session);
+                Folder folder1 = createFolder(session, testFolder, "folder1");
+                Folder folder2 = createFolder(session, testFolder, "folder2");
+
+                // create document
+                Document doc1 = createDocument(session, folder1, "testdoc.txt", "multifiling
test");
+
+                addResult(checkChildren(session, folder1, "Folder 1 after createDocument()"));
+                addResult(checkChildren(session, folder2, "Folder 2 after createDocument()"));
+
+                count1 = countFolderChildren(folder1);
+                f = createResult(FAILURE, "Folder 1 should have exactly one child but has
" + count1 + " children!");
+                addResult(assertEquals(1, count1, null, f));
+
+                count2 = countFolderChildren(folder2);
+                f = createResult(FAILURE, "Folder 2 should not have children but has " +
count2 + " children!");
+                addResult(assertEquals(0, count2, null, f));
+
+                parents = doc1.getParents().size();
+                f = createResult(FAILURE, "Document should have one parent but has " + parents
+ " parents!");
+                addResult(assertEquals(1, parents, null, f));
+
+                // add to other folder
+                doc1.addToFolder(folder2, true);
+
+                addResult(checkChildren(session, folder1, "Folder 1 after addToFolder()"));
+                addResult(checkChildren(session, folder2, "Folder 2 after addToFolder()"));
+
+                count1 = countFolderChildren(folder1);
+                f = createResult(FAILURE, "Folder 1 should have exactly one child but has
" + count1 + " children!");
+                addResult(assertEquals(1, count1, null, f));
+
+                count2 = countFolderChildren(folder2);
+                f = createResult(FAILURE, "Folder 2 should have exactly one child but has
" + count2 + " children!");
+                addResult(assertEquals(1, count2, null, f));
+
+                parents = doc1.getParents().size();
+                f = createResult(FAILURE, "Document should have two parents but has " + parents
+ " parents!");
+                addResult(assertEquals(2, parents, null, f));
+
+                // remove from first folder
+                doc1.removeFromFolder(folder2);
+
+                addResult(checkChildren(session, folder1, "Folder 1 after removeFromFolder()"));
+                addResult(checkChildren(session, folder2, "Folder 2 after removeFromFolder()"));
+
+                count1 = countFolderChildren(folder1);
+                f = createResult(FAILURE, "Folder 1 should have exactly one child but has
" + count1 + " children!");
+                addResult(assertEquals(1, count1, null, f));
+
+                count2 = countFolderChildren(folder2);
+                f = createResult(FAILURE, "Folder 2 should not have children but has " +
count2 + " children!");
+                addResult(assertEquals(0, count2, null, f));
+
+                parents = doc1.getParents().size();
+                f = createResult(FAILURE, "Document should have one parent but has " + parents
+ " parents!");
+                addResult(assertEquals(1, parents, null, f));
+
+                // delete everything
+                deleteObject(doc1);
+                deleteObject(folder2);
+                deleteObject(folder1);
+            } finally {
+                // clean up
+                deleteTestFolder();
+            }
+        } else {
+            addResult(createResult(SKIPPED, "Multifling not supported. Test Skipped!"));
+        }
+    }
+
+    protected boolean supportsMultifiling(Session session) {
+        RepositoryInfo repository = session.getRepositoryInfo();
+
+        if (repository.getCapabilities().isMultifilingSupported() == null) {
+            return false;
+        }
+
+        return repository.getCapabilities().isMultifilingSupported().booleanValue();
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/MultifilingTest.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/filing/UnfilingTest.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/filing/UnfilingTest.java?rev=1162032&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/UnfilingTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/UnfilingTest.java
Fri Aug 26 08:56:52 2011
@@ -0,0 +1,118 @@
+/*
+ * 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.filing;
+
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
+
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Unfiling test.
+ */
+public class UnfilingTest extends AbstractSessionTest {
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Unfiling Test");
+        setDescription("Creates a folder and a document, removes the document from the folder
and then adds it again.");
+    }
+
+    @Override
+    public void run(Session session) {
+        if (supportsUnfiling(session)) {
+            CmisTestResult f;
+
+            int count;
+            int parents;
+
+            try {
+                // create folders
+                Folder testFolder = createTestFolder(session);
+                Folder folder1 = createFolder(session, testFolder, "folder1");
+
+                // create document
+                Document doc1 = createDocument(session, folder1, "testdoc.txt", "unfiling
test");
+
+                addResult(checkChildren(session, folder1, "Folder after createDocument()"));
+
+                count = countFolderChildren(folder1);
+                f = createResult(FAILURE, "Folder should have exactly one child but has "
+ count + " children!");
+                addResult(assertEquals(1, count, null, f));
+
+                parents = doc1.getParents().size();
+                f = createResult(FAILURE, "Document should have one parent but has " + parents
+ " parents!");
+                addResult(assertEquals(1, parents, null, f));
+
+                // remove from folder
+                doc1.removeFromFolder(folder1);
+
+                addResult(checkChildren(session, folder1, "Folder after removeFromFolder()"));
+
+                count = countFolderChildren(folder1);
+                f = createResult(FAILURE, "Folder should have no children but has " + count
+ " children!");
+                addResult(assertEquals(0, count, null, f));
+
+                parents = doc1.getParents().size();
+                f = createResult(FAILURE, "Document should not have no parents but has "
+ parents + " parents!");
+                addResult(assertEquals(0, parents, null, f));
+
+                // add to folder again
+                doc1.addToFolder(folder1, true);
+
+                addResult(checkChildren(session, folder1, "Folder after addToFolder()"));
+
+                count = countFolderChildren(folder1);
+                f = createResult(FAILURE, "Folder should have exactly one child but has "
+ count + " children!");
+                addResult(assertEquals(1, count, null, f));
+
+                parents = doc1.getParents().size();
+                f = createResult(FAILURE, "Document should have one parent but has " + parents
+ " parents!");
+                addResult(assertEquals(1, parents, null, f));
+
+                // delete everything
+                deleteObject(doc1);
+                deleteObject(folder1);
+            } finally {
+                // clean up
+                deleteTestFolder();
+            }
+        } else {
+            addResult(createResult(SKIPPED, "Unfiling not supported. Test Skipped!"));
+        }
+    }
+
+    protected boolean supportsUnfiling(Session session) {
+        RepositoryInfo repository = session.getRepositoryInfo();
+
+        if (repository.getCapabilities().isUnfilingSupported() == null) {
+            return false;
+        }
+
+        return repository.getCapabilities().isUnfilingSupported().booleanValue();
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/filing/UnfilingTest.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=1162032&r1=1162031&r2=1162032&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
Fri Aug 26 08:56:52 2011
@@ -24,5 +24,6 @@
 org.apache.chemistry.opencmis.tck.tests.basics.BasicsTestGroup
 org.apache.chemistry.opencmis.tck.tests.crud.CRUDTestGroup
 org.apache.chemistry.opencmis.tck.tests.versioning.VersioningTestGroup
+org.apache.chemistry.opencmis.tck.tests.filing.FilingTestGroup
 org.apache.chemistry.opencmis.tck.tests.control.ControlTestGroup
 org.apache.chemistry.opencmis.tck.tests.query.QueryTestGroup
\ No newline at end of file

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java?rev=1162032&r1=1162031&r2=1162032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.java
Fri Aug 26 08:56:52 2011
@@ -52,7 +52,6 @@ import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JProgressBar;
 import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
 import javax.swing.JTextField;
 import javax.swing.JTree;
 import javax.swing.SwingWorker;
@@ -192,6 +191,10 @@ public class TckDialog {
                     BaseTypeId.CMIS_DOCUMENT.value(), TestParameters.DEFAULT_DOCUMENT_TYPE_VALUE);
             configPanel.add(Box.createRigidArea(new Dimension(1, 10)));
 
+            final JComboBox relationshipComboBox = addComboBox(configPanel, "Test relationship
type:",
+                    BaseTypeId.CMIS_RELATIONSHIP.value(), TestParameters.DEFAULT_RELATIONSHIP_TYPE_VALUE);
+            configPanel.add(Box.createRigidArea(new Dimension(1, 10)));
+
             configPanel.add(new JLabel("Test folder path:"));
             final JTextField testParentFolderField = new JTextField(TestParameters.DEFAULT_TEST_FOLDER_PARENT_VALUE);
             testParentFolderField.setMaximumSize(new Dimension(Short.MAX_VALUE, 10));
@@ -225,6 +228,10 @@ public class TckDialog {
                         parameters.put(TestParameters.DEFAULT_FOLDER_TYPE, (String) folderComboBox.getSelectedItem());
                         parameters.put(TestParameters.DEFAULT_DOCUMENT_TYPE,
                                 (String) documentComboBox.getSelectedItem());
+                        if (relationshipComboBox.isEnabled()) {
+                            parameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE,
+                                    (String) relationshipComboBox.getSelectedItem());
+                        }
                         parameters.put(TestParameters.DEFAULT_TEST_FOLDER_PARENT, testParentFolderField.getText());
 
                         runner.setParameters(parameters);
@@ -278,6 +285,7 @@ public class TckDialog {
             comboBox.setSelectedItem(defaultTypeId);
             comboBox.setAlignmentX(Component.LEFT_ALIGNMENT);
             comboBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 10));
+            comboBox.setEnabled(typeIds.length > 0);
             panel.add(comboBox);
 
             return comboBox;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java?rev=1162032&r1=1162031&r2=1162032&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
Fri Aug 26 08:56:52 2011
@@ -48,6 +48,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.impl.MimeTypes;
 
 public class ClientModel {
@@ -250,10 +251,16 @@ public class ClientModel {
     public synchronized List<ObjectType> getCreateableTypes(String rootTypeId) {
         List<ObjectType> result = new ArrayList<ObjectType>();
 
+        ObjectType rootType = null;
+        try {
+            rootType = clientSession.getSession().getTypeDefinition(rootTypeId);
+        } catch (CmisObjectNotFoundException e) {
+            return result;
+        }
+
         List<Tree<ObjectType>> types = clientSession.getSession().getTypeDescendants(rootTypeId,
-1, false);
         addType(types, result);
 
-        ObjectType rootType = clientSession.getSession().getTypeDefinition(rootTypeId);
         boolean isCreatable = (rootType.isCreatable() == null ? true : rootType.isCreatable().booleanValue());
         if (isCreatable) {
             result.add(rootType);



Mime
View raw message