This project has retired. For details please refer to its
Attic page.
CopyTest 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.crud;
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.Document;
27import org.apache.chemistry.opencmis.client.api.Folder;
28import org.apache.chemistry.opencmis.client.api.Session;
29import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
30import org.apache.chemistry.opencmis.commons.enums.BindingType;
31import org.apache.chemistry.opencmis.commons.enums.VersioningState;
32import org.apache.chemistry.opencmis.tck.CmisTestResult;
33import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
3435/**36 * Copy test.37 */38publicclassCopyTestextendsAbstractSessionTest {
3940 @Override
41publicvoid init(Map<String, String> parameters) {
42super.init(parameters);
43 setName("Copy Test");
44 setDescription("Creates two folders and a document and copies the document from one folder to the other. "45 + " If the AtomPub binding is used, this test is skipped.");
46 }
4748 @Override
49publicvoid run(Session session) {
50if (getBinding() == BindingType.ATOMPUB) {
51 addResult(createResult(SKIPPED,
52"AtomPub binding does not support createDocumentFromSource(). Test Skipped!"));
53return;
54 }
5556CmisTestResult f;
5758try {
59// create folders60 Folder testFolder = createTestFolder(session);
61 Folder folder1 = createFolder(session, testFolder, "copyfolder1");
62 Folder folder2 = createFolder(session, testFolder, "copyfolder2");
6364// create document65 Document doc1 = createDocument(session, folder1, "copytestdoc.txt", "copy test");
6667 VersioningState versioningState = VersioningState.MAJOR;
68if (!((DocumentTypeDefinition) doc1.getType()).isVersionable()) {
69 versioningState = VersioningState.NONE;
70 }
7172// copy73 Document doc2 = doc1.copy(folder2, null, versioningState, null, null, null, SELECT_ALL_NO_CACHE_OC);
7475if (doc2 == null) {
76 addResult(createResult(FAILURE, "Copied document is null!"));
77 } else {
78 addResult(checkObject(session, doc2, getAllProperties(doc2),
79"Copied document check. Id: + " + doc2.getName()));
8081 f = createResult(FAILURE, "Content streams don't match!");
82 addResult(assertEquals(doc1.getContentStream(), doc2.getContentStream(), null, f));
83 }
8485int count1 = countFolderChildren(folder1);
86 f = createResult(FAILURE, "Source folder should have exactly one child but has " + count1 + " children!");
87 addResult(assertEquals(1, count1, null, f));
8889int count2 = countFolderChildren(folder2);
90 f = createResult(FAILURE, "Target folder should have exactly one child but has " + count2 + " children!");
91 addResult(assertEquals(1, count2, null, f));
9293 deleteObject(doc2);
94 deleteObject(doc1);
95 } finally {
96// clean up97 deleteTestFolder();
98 }
99 }
100 }