This project has retired. For details please refer to its
Attic page.
ContentChangesSmokeTest 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.ChangeEvent;
27import org.apache.chemistry.opencmis.client.api.ChangeEvents;
28import org.apache.chemistry.opencmis.client.api.CmisObject;
29import org.apache.chemistry.opencmis.client.api.Session;
30import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
31import org.apache.chemistry.opencmis.commons.enums.BindingType;
32import org.apache.chemistry.opencmis.commons.enums.CapabilityChanges;
33import org.apache.chemistry.opencmis.commons.enums.ChangeType;
34import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
35import org.apache.chemistry.opencmis.tck.CmisTestResult;
36import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
3738/**39 * Content Changes smoke test.40 */41publicclassContentChangesSmokeTestextendsAbstractSessionTest {
4243 @Override
44publicvoid init(Map<String, String> parameters) {
45super.init(parameters);
46 setName("Content Changes Smoke Test");
47 setDescription("Calls getContentChanges(). It does not check if the results are correct!");
48 }
4950 @Override
51publicvoid run(Session session) {
52CmisTestResult f;
5354if (supportsContentChanges(session)) {
55 ChangeEvents events = session.getContentChanges(null, true, 1000, SELECT_ALL_NO_CACHE_OC);
5657 f = createResult(FAILURE, "Change events are null!");
58 addResult(assertNotNull(events, null, f));
5960if (events != null && events.getChangeEvents() != null) {
6162if (getBinding() != BindingType.ATOMPUB) {
63// the AtompPub binding does not return a change log token64 f = createResult(FAILURE, "Change log token is null!");
65 addResult(assertNotNull(events.getLatestChangeLogToken(), null, f));
66 }
6768for (ChangeEvent event : events.getChangeEvents()) {
69 f = createResult(FAILURE, "Object Id is not set!");
70 addResult(assertStringNotEmpty(event.getObjectId(), null, f));
7172 f = createResult(FAILURE, "Change Type is not set! Id: " + event.getObjectId());
73 addResult(assertNotNull(event.getChangeType(), null, f));
7475 f = createResult(FAILURE, "Change Time is not set! Id: " + event.getObjectId());
76 addResult(assertNotNull(event.getChangeTime(), null, f));
7778if (event.getObjectId() != null) {
79if (event.getChangeType() == ChangeType.DELETED) {
80try {
81 session.getObject(event.getObjectId(), SELECT_ALL_NO_CACHE_OC);
82 addResult(createResult(FAILURE,
83"Change event indicates that an object has been deleted but it still exists. Id: "84 + event.getObjectId()));
85 } catch (CmisObjectNotFoundException e) {
86 }
87 } else {
88try {
89 CmisObject object = session.getObject(event.getObjectId(), SELECT_ALL_NO_CACHE_OC);
90 addResult(checkObject(session, object, getAllProperties(object), "Object check. Id: "91 + event.getObjectId()));
92 } catch (CmisObjectNotFoundException e) {
93// object might have been deleted later94 }
95 }
96 }
97 }
98 }
99 } else {
100 addResult(createResult(SKIPPED, "Content Changes not supported. Test Skipped!"));
101 }
102 }
103104protectedboolean supportsContentChanges(Session session) {
105 RepositoryInfo repository = session.getRepositoryInfo();
106107if (repository.getCapabilities().getChangesCapability() == null) {
108return false;
109 }
110111return repository.getCapabilities().getChangesCapability() != CapabilityChanges.NONE;
112 }
113 }