This project has retired. For details please refer to its
Attic page.
MultifilingTest 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.filing;
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.data.RepositoryInfo;
30import org.apache.chemistry.opencmis.tck.CmisTestResult;
31import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
3233/**34 * Multifiling test.35 */36publicclassMultifilingTestextendsAbstractSessionTest {
3738 @Override
39publicvoid init(Map<String, String> parameters) {
40super.init(parameters);
41 setName("Multifiling Test");
42 setDescription("Creates two folders and a document in one of the folders, "43 + "adds the document to the second folder and then removes it again for the second folder.");
44 }
4546 @Override
47publicvoid run(Session session) {
48if (supportsMultifiling(session)) {
49CmisTestResult f;
5051int count1;
52int count2;
53int parents;
5455try {
56// create folders57 Folder testFolder = createTestFolder(session);
58 Folder folder1 = createFolder(session, testFolder, "folder1");
59 Folder folder2 = createFolder(session, testFolder, "folder2");
6061// create document62 Document doc1 = createDocument(session, folder1, "testdoc.txt", "multifiling test");
6364 addResult(checkChildren(session, folder1, "Folder 1 after createDocument()"));
65 addResult(checkChildren(session, folder2, "Folder 2 after createDocument()"));
6667 count1 = countFolderChildren(folder1);
68 f = createResult(FAILURE, "Folder 1 should have exactly one child but has " + count1 + " children!");
69 addResult(assertEquals(1, count1, null, f));
7071 count2 = countFolderChildren(folder2);
72 f = createResult(FAILURE, "Folder 2 should not have children but has " + count2 + " children!");
73 addResult(assertEquals(0, count2, null, f));
7475 parents = doc1.getParents().size();
76 f = createResult(FAILURE, "Document should have one parent but has " + parents + " parents!");
77 addResult(assertEquals(1, parents, null, f));
7879// add to other folder80 doc1.addToFolder(folder2, true);
8182 addResult(checkChildren(session, folder1, "Folder 1 after addToFolder()"));
83 addResult(checkChildren(session, folder2, "Folder 2 after addToFolder()"));
8485 count1 = countFolderChildren(folder1);
86 f = createResult(FAILURE, "Folder 1 should have exactly one child but has " + count1 + " children!");
87 addResult(assertEquals(1, count1, null, f));
8889 count2 = countFolderChildren(folder2);
90 f = createResult(FAILURE, "Folder 2 should have exactly one child but has " + count2 + " children!");
91 addResult(assertEquals(1, count2, null, f));
9293 parents = doc1.getParents().size();
94 f = createResult(FAILURE, "Document should have two parents but has " + parents + " parents!");
95 addResult(assertEquals(2, parents, null, f));
9697// remove from first folder98 doc1.removeFromFolder(folder2);
99100 addResult(checkChildren(session, folder1, "Folder 1 after removeFromFolder()"));
101 addResult(checkChildren(session, folder2, "Folder 2 after removeFromFolder()"));
102103 count1 = countFolderChildren(folder1);
104 f = createResult(FAILURE, "Folder 1 should have exactly one child but has " + count1 + " children!");
105 addResult(assertEquals(1, count1, null, f));
106107 count2 = countFolderChildren(folder2);
108 f = createResult(FAILURE, "Folder 2 should not have children but has " + count2 + " children!");
109 addResult(assertEquals(0, count2, null, f));
110111 parents = doc1.getParents().size();
112 f = createResult(FAILURE, "Document should have one parent but has " + parents + " parents!");
113 addResult(assertEquals(1, parents, null, f));
114115// delete everything116 deleteObject(doc1);
117 deleteObject(folder2);
118 deleteObject(folder1);
119 } finally {
120// clean up121 deleteTestFolder();
122 }
123 } else {
124 addResult(createResult(SKIPPED, "Multifling not supported. Test Skipped!"));
125 }
126 }
127128protectedboolean supportsMultifiling(Session session) {
129 RepositoryInfo repository = session.getRepositoryInfo();
130131if (repository.getCapabilities().isMultifilingSupported() == null) {
132return false;
133 }
134135return repository.getCapabilities().isMultifilingSupported().booleanValue();
136 }
137 }