This project has retired. For details please refer to its Attic page.
RootFolderTest 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.basics;
20  
21  import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
22  import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.OK;
23  import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
24  
25  import java.util.Map;
26  
27  import org.apache.chemistry.opencmis.client.api.Folder;
28  import org.apache.chemistry.opencmis.client.api.Session;
29  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
30  import org.apache.chemistry.opencmis.commons.enums.Action;
31  import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
32  import org.apache.chemistry.opencmis.tck.CmisTestResult;
33  import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
34  
35  /**
36   * Basic root folder tests.
37   */
38  public class RootFolderTest extends AbstractSessionTest {
39  
40      @Override
41      public void init(Map<String, String> parameters) {
42          super.init(parameters);
43          setName("Root Folder Test");
44          setDescription("Checks the root folder and its children for specification compliance.");
45      }
46  
47      @Override
48      public void run(Session session) throws Exception {
49          CmisTestResult success;
50          CmisTestResult failure;
51  
52          // check root folder id
53          RepositoryInfo ri = getRepositoryInfo(session);
54  
55          success = createResult(OK, "Root folder id: " + ri.getRootFolderId());
56          failure = createResult(FAILURE, "Root folder id is not set!");
57          addResult(assertStringNotEmpty(ri.getRootFolderId(), success, failure));
58  
59          // get the root folder
60          Folder rootFolder = session.getRootFolder(SELECT_ALL_NO_CACHE_OC);
61  
62          if (rootFolder == null) {
63              addResult(createResult(FAILURE, "Root folder is not available!"));
64              return;
65          }
66  
67          addResult(checkObject(session, rootFolder, getAllProperties(rootFolder), "Root folder object spec compliance"));
68  
69          // folder and path
70          failure = createResult(FAILURE,
71                  "Root folder id in the repository info doesn't match the root folder object id!");
72          addResult(assertEquals(ri.getRootFolderId(), rootFolder.getId(), null, failure));
73  
74          failure = createResult(FAILURE, "Root folder is not a cmis:folder!");
75          addResult(assertEquals(BaseTypeId.CMIS_FOLDER, rootFolder.getBaseTypeId(), null, failure));
76  
77          failure = createResult(FAILURE, "Root folder path is not '/'!");
78          addResult(assertEquals("/", rootFolder.getPath(), null, failure));
79  
80          failure = createResult(FAILURE, "Root folder has parents!");
81          addResult(assertEquals(0, rootFolder.getParents().size(), null, failure));
82  
83          // allowable actions
84          failure = createResult(FAILURE, "Root folder has CAN_GET_FOLDER_PARENT allowable action!");
85          addResult(assertNotAllowableAction(rootFolder, Action.CAN_GET_FOLDER_PARENT, null, failure));
86  
87          failure = createResult(WARNING, "Root folder has no CAN_GET_CHILDREN allowable action!");
88          addResult(assertAllowableAction(rootFolder, Action.CAN_GET_CHILDREN, null, failure));
89  
90          // simple children test
91          addResult(checkChildren(session, rootFolder, "Root folder children check"));
92      }
93  }