chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1301977 - /chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/
Date Sat, 17 Mar 2012 18:51:16 GMT
Author: fmui
Date: Sat Mar 17 18:51:15 2012
New Revision: 1301977

URL: http://svn.apache.org/viewvc?rev=1301977&view=rev
Log:
TCK: two additional query tests

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/AbstractQueryTest.java
  (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.java
  (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryRootFolderTest.java
  (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QuerySmokeTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryTestGroup.java

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/AbstractQueryTest.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/query/AbstractQueryTest.java?rev=1301977&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/AbstractQueryTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/AbstractQueryTest.java
Sat Mar 17 18:51:15 2012
@@ -0,0 +1,37 @@
+/*
+ * 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.query;
+
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
+import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
+
+public abstract class AbstractQueryTest extends AbstractSessionTest {
+
+    protected boolean supportsQuery(Session session) {
+        RepositoryInfo repository = session.getRepositoryInfo();
+
+        if (repository.getCapabilities().getQueryCapability() == null) {
+            return false;
+        }
+
+        return repository.getCapabilities().getQueryCapability() != CapabilityQuery.NONE;
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/AbstractQueryTest.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/query/QueryLikeTest.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/query/QueryLikeTest.java?rev=1301977&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.java
Sat Mar 17 18:51:15 2012
@@ -0,0 +1,92 @@
+/*
+ * 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.query;
+
+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.CmisObject;
+import org.apache.chemistry.opencmis.client.api.OperationContext;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+
+public class QueryLikeTest extends AbstractQueryTest {
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Query LIKE Test");
+        setDescription("Performs a query that should return the root folder name and id.");
+    }
+
+    @Override
+    public void run(Session session) {
+        if (supportsQuery(session)) {
+
+            OperationContext context = session.createOperationContext();
+            context.setFilterString("cmis:name,cmis:creationDate");
+            context.setCacheEnabled(false);
+            context.setIncludeAcls(false);
+            context.setIncludeAllowableActions(false);
+            context.setIncludePathSegments(false);
+            context.setIncludePolicies(false);
+            context.setIncludeRelationships(IncludeRelationships.NONE);
+            context.setRenditionFilterString("cmis:none");
+            context.setOrderBy("cmis:creationDate");
+
+            CmisTestResult f;
+
+            for (char c = 'a'; c <= 'z'; c++) {
+                long timestamp = Long.MIN_VALUE;
+
+                for (CmisObject o : session
+                        .queryObjects("cmis:document", "cmis:name LIKE '" + c + "%'", false,
context).getPage(10)) {
+
+                    if (o.getName() == null) {
+                        addResult(createResult(
+                                FAILURE,
+                                "Documents without name should not be returned by this query!
Document id: "
+                                        + o.getId()));
+                    } else {
+                        f = createResult(FAILURE,
+                                "Document name should start with '" + c + "' but the name
is '" + o.getName() + "'");
+                        addResult(assertIsTrue(o.getName().startsWith("" + c), null, f));
+                    }
+
+                    if (o.getCreationDate() == null) {
+                        addResult(createResult(FAILURE,
+                                "Found document without creation date! Document id: " + o.getId()));
+                    } else {
+                        f = createResult(FAILURE,
+                                "Query results should be ordered by cmis:creationDate but
they are not!");
+                        addResult(assertIsTrue(timestamp <= o.getCreationDate().getTimeInMillis(),
null, f));
+
+                        timestamp = o.getCreationDate().getTimeInMillis();
+                    }
+                }
+            }
+
+        } else {
+            addResult(createResult(SKIPPED, "Query not supported. Test Skipped!"));
+        }
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.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/query/QueryRootFolderTest.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/query/QueryRootFolderTest.java?rev=1301977&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryRootFolderTest.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryRootFolderTest.java
Sat Mar 17 18:51:15 2012
@@ -0,0 +1,136 @@
+/*
+ * 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.query;
+
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
+
+import java.util.GregorianCalendar;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.QueryResult;
+import org.apache.chemistry.opencmis.client.api.QueryStatement;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.tck.CmisTestResult;
+
+/**
+ * Root folder query test.
+ */
+public class QueryRootFolderTest extends AbstractQueryTest {
+
+    @Override
+    public void init(Map<String, String> parameters) {
+        super.init(parameters);
+        setName("Query Root Folder Test");
+        setDescription("Performs a query that should return the root folder name and id.");
+    }
+
+    @Override
+    public void run(Session session) {
+        if (supportsQuery(session)) {
+            queryById(session);
+            queryByDate(session);
+        } else {
+            addResult(createResult(SKIPPED, "Query not supported. Test Skipped!"));
+        }
+    }
+
+    protected void queryById(Session session) {
+        CmisTestResult f;
+
+        String testType = "cmis:folder";
+
+        Folder rootFolder = session.getRootFolder();
+
+        QueryStatement statement = session
+                .createQueryStatement("SELECT ? AS folderName, ? AS folderId FROM ? WHERE
? = ?");
+
+        statement.setProperty(1, testType, PropertyIds.NAME);
+        statement.setProperty(2, testType, PropertyIds.OBJECT_ID);
+        statement.setType(3, testType);
+        statement.setProperty(4, testType, PropertyIds.OBJECT_ID);
+        statement.setString(5, rootFolder.getId());
+
+        addResult(createInfoResult("Query: " + statement.toQueryString()));
+
+        int count = 0;
+        for (QueryResult qr : statement.query(false)) {
+            count++;
+
+            String folderName = qr.getPropertyValueByQueryName("folderName");
+            String folderId = qr.getPropertyValueByQueryName("folderId");
+
+            f = createResult(FAILURE, "Query result does not match root folder name!");
+            addResult(assertEquals(rootFolder.getName(), folderName, null, f));
+
+            f = createResult(FAILURE, "Query result does not match root folder id!");
+            addResult(assertEquals(rootFolder.getId(), folderId, null, f));
+        }
+
+        f = createResult(FAILURE, "The query should return exactly one result but returned
" + count + "!");
+        addResult(assertEquals(1, count, null, f));
+    }
+
+    protected void queryByDate(Session session) {
+        CmisTestResult f;
+
+        String testType = "cmis:folder";
+
+        Folder rootFolder = session.getRootFolder();
+
+        GregorianCalendar before = new GregorianCalendar();
+        before.setTimeInMillis(rootFolder.getCreationDate().getTimeInMillis() - (60 * 60
* 1000));
+
+        GregorianCalendar after = new GregorianCalendar();
+        after.setTimeInMillis(rootFolder.getCreationDate().getTimeInMillis() + (60 * 60 *
1000));
+
+        QueryStatement statement = session
+                .createQueryStatement("SELECT ? AS folderName, ? AS folderId FROM ? WHERE
? > TIMESTAMP ? AND ? < TIMESTAMP ?");
+
+        statement.setProperty(1, testType, PropertyIds.NAME);
+        statement.setProperty(2, testType, PropertyIds.OBJECT_ID);
+        statement.setType(3, testType);
+        statement.setProperty(4, testType, PropertyIds.CREATION_DATE);
+        statement.setDateTime(5, before);
+        statement.setProperty(6, testType, PropertyIds.CREATION_DATE);
+        statement.setDateTime(7, after);
+
+        addResult(createInfoResult("Query: " + statement.toQueryString()));
+
+        boolean found = false;
+        for (QueryResult qr : statement.query(false)) {
+            String folderId = qr.getPropertyValueByQueryName("folderId");
+
+            if (rootFolder.getId().equals(folderId)) {
+                found = true;
+
+                String folderName = qr.getPropertyValueByQueryName("folderName");
+
+                f = createResult(FAILURE, "Query result does not match root folder name!");
+                addResult(assertEquals(rootFolder.getName(), folderName, null, f));
+                break;
+            }
+        }
+
+        f = createResult(FAILURE, "The query should return the root folder but does not!");
+        addResult(assertIsTrue(found, null, f));
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryRootFolderTest.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/query/QuerySmokeTest.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/query/QuerySmokeTest.java?rev=1301977&r1=1301976&r2=1301977&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QuerySmokeTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QuerySmokeTest.java
Sat Mar 17 18:51:15 2012
@@ -33,18 +33,15 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
-import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
-import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
 import org.apache.chemistry.opencmis.tck.impl.CmisTestResultImpl;
 
 /**
  * Query smoke test.
  */
-public class QuerySmokeTest extends AbstractSessionTest {
+public class QuerySmokeTest extends AbstractQueryTest {
 
     @Override
     public void init(Map<String, String> parameters) {
@@ -61,6 +58,8 @@ public class QuerySmokeTest extends Abst
             String testType = "cmis:document";
             String statement = "SELECT * FROM " + testType;
 
+            addResult(createInfoResult("Query: " + statement));
+
             ObjectType type = session.getTypeDefinition(testType);
 
             f = createResult(FAILURE, "Test type definition '" + testType + "'not found!");
@@ -157,14 +156,4 @@ public class QuerySmokeTest extends Abst
 
         return (result.getStatus().getLevel() <= OK.getLevel() ? null : result);
     }
-
-    protected boolean supportsQuery(Session session) {
-        RepositoryInfo repository = session.getRepositoryInfo();
-
-        if (repository.getCapabilities().getQueryCapability() == null) {
-            return false;
-        }
-
-        return repository.getCapabilities().getQueryCapability() != CapabilityQuery.NONE;
-    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryTestGroup.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/query/QueryTestGroup.java?rev=1301977&r1=1301976&r2=1301977&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryTestGroup.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryTestGroup.java
Sat Mar 17 18:51:15 2012
@@ -34,6 +34,8 @@ public class QueryTestGroup extends Abst
         setDescription("Query and content changes tests.");
 
         addTest(new QuerySmokeTest());
+        addTest(new QueryRootFolderTest());
+        addTest(new QueryLikeTest());
         addTest(new ContentChangesSmokeTest());
     }
 }



Mime
View raw message