1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
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
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
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
68 failure = createResult(FAILURE, "Root folder doesn't exist?!");
69 addResult(assertIsTrue(session.exists(ri.getRootFolderId()), null, failure));
70
71
72 addResult(checkObject(session, rootFolder, getAllProperties(rootFolder), "Root folder object spec compliance"));
73
74
75 failure = createResult(FAILURE,
76 "Root folder id in the repository info doesn't match the root folder object id!");
77 addResult(assertEquals(ri.getRootFolderId(), rootFolder.getId(), null, failure));
78
79 failure = createResult(FAILURE, "Root folder is not a cmis:folder!");
80 addResult(assertEquals(BaseTypeId.CMIS_FOLDER, rootFolder.getBaseTypeId(), null, failure));
81
82 failure = createResult(FAILURE, "Root folder path is not '/'!");
83 addResult(assertEquals("/", rootFolder.getPath(), null, failure));
84
85 failure = createResult(FAILURE, "Root folder has parents!");
86 addResult(assertEquals(0, rootFolder.getParents().size(), null, failure));
87
88
89 failure = createResult(FAILURE, "Root folder has CAN_GET_FOLDER_PARENT allowable action!");
90 addResult(assertNotAllowableAction(rootFolder, Action.CAN_GET_FOLDER_PARENT, null, failure));
91
92 failure = createResult(WARNING, "Root folder has no CAN_GET_CHILDREN allowable action!");
93 addResult(assertAllowableAction(rootFolder, Action.CAN_GET_CHILDREN, null, failure));
94
95
96 addResult(checkChildren(session, rootFolder, "Root folder children check"));
97 }
98 }