This project has retired. For details please refer to its Attic page.
MoveTest xref

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.tck.tests.crud;
20  
21  import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
22  
23  import java.util.Map;
24  
25  import org.apache.chemistry.opencmis.client.api.Document;
26  import org.apache.chemistry.opencmis.client.api.Folder;
27  import org.apache.chemistry.opencmis.client.api.Session;
28  import org.apache.chemistry.opencmis.tck.CmisTestResult;
29  import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
30  
31  /**
32   * Copy test.
33   */
34  public class MoveTest extends AbstractSessionTest {
35  
36      @Override
37      public void init(Map<String, String> parameters) {
38          super.init(parameters);
39          setName("Move Test");
40          setDescription("Creates two folders and a document and moves the document from one folder to the other.");
41      }
42  
43      @Override
44      public void run(Session session) {
45          CmisTestResult f;
46  
47          try {
48              // create folders
49              Folder testFolder = createTestFolder(session);
50              Folder folder1 = createFolder(session, testFolder, "movefolder1");
51              Folder folder2 = createFolder(session, testFolder, "movefolder2");
52  
53              // create document
54              Document doc1 = createDocument(session, folder1, "movetestdoc.txt", "move test");
55  
56              // move
57              Document doc2 = (Document) doc1.move(folder1, folder2, SELECT_ALL_NO_CACHE_OC);
58  
59              if (doc2 == null) {
60                  addResult(createResult(FAILURE, "Moved document is null!"));
61              } else {
62                  addResult(checkObject(session, doc2, getAllProperties(doc2),
63                          "Moved document check. Id: + " + doc2.getName()));
64              }
65  
66              int count1 = countFolderChildren(folder1);
67              f = createResult(FAILURE, "Source folder should be empty after move but has " + count1 + " children!");
68              addResult(assertEquals(0, count1, null, f));
69  
70              int count2 = countFolderChildren(folder2);
71              f = createResult(FAILURE, "Target folder should have exactly one child but has " + count2 + " children!");
72              addResult(assertEquals(1, count2, null, f));
73          } finally {
74              // clean up
75              deleteTestFolder();
76          }
77      }
78  }