You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2013/12/22 19:25:21 UTC
svn commit: r1553016 - in
/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud:
CRUDTestGroup.java PropertyFilterTest.java
Author: fmui
Date: Sun Dec 22 18:25:21 2013
New Revision: 1553016
URL: http://svn.apache.org/r1553016
Log:
TCK: added property filter test
Added:
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/PropertyFilterTest.java
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CRUDTestGroup.java
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=1553016&r1=1553015&r2=1553016&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 Sun Dec 22 18:25:21 2013
@@ -41,6 +41,7 @@ public class CRUDTestGroup extends Abstr
addTest(new NameCharsetTest());
addTest(new CreateAndDeleteRelationshipTest());
addTest(new CreateAndDeleteItemTest());
+ addTest(new PropertyFilterTest());
addTest(new UpdateSmokeTest());
addTest(new BulkUpdatePropertiesTest());
addTest(new SetAndDeleteContentTest());
Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/PropertyFilterTest.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/PropertyFilterTest.java?rev=1553016&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/PropertyFilterTest.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/PropertyFilterTest.java Sun Dec 22 18:25:21 2013
@@ -0,0 +1,172 @@
+/*
+ * 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.WARNING;
+
+import java.util.HashSet;
+import java.util.Map;
+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.Folder;
+import org.apache.chemistry.opencmis.client.api.OperationContext;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.client.util.OperationContextUtils;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+public class PropertyFilterTest extends AbstractSessionTest {
+
+ private static final String CONTENT = "TCK test content.";
+ private static final String INVALID_PROPERTY = "cmis:tck:thisPropertyDoesNotExist";
+
+ @Override
+ public void init(Map<String, String> parameters) {
+ super.init(parameters);
+ setName("Property Filter Test");
+ setDescription("Tests different property filter combinations for documents and folders.");
+ }
+
+ @Override
+ public void run(Session session) {
+ CmisTestResult f;
+
+ // filter with MIME type
+ OperationContext testContext1 = OperationContextUtils.createMinimumOperationContext();
+ Set<String> testfilter1 = new HashSet<String>(testContext1.getFilter());
+ testfilter1.add(PropertyIds.CONTENT_STREAM_MIME_TYPE);
+ testContext1.setFilter(testfilter1);
+
+ // filter with path
+ OperationContext testContext2 = OperationContextUtils.createMinimumOperationContext();
+ Set<String> testfilter2 = new HashSet<String>(testContext2.getFilter());
+ testfilter2.add(PropertyIds.PATH);
+ testContext2.setFilter(testfilter2);
+
+ // filter with invalid property
+ OperationContext testContext3 = OperationContextUtils.createMinimumOperationContext();
+ Set<String> testfilter3 = new HashSet<String>(testContext3.getFilter());
+ testfilter3.add(INVALID_PROPERTY);
+ testContext3.setFilter(testfilter3);
+
+ // create a test folder
+ Folder testFolder = createTestFolder(session);
+
+ try {
+ Document doc = createDocument(session, testFolder, "doc", CONTENT);
+
+ Document doc1 = (Document) session.getObject(doc, testContext1);
+
+ // check document
+ f = createResult(FAILURE, "Document should have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
+ addResult(assertNotNull(doc1.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
+ f = createResult(FAILURE, "Document should not have the property " + PropertyIds.PATH + "!");
+ addResult(assertNull(doc1.getProperty(PropertyIds.PATH), null, f));
+ f = createResult(FAILURE, "Document should not have the property " + INVALID_PROPERTY + "!");
+ addResult(assertNull(doc1.getProperty(INVALID_PROPERTY), null, f));
+
+ Document doc2 = (Document) session.getObject(doc, testContext2);
+
+ f = createResult(WARNING, "Document should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE
+ + "!");
+ addResult(assertNull(doc2.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
+ f = createResult(FAILURE, "Document should not have the property " + PropertyIds.PATH + "!");
+ addResult(assertNull(doc2.getProperty(PropertyIds.PATH), null, f));
+ f = createResult(FAILURE, "Document should not have the property " + INVALID_PROPERTY + "!");
+ addResult(assertNull(doc2.getProperty(INVALID_PROPERTY), null, f));
+
+ Document doc3 = (Document) session.getObject(doc, testContext3);
+
+ f = createResult(WARNING, "Document should not have the property" + PropertyIds.CONTENT_STREAM_MIME_TYPE
+ + "!");
+ addResult(assertNull(doc3.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
+ f = createResult(FAILURE, "Document should not have the property" + PropertyIds.PATH + "!");
+ addResult(assertNull(doc3.getProperty(PropertyIds.PATH), null, f));
+ f = createResult(FAILURE, "Document should not have the property" + INVALID_PROPERTY + "!");
+ addResult(assertNull(doc3.getProperty(INVALID_PROPERTY), null, f));
+
+ // check folder
+ Folder folder1 = (Folder) session.getObject(testFolder, testContext1);
+
+ f = createResult(FAILURE, "Folder should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE
+ + "!");
+ addResult(assertNull(folder1.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
+ f = createResult(WARNING, "Folder should not have the property " + PropertyIds.PATH + "!");
+ addResult(assertNull(folder1.getProperty(PropertyIds.PATH), null, f));
+ f = createResult(FAILURE, "Folder should not have the property " + INVALID_PROPERTY + "!");
+ addResult(assertNull(folder1.getProperty(INVALID_PROPERTY), null, f));
+
+ Folder folder2 = (Folder) session.getObject(testFolder, testContext2);
+
+ f = createResult(FAILURE, "Folder should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE
+ + "!");
+ addResult(assertNull(folder2.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
+ f = createResult(FAILURE, "Folder should have the property " + PropertyIds.PATH + "!");
+ addResult(assertNotNull(folder2.getProperty(PropertyIds.PATH), null, f));
+ f = createResult(FAILURE, "Folder should not have the property " + INVALID_PROPERTY + "!");
+ addResult(assertNull(folder2.getProperty(INVALID_PROPERTY), null, f));
+
+ Folder folder3 = (Folder) session.getObject(testFolder, testContext3);
+
+ f = createResult(FAILURE, "Folder should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE
+ + "!");
+ addResult(assertNull(folder3.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
+ f = createResult(WARNING, "Folder should not have the property " + PropertyIds.PATH + "!");
+ addResult(assertNull(folder3.getProperty(PropertyIds.PATH), null, f));
+ f = createResult(FAILURE, "Folder should not have the property " + INVALID_PROPERTY + "!");
+ addResult(assertNull(folder3.getProperty(INVALID_PROPERTY), null, f));
+
+ // check children
+ CmisObject obj1 = testFolder.getChildren(testContext1).iterator().next();
+
+ f = createResult(WARNING, "Child should have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
+ addResult(assertNotNull(obj1.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
+ f = createResult(WARNING, "Child should not have the property " + PropertyIds.PATH + "!");
+ addResult(assertNull(obj1.getProperty(PropertyIds.PATH), null, f));
+ f = createResult(FAILURE, "Child should not have the property " + INVALID_PROPERTY + "!");
+ addResult(assertNull(obj1.getProperty(INVALID_PROPERTY), null, f));
+
+ CmisObject obj2 = testFolder.getChildren(testContext2).iterator().next();
+
+ f = createResult(WARNING, "Child should not have the property " + PropertyIds.CONTENT_STREAM_MIME_TYPE
+ + "!");
+ addResult(assertNull(obj2.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
+ f = createResult(WARNING, "Child should not have the property " + PropertyIds.PATH + "!");
+ addResult(assertNull(obj2.getProperty(PropertyIds.PATH), null, f));
+ f = createResult(FAILURE, "Child should not have the property " + INVALID_PROPERTY + "!");
+ addResult(assertNull(obj2.getProperty(INVALID_PROPERTY), null, f));
+
+ CmisObject obj3 = testFolder.getChildren(testContext3).iterator().next();
+
+ f = createResult(WARNING, "Child should not have the property" + PropertyIds.CONTENT_STREAM_MIME_TYPE + "!");
+ addResult(assertNull(obj3.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f));
+ f = createResult(WARNING, "Child should not have the property" + PropertyIds.PATH + "!");
+ addResult(assertNull(obj3.getProperty(PropertyIds.PATH), null, f));
+ f = createResult(FAILURE, "Child should not have the property" + INVALID_PROPERTY + "!");
+ addResult(assertNull(obj3.getProperty(INVALID_PROPERTY), null, f));
+ } finally {
+ // delete the test folder
+ deleteTestFolder();
+ }
+ }
+}