This project has retired. For details please refer to its
Attic page.
QueryLikeTest xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.tck.tests.query;
2021importstatic org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
22importstatic org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
2324import java.util.Map;
2526import org.apache.chemistry.opencmis.client.api.CmisObject;
27import org.apache.chemistry.opencmis.client.api.OperationContext;
28import org.apache.chemistry.opencmis.client.api.Session;
29import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
30import org.apache.chemistry.opencmis.tck.CmisTestResult;
3132publicclassQueryLikeTestextendsAbstractQueryTest {
3334 @Override
35publicvoid init(Map<String, String> parameters) {
36super.init(parameters);
37 setName("Query LIKE Test");
38 setDescription("Performs a query that should return the root folder name and id.");
39 }
4041 @Override
42publicvoid run(Session session) {
43if (supportsQuery(session)) {
4445 OperationContext context = session.createOperationContext();
46 context.setFilterString("cmis:name,cmis:creationDate");
47 context.setCacheEnabled(false);
48 context.setIncludeAcls(false);
49 context.setIncludeAllowableActions(false);
50 context.setIncludePathSegments(false);
51 context.setIncludePolicies(false);
52 context.setIncludeRelationships(IncludeRelationships.NONE);
53 context.setRenditionFilterString("cmis:none");
54 context.setOrderBy("cmis:creationDate");
5556CmisTestResult f;
5758for (char c = 'a'; c <= 'z'; c++) {
59long timestamp = Long.MIN_VALUE;
6061for (CmisObject o : session
62 .queryObjects("cmis:document", "cmis:name LIKE '" + c + "%'", false, context).getPage(10)) {
6364if (o.getName() == null) {
65 addResult(createResult(
66 FAILURE,
67"Documents without name should not be returned by this query! Document id: "68 + o.getId()));
69 } else {
70 f = createResult(FAILURE,
71"Document name should start with '" + c + "' but the name is '" + o.getName() + "'");
72 addResult(assertIsTrue(o.getName().startsWith("" + c), null, f));
73 }
7475if (o.getCreationDate() == null) {
76 addResult(createResult(FAILURE,
77"Found document without creation date! Document id: " + o.getId()));
78 } else {
79 f = createResult(FAILURE,
80"Query results should be ordered by cmis:creationDate but they are not!");
81 addResult(assertIsTrue(timestamp <= o.getCreationDate().getTimeInMillis(), null, f));
8283 timestamp = o.getCreationDate().getTimeInMillis();
84 }
85 }
86 }
8788 } else {
89 addResult(createResult(SKIPPED, "Query not supported. Test Skipped!"));
90 }
91 }
92 }