chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1455628 - 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 Tue, 12 Mar 2013 17:09:00 GMT
Author: fmui
Date: Tue Mar 12 17:09:00 2013
New Revision: 1455628

URL: http://svn.apache.org/r1455628
Log:
TCK: item test preparations 

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteItemTest.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/crud/CRUDTestGroup.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteRelationshipTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TckDialog.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=1455628&r1=1455627&r2=1455628&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
Tue Mar 12 17:09:00 2013
@@ -44,6 +44,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
 import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.Item;
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
 import org.apache.chemistry.opencmis.client.api.ObjectId;
 import org.apache.chemistry.opencmis.client.api.ObjectType;
@@ -114,6 +115,7 @@ public abstract class AbstractSessionTes
 
     private Boolean supportsRelationships;
     private Boolean supportsPolicies;
+    private Boolean supportsItems;
 
     public BindingType getBinding() {
         if (getParameters() == null) {
@@ -185,6 +187,15 @@ public abstract class AbstractSessionTes
         return objectTypeId;
     }
 
+    protected String getItemTestTypeId() {
+        String objectTypeId = getParameters().get(TestParameters.DEFAULT_ITEM_TYPE);
+        if (objectTypeId == null) {
+            objectTypeId = TestParameters.DEFAULT_ITEM_TYPE_VALUE;
+        }
+
+        return objectTypeId;
+    }
+
     // --- helpers ---
 
     protected String[] getAllProperties(CmisObject object) {
@@ -254,7 +265,7 @@ public abstract class AbstractSessionTes
         try {
             CmisTestResult f;
 
-            // check document name
+            // check folder name
             f = createResult(FAILURE, "Folder name does not match!", false);
             addResult(assertEquals(name, result.getName(), null, f));
 
@@ -479,6 +490,63 @@ public abstract class AbstractSessionTes
     }
 
     /**
+     * Creates a item.
+     */
+    protected Item createItem(Session session, Folder parent, String name) {
+        return createItem(session, parent, name, getItemTestTypeId());
+    }
+
+    /**
+     * Creates a item.
+     */
+    protected Item createItem(Session session, Folder parent, String name, String objectTypeId)
{
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(PropertyIds.NAME, name);
+        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
+
+        Item result = null;
+        try {
+            // create the item
+            result = parent.createItem(properties, null, null, null, SELECT_ALL_NO_CACHE_OC);
+        } catch (CmisBaseException e) {
+            addResult(createResult(UNEXPECTED_EXCEPTION, "Item could not be created! Exception:
" + e.getMessage(), e,
+                    true));
+            return null;
+        }
+
+        try {
+            CmisTestResult f;
+
+            // check item name
+            f = createResult(FAILURE, "Item name does not match!", false);
+            addResult(assertEquals(name, result.getName(), null, f));
+
+            addResult(checkObject(session, result, getAllProperties(result), "New item object
spec compliance"));
+        } catch (CmisBaseException e) {
+            addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created Item is invalid!
Exception: " + e.getMessage(),
+                    e, true));
+        }
+
+        if (parent != null) {
+            List<Folder> parents = result.getParents(SELECT_ALL_NO_CACHE_OC);
+            boolean found = false;
+            for (Folder folder : parents) {
+                if (parent.getId().equals(folder.getId())) {
+                    found = true;
+                    break;
+                }
+            }
+
+            if (!found) {
+                addResult(createResult(FAILURE,
+                        "The folder the item has been created in is not in the list of the
item parents!"));
+            }
+        }
+
+        return result;
+    }
+
+    /**
      * Deletes an object and checks if it is deleted.
      */
     protected void deleteObject(CmisObject object) {
@@ -624,6 +692,20 @@ public abstract class AbstractSessionTes
         return supportsPolicies.booleanValue();
     }
 
+    protected boolean hasItems(Session session) {
+        if (supportsItems == null) {
+            supportsItems = Boolean.FALSE;
+            for (ObjectType type : session.getTypeChildren(null, false)) {
+                if (BaseTypeId.CMIS_ITEM.value().equals(type.getId())) {
+                    supportsItems = Boolean.TRUE;
+                    break;
+                }
+            }
+        }
+
+        return supportsItems.booleanValue();
+    }
+
     protected CmisTestResult checkObject(Session session, CmisObject object, String[] properties,
String message) {
         List<CmisTestResult> results = new ArrayList<CmisTestResult>();
 

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=1455628&r1=1455627&r2=1455628&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
Tue Mar 12 17:09:00 2013
@@ -28,6 +28,9 @@ public class TestParameters {
     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_ITEM_TYPE = "org.apache.chemistry.opencmis.tck.default.itemType";
+    public static final String DEFAULT_ITEM_TYPE_VALUE = "cmis:item";
+
     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/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=1455628&r1=1455627&r2=1455628&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
Tue Mar 12 17:09:00 2013
@@ -39,6 +39,7 @@ public class CRUDTestGroup extends Abstr
         addTest(new CreateDocumentWithoutContent());
         addTest(new NameCharsetTest());
         addTest(new CreateAndDeleteRelationshipTest());
+        // addTest(new CreateAndDeleteItemTest());
         addTest(new UpdateSmokeTest());
         addTest(new SetAndDeleteContentTest());
         addTest(new ContentRangesTest());

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteItemTest.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/CreateAndDeleteItemTest.java?rev=1455628&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteItemTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteItemTest.java
Tue Mar 12 17:09:00 2013
@@ -0,0 +1,115 @@
+/*
+ * 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.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.Item;
+import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+/**
+ * Simple folder test.
+ */
+public class CreateAndDeleteItemTest extends AbstractSessionTest {
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Create and Delete Item Test");
+        setDescription("Creates a few items, checks the newly created itens and their parent
and finally deletes the created item.");
+    }
+
+    @Override
+    public void run(Session session) {
+        if (session.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_0) {
+            addResult(createResult(SKIPPED, "Items are not supporetd by CMIS 1.0. Test skipped!"));
+            return;
+        }
+
+        if (hasItems(session)) {
+            CmisTestResult f;
+
+            int numOfItems = 20;
+
+            // create a test folder
+            Folder testFolder = createTestFolder(session);
+
+            try {
+                Map<String, Item> items = new HashMap<String, Item>();
+
+                // create items
+                for (int i = 0; i < numOfItems; i++) {
+                    Item newItem = createItem(session, testFolder, "item" + i);
+                    items.put(newItem.getId(), newItem);
+                }
+
+                // check if all items are there
+                ItemIterable<CmisObject> children = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC);
+                List<String> childrenIds = new ArrayList<String>();
+                for (CmisObject child : children) {
+                    if (child != null) {
+                        childrenIds.add(child.getId());
+                        Item item = items.get(child.getId());
+
+                        f = createResult(FAILURE, "Item and test folder child don't match!
Id: " + child.getId());
+                        addResult(assertShallowEquals(item, child, null, f));
+                    }
+                }
+
+                f = createResult(FAILURE, "Number of created items does not match the number
of existing items!");
+                addResult(assertEquals(numOfItems, childrenIds.size(), null, f));
+
+                for (Item item : items.values()) {
+                    if (!childrenIds.contains(item.getId())) {
+                        addResult(createResult(FAILURE,
+                                "Created item not found in test folder children! Id: " +
item.getId()));
+                    }
+                }
+
+                // delete all item
+                for (Item item : items.values()) {
+                    item.delete(true);
+
+                    f = createResult(FAILURE,
+                            "Item should not exist anymore but it is still there! Id: " +
item.getId());
+                    addResult(assertIsFalse(exists(item), null, f));
+                }
+            } finally {
+                // delete the test folder
+                deleteTestFolder();
+            }
+
+            addResult(createInfoResult("Tested the creation and deletion of " + numOfItems
+ " items."));
+        } else {
+            addResult(createResult(SKIPPED, "Items 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/CreateAndDeleteItemTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=1455628&r1=1455627&r2=1455628&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteRelationshipTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteRelationshipTest.java
Tue Mar 12 17:09:00 2013
@@ -160,7 +160,7 @@ public class CreateAndDeleteRelationship
 			}
 		} else {
 			addResult(createResult(SKIPPED,
-					"Relationships not supported. Test Skipped!"));
+					"Relationships not supported. Test skipped!"));
 		}
 	}
 }

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=1455628&r1=1455627&r2=1455628&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
Tue Mar 12 17:09:00 2013
@@ -207,6 +207,10 @@ public class TckDialog {
                     BaseTypeId.CMIS_RELATIONSHIP.value(), TestParameters.DEFAULT_RELATIONSHIP_TYPE_VALUE);
             configPanel.add(Box.createRigidArea(new Dimension(1, 10)));
 
+            final JComboBox itemComboBox = addComboBox(configPanel, "Test item type:", BaseTypeId.CMIS_ITEM.value(),
+                    TestParameters.DEFAULT_ITEM_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));
@@ -244,6 +248,9 @@ public class TckDialog {
                             parameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE,
                                     (String) relationshipComboBox.getSelectedItem());
                         }
+                        if (itemComboBox.isEnabled()) {
+                            parameters.put(TestParameters.DEFAULT_ITEM_TYPE, (String) itemComboBox.getSelectedItem());
+                        }
                         parameters.put(TestParameters.DEFAULT_TEST_FOLDER_PARENT, testParentFolderField.getText());
 
                         runner.setParameters(parameters);



Mime
View raw message