CMIS-1052: First steps towards Java 8, removed a few outdated pre-TCK tests
git-svn-id: https://svn.apache.org/repos/asf/chemistry/opencmis/trunk@1816057 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/AtomPubTestBindingFactory.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/AtomPubTestBindingFactory.java
deleted file mode 100644
index b20fbd3..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/AtomPubTestBindingFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.atompub;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
-import org.apache.chemistry.opencmis.commons.SessionParameter;
-import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
-
-public class AtomPubTestBindingFactory {
-
- private AtomPubTestBindingFactory() {
- }
-
- public static CmisBinding createBinding(String atomPubUrl, String user, String password) {
- // gather parameters
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put(SessionParameter.USER, user);
- parameters.put(SessionParameter.PASSWORD, password);
-
- parameters.put(SessionParameter.ATOMPUB_URL, atomPubUrl);
-
- // get factory and create provider
- CmisBindingFactory factory = CmisBindingFactory.newInstance();
- CmisBinding binding = factory.createCmisAtomPubBinding(parameters);
-
- return binding;
- }
-}
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/SimpleReadOnlyTests.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/SimpleReadOnlyTests.java
deleted file mode 100644
index d56461d..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/SimpleReadOnlyTests.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.atompub;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.chemistry.opencmis.client.bindings.framework.AbstractSimpleReadOnlyTests;
-import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
-
-public class SimpleReadOnlyTests extends AbstractSimpleReadOnlyTests {
-
- private final Set<String> fTests;
-
- public SimpleReadOnlyTests() {
- fTests = new HashSet<String>();
- fTests.add(TEST_REPOSITORY_INFO);
- fTests.add(TEST_TYPES);
- fTests.add(TEST_NAVIGATION);
- fTests.add(TEST_CONTENT_STREAM);
- fTests.add(TEST_QUERY);
- fTests.add(TEST_CHECKEDOUT);
- fTests.add(TEST_CONTENT_CHANGES);
- }
-
- @Override
- protected CmisBinding createBinding() {
- // Add the default Java cookie manager from Java 1.6 to optimize
- // authentication
- // by reusing the common case where a token is stored in a cookie.
- // Note: Enable cookie management requires Java 1.6, uncomment the
- // following two lines to
- // enable cookie management for the tests.
- // java.net.CookieManager cm = new java.net.CookieManager(null,
- // CookiePolicy.ACCEPT_ALL);
- // java.net.CookieHandler.setDefault(cm);
-
- return AtomPubTestBindingFactory.createBinding(getAtomPubURL(), getUsername(), getPassword());
- }
-
- @Override
- protected Set<String> getEnabledTests() {
- return fTests;
- }
-}
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/SimpleReadWriteTests.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/SimpleReadWriteTests.java
deleted file mode 100644
index 64bba26..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/atompub/SimpleReadWriteTests.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.atompub;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.chemistry.opencmis.client.bindings.framework.AbstractSimpleReadWriteTests;
-import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
-
-public class SimpleReadWriteTests extends AbstractSimpleReadWriteTests {
-
- private final Set<String> fTests;
-
- public SimpleReadWriteTests() {
- fTests = new HashSet<String>();
- fTests.add(TEST_CREATE_FOLDER);
- fTests.add(TEST_CREATE_DOCUMENT);
- fTests.add(TEST_SET_AND_DELETE_CONTENT);
- fTests.add(TEST_UPDATE_PROPERTIES);
- fTests.add(TEST_DELETE_TREE);
- fTests.add(TEST_MOVE_OBJECT);
- // fTests.add(TEST_COPY_OBJECT);
- fTests.add(TEST_VERSIONING);
- }
-
- @Override
- protected CmisBinding createBinding() {
- // Add the default Java cookie manager from Java 1.6 to optimize
- // authentication
- // by reusing the common case where a token is stored in a cookie.
- // Note: Enable cookie management requires Java 1.6, uncomment the
- // following two lines to
- // enable cookie management for the tests.
- // java.net.CookieManager cm = new java.net.CookieManager(null,
- // CookiePolicy.ACCEPT_ALL);
- // java.net.CookieHandler.setDefault(cm);
-
- return AtomPubTestBindingFactory.createBinding(getAtomPubURL(), getUsername(), getPassword());
- }
-
- @Override
- protected Set<String> getEnabledTests() {
- return fTests;
- }
-}
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractCmisTestCase.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractCmisTestCase.java
deleted file mode 100644
index a823b87..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractCmisTestCase.java
+++ /dev/null
@@ -1,1206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.framework;
-
-import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNotEmpty;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.data.Ace;
-import org.apache.chemistry.opencmis.commons.data.Acl;
-import org.apache.chemistry.opencmis.commons.data.AllowableActions;
-import org.apache.chemistry.opencmis.commons.data.ContentStream;
-import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
-import org.apache.chemistry.opencmis.commons.data.ObjectData;
-import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
-import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
-import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.data.PropertyData;
-import org.apache.chemistry.opencmis.commons.data.PropertyDateTime;
-import org.apache.chemistry.opencmis.commons.data.PropertyId;
-import org.apache.chemistry.opencmis.commons.data.PropertyString;
-import org.apache.chemistry.opencmis.commons.data.RenditionData;
-import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
-import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
-import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
-import org.apache.chemistry.opencmis.commons.enums.Action;
-import org.apache.chemistry.opencmis.commons.enums.CapabilityAcl;
-import org.apache.chemistry.opencmis.commons.enums.CapabilityChanges;
-import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
-import org.apache.chemistry.opencmis.commons.enums.CapabilityRenditions;
-import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
-import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
-import org.apache.chemistry.opencmis.commons.enums.VersioningState;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
-import org.apache.chemistry.opencmis.commons.impl.IOUtils;
-import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
-import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Base test case for CMIS tests.
- */
-public abstract class AbstractCmisTestCase extends TestCase {
-
- public static final String DEFAULT_TESTS_ENABLED = "true";
- public static final String DEFAULT_USERNAME = "admin";
- public static final String DEFAULT_PASSWORD = "admin";
- public static final String DEFAULT_ATOMPUB_URL = "http://localhost:8080/opencmis/atom11";
- public static final String DEFAULT_WEBSERVICES_URLPREFIX = "http://localhost:8080/opencmis/services/";
- public static final String DEFAULT_DOCTYPE = "cmis:document";
- public static final String DEFAULT_FOLDERTYPE = "cmis:folder";
-
- public static final String PROP_TESTS_ENABLED = "opencmis.test";
- public static final String PROP_USERNAME = "opencmis.test.username";
- public static final String PROP_PASSWORD = "opencmis.test.password";
- public static final String PROP_REPOSITORY = "opencmis.test.repository";
- public static final String PROP_TESTFOLDER = "opencmis.test.testfolder";
- public static final String PROP_DOCTYPE = "opencmis.test.documenttype";
- public static final String PROP_FOLDERTYPE = "opencmis.test.foldertype";
- public static final String PROP_CONFIG_FILE = "opencmis.test.config";
-
- public static final String PROP_ATOMPUB_URL = "opencmis.test.atompub.url";
- public static final String PROP_WEBSERVICES_URLPREFIX = "opencmis.test.webservices.url";
-
- private CmisBinding binding;
- private String fTestRepositoryId;
- private String fTestFolderId;
-
- private static final Logger log = LoggerFactory.getLogger(AbstractCmisTestCase.class);
-
- /**
- * Read configuration file.
- */
- static {
- String configFileName = System.getProperty(PROP_CONFIG_FILE);
- if (configFileName != null) {
-
- try {
- java.util.Properties properties = new java.util.Properties();
- properties.load(new FileInputStream(configFileName));
-
- for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- String value = properties.getProperty(key);
- System.setProperty(key, value);
- }
- } catch (Exception e) {
- System.err.println("Could not load test properties: " + e.toString());
- }
- }
- }
-
- /**
- * Returns the binding object or creates one if does not exist.
- */
- protected CmisBinding getBinding() {
- if (binding == null) {
- log.info("Creating binding...");
- binding = createBinding();
- }
-
- return binding;
- }
-
- /**
- * Creates a binding object.
- */
- protected abstract CmisBinding createBinding();
-
- /**
- * Returns a set of test names that enabled.
- */
- protected abstract Set<String> getEnabledTests();
-
- /**
- * Returns the test repository id.
- */
- protected String getTestRepositoryId() {
- if (fTestRepositoryId != null) {
- return fTestRepositoryId;
- }
-
- fTestRepositoryId = System.getProperty(PROP_REPOSITORY);
- if (fTestRepositoryId != null) {
- log.info("Test repository: " + fTestRepositoryId);
- return fTestRepositoryId;
- }
-
- fTestRepositoryId = getFirstRepositoryId();
- log.info("Test repository: " + fTestRepositoryId);
-
- return fTestRepositoryId;
- }
-
- /**
- * Returns the test root folder id.
- */
- protected String getTestRootFolder() {
- if (fTestFolderId != null) {
- return fTestFolderId;
- }
-
- fTestFolderId = System.getProperty(PROP_TESTFOLDER);
- if (fTestFolderId != null) {
- log.info("Test root folder: " + fTestFolderId);
- return fTestFolderId;
- }
-
- fTestFolderId = getRootFolderId();
- log.info("Test root folder: " + fTestFolderId);
-
- return fTestFolderId;
- }
-
- /**
- * Returns if the test is enabled.
- */
- protected boolean isEnabled(String name) {
- boolean testsEnabled = Boolean.parseBoolean(System.getProperty(PROP_TESTS_ENABLED, DEFAULT_TESTS_ENABLED));
-
- if (testsEnabled && getEnabledTests().contains(name)) {
- return true;
- }
-
- log.info("Skipping test '" + name + "'!");
-
- return false;
- }
-
- /**
- * Returns the test username.
- */
- protected String getUsername() {
- return System.getProperty(PROP_USERNAME, DEFAULT_USERNAME);
- }
-
- /**
- * Returns the test password.
- */
- protected String getPassword() {
- return System.getProperty(PROP_PASSWORD, DEFAULT_PASSWORD);
- }
-
- /**
- * Returns the default document type.
- */
- protected String getDefaultDocumentType() {
- return System.getProperty(PROP_DOCTYPE, DEFAULT_DOCTYPE);
- }
-
- /**
- * Returns the default folder type.
- */
- protected String getDefaultFolderType() {
- return System.getProperty(PROP_FOLDERTYPE, DEFAULT_FOLDERTYPE);
- }
-
- /**
- * Returns the AtomPub URL.
- */
- protected String getAtomPubURL() {
- return System.getProperty(PROP_ATOMPUB_URL, DEFAULT_ATOMPUB_URL);
- }
-
- /**
- * Returns the Web Services URL prefix.
- */
- protected String getWebServicesURL() {
- return System.getProperty(PROP_WEBSERVICES_URLPREFIX, DEFAULT_WEBSERVICES_URLPREFIX);
- }
-
- /**
- * Returns the object factory.
- */
- protected BindingsObjectFactory getObjectFactory() {
- return getBinding().getObjectFactory();
- }
-
- /**
- * Returns the id of the first repository.
- */
- protected String getFirstRepositoryId() {
- List<RepositoryInfo> repositories = getBinding().getRepositoryService().getRepositoryInfos(null);
-
- assertNotNull(repositories);
- assertFalse(repositories.isEmpty());
- assertNotNull(repositories.get(0).getId());
-
- return repositories.get(0).getId();
- }
-
- /**
- * Returns the info object of the test repository.
- */
- protected RepositoryInfo getRepositoryInfo() {
- RepositoryInfo repositoryInfo = getBinding().getRepositoryService().getRepositoryInfo(getTestRepositoryId(),
- null);
-
- assertNotNull(repositoryInfo);
- assertNotNull(repositoryInfo.getId());
- assertEquals(getTestRepositoryId(), repositoryInfo.getId());
-
- return repositoryInfo;
- }
-
- /**
- * Returns the root folder of the test repository.
- */
- protected String getRootFolderId() {
- RepositoryInfo repository = getRepositoryInfo();
-
- assertNotNull(repository.getRootFolderId());
-
- return repository.getRootFolderId();
- }
-
- /**
- * Returns if the test repository supports reading ACLs.
- */
- protected boolean supportsDiscoverACLs() {
- RepositoryInfo repository = getRepositoryInfo();
-
- assertNotNull(repository.getCapabilities());
-
- return repository.getCapabilities().getAclCapability() != CapabilityAcl.NONE;
- }
-
- /**
- * Returns if the test repository supports setting ACLs.
- */
- protected boolean supportsManageACLs() {
- RepositoryInfo repository = getRepositoryInfo();
-
- assertNotNull(repository.getCapabilities());
-
- return repository.getCapabilities().getAclCapability() == CapabilityAcl.MANAGE;
- }
-
- /**
- * Returns if the test repository supports renditions.
- */
- protected boolean supportsRenditions() {
- RepositoryInfo repository = getRepositoryInfo();
-
- assertNotNull(repository.getCapabilities());
-
- if (repository.getCapabilities().getRenditionsCapability() == null) {
- return false;
- }
-
- return repository.getCapabilities().getRenditionsCapability() != CapabilityRenditions.NONE;
- }
-
- /**
- * Returns if the test repository supports descendants.
- */
- protected boolean supportsDescendants() {
- RepositoryInfo repository = getRepositoryInfo();
-
- assertNotNull(repository.getCapabilities());
-
- if (repository.getCapabilities().isGetDescendantsSupported() == null) {
- return false;
- }
-
- return repository.getCapabilities().isGetDescendantsSupported();
- }
-
- /**
- * Returns if the test repository supports descendants.
- */
- protected boolean supportsFolderTree() {
- RepositoryInfo repository = getRepositoryInfo();
-
- assertNotNull(repository.getCapabilities());
-
- if (repository.getCapabilities().isGetFolderTreeSupported() == null) {
- return false;
- }
-
- return repository.getCapabilities().isGetFolderTreeSupported();
- }
-
- /**
- * Returns if the test repository supports content changes.
- */
- protected boolean supportsContentChanges() {
- RepositoryInfo repository = getRepositoryInfo();
-
- assertNotNull(repository.getCapabilities());
-
- if (repository.getCapabilities().getChangesCapability() == null) {
- return false;
- }
-
- return repository.getCapabilities().getChangesCapability() != CapabilityChanges.NONE;
- }
-
- /**
- * Returns if the test repository supports query.
- */
- protected boolean supportsQuery() {
- RepositoryInfo repository = getRepositoryInfo();
-
- assertNotNull(repository.getCapabilities());
-
- if (repository.getCapabilities().getQueryCapability() == null) {
- return false;
- }
-
- return repository.getCapabilities().getQueryCapability() != CapabilityQuery.NONE;
- }
-
- /**
- * Returns if the test repository supports relationships.
- */
- protected boolean supportsRelationships() {
- TypeDefinition relType = null;
-
- try {
- relType = getBinding().getRepositoryService().getTypeDefinition(getTestRepositoryId(), "cmis:relationship",
- null);
- } catch (CmisObjectNotFoundException e) {
- return false;
- }
-
- return relType != null;
- }
-
- /**
- * Returns if the test repository supports policies.
- */
- protected boolean supportsPolicies() {
- TypeDefinition relType = null;
-
- try {
- relType = getBinding().getRepositoryService().getTypeDefinition(getTestRepositoryId(), "cmis:policy", null);
- } catch (CmisObjectNotFoundException e) {
- return false;
- }
-
- return relType != null;
- }
-
- /**
- * Returns the AclPropagation from the ACL capabilities.
- */
- protected AclPropagation getAclPropagation() {
- RepositoryInfo repository = getRepositoryInfo();
-
- assertNotNull(repository.getCapabilities());
-
- if (repository.getAclCapabilities().getAclPropagation() == null) {
- return AclPropagation.REPOSITORYDETERMINED;
- }
-
- return repository.getAclCapabilities().getAclPropagation();
- }
-
- // ---- helpers ----
-
- /**
- * Prints a warning.
- */
- protected void warning(String message) {
- System.out.println("**** " + message);
- }
-
- /**
- * Creates a ContentStreamData object from a byte array.
- */
- protected ContentStream createContentStreamData(String mimeType, byte[] content) {
- assertNotNull(content);
-
- return getObjectFactory().createContentStream("test", BigInteger.valueOf(content.length), mimeType,
- new ByteArrayInputStream(content));
- }
-
- /**
- * Extracts the path from a folder object.
- */
- protected String getPath(ObjectData folderObject) {
- assertNotNull(folderObject);
- assertNotNull(folderObject.getProperties());
- assertNotNull(folderObject.getProperties().getProperties());
- assertTrue(folderObject.getProperties().getProperties().get(PropertyIds.PATH) instanceof PropertyString);
-
- PropertyString pathProperty = (PropertyString) folderObject.getProperties().getProperties()
- .get(PropertyIds.PATH);
-
- assertNotNull(pathProperty.getValues());
- assertEquals(1, pathProperty.getValues().size());
- assertNotNull(pathProperty.getValues().get(0));
-
- return pathProperty.getValues().get(0);
- }
-
- // ---- short cuts ----
-
- /**
- * Retrieves an object.
- */
- protected ObjectData getObject(String objectId, String filter, Boolean includeAllowableActions,
- IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
- Boolean includeACL, ExtensionsData extension) {
- ObjectData object = getBinding().getObjectService()
- .getObject(getTestRepositoryId(), objectId, filter, includeAllowableActions, includeRelationships,
- renditionFilter, includePolicyIds, includeACL, extension);
-
- assertNotNull(object);
-
- return object;
- }
-
- /**
- * Retrieves a full blown object.
- */
- protected ObjectData getObject(String objectId) {
- ObjectData object = getObject(objectId, "*", Boolean.TRUE, IncludeRelationships.BOTH, null, Boolean.TRUE,
- Boolean.TRUE, null);
-
- assertBasicProperties(object.getProperties());
-
- return object;
- }
-
- /**
- * Retrieves an object by path.
- */
- protected ObjectData getObjectByPath(String path, String filter, Boolean includeAllowableActions,
- IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds,
- Boolean includeACL, ExtensionsData extension) {
- ObjectData object = getBinding().getObjectService()
- .getObjectByPath(getTestRepositoryId(), path, filter, includeAllowableActions, includeRelationships,
- renditionFilter, includePolicyIds, includeACL, extension);
-
- assertNotNull(object);
-
- return object;
- }
-
- /**
- * Retrieves a full blown object by path.
- */
- protected ObjectData getObjectByPath(String path) {
- ObjectData object = getObjectByPath(path, "*", Boolean.TRUE, IncludeRelationships.BOTH, null, Boolean.TRUE,
- Boolean.TRUE, null);
-
- assertBasicProperties(object.getProperties());
-
- return object;
- }
-
- /**
- * Returns <code>true</code> if the object with the given id exists,
- * <code>false</code> otherwise.
- */
- protected boolean existsObject(String objectId) {
- try {
- ObjectData object = getObject(objectId, PropertyIds.OBJECT_ID, Boolean.FALSE, IncludeRelationships.NONE,
- null, Boolean.FALSE, Boolean.FALSE, null);
-
- assertNotNull(object);
- assertNotNull(object.getId());
- } catch (CmisObjectNotFoundException e) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Returns the child of a folder.
- */
- protected ObjectInFolderData getChild(String folderId, String objectId) {
- boolean hasMore = true;
-
- while (hasMore) {
- ObjectInFolderList children = getBinding().getNavigationService().getChildren(getTestRepositoryId(),
- folderId, "*", null, Boolean.TRUE, IncludeRelationships.BOTH, null, Boolean.TRUE, null, null, null);
-
- assertNotNull(children);
- assertTrue(isNotEmpty(children.getObjects()));
-
- hasMore = children.hasMoreItems() == null ? false : children.hasMoreItems().booleanValue();
-
- for (ObjectInFolderData object : children.getObjects()) {
- assertNotNull(object);
- assertNotNull(object.getPathSegment());
- assertNotNull(object.getObject());
- assertNotNull(object.getObject().getId());
-
- assertBasicProperties(object.getObject().getProperties());
-
- if (object.getObject().getId().equals(objectId)) {
- return object;
- }
- }
- }
-
- fail("Child not found!");
-
- return null;
- }
-
- /**
- * Gets the version series id of an object.
- */
- protected String getVersionSeriesId(ObjectData object) {
- PropertyData<?> versionSeriesId = object.getProperties().getProperties().get(PropertyIds.VERSION_SERIES_ID);
- assertNotNull(versionSeriesId);
- assertTrue(versionSeriesId instanceof PropertyId);
-
- return ((PropertyId) versionSeriesId).getFirstValue();
- }
-
- /**
- * Gets the version series id of an object.
- */
- protected String getVersionSeriesId(String docId) {
- return getVersionSeriesId(getObject(docId));
- }
-
- /**
- * Creates a folder.
- */
- protected String createFolder(Properties properties, String folderId, List<String> policies, Acl addACEs,
- Acl removeACEs) {
- String objectId = getBinding().getObjectService().createFolder(getTestRepositoryId(), properties, folderId,
- policies, addACEs, removeACEs, null);
- assertNotNull(objectId);
- assertTrue(existsObject(objectId));
-
- ObjectInFolderData folderChild = getChild(folderId, objectId);
-
- // check canGetProperties
- assertAllowableAction(folderChild.getObject().getAllowableActions(), Action.CAN_GET_PROPERTIES, true);
-
- // check name
- PropertyData<?> nameProp = properties.getProperties().get(PropertyIds.NAME);
- if (nameProp != null) {
- assertPropertyValue(folderChild.getObject().getProperties(), PropertyIds.NAME, PropertyString.class,
- nameProp.getFirstValue());
- }
-
- // check object type
- PropertyData<?> typeProp = properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
- assertNotNull(typeProp);
- assertPropertyValue(folderChild.getObject().getProperties(), PropertyIds.OBJECT_TYPE_ID, PropertyId.class,
- typeProp.getFirstValue());
-
- // check parent
- ObjectData parent = getBinding().getNavigationService().getFolderParent(getTestRepositoryId(), objectId, null,
- null);
- assertNotNull(parent);
- assertNotNull(parent.getProperties());
- assertNotNull(parent.getProperties().getProperties());
- assertNotNull(parent.getProperties().getProperties().get(PropertyIds.OBJECT_ID));
- assertEquals(folderId, parent.getProperties().getProperties().get(PropertyIds.OBJECT_ID).getFirstValue());
-
- return objectId;
- }
-
- /**
- * Creates a folder with the default type.
- */
- protected String createDefaultFolder(String folderId, String name) {
- List<PropertyData<?>> propList = new ArrayList<PropertyData<?>>();
- propList.add(getObjectFactory().createPropertyStringData(PropertyIds.NAME, name));
- propList.add(getObjectFactory().createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, getDefaultFolderType()));
-
- Properties properties = getObjectFactory().createPropertiesData(propList);
-
- return createFolder(properties, folderId, null, null, null);
- }
-
- /**
- * Creates a document.
- */
- protected String createDocument(Properties properties, String folderId, ContentStream contentStream,
- VersioningState versioningState, List<String> policies, Acl addACEs, Acl removeACEs) {
- String objectId = getBinding().getObjectService().createDocument(getTestRepositoryId(), properties, folderId,
- contentStream, versioningState, policies, addACEs, removeACEs, null);
- assertNotNull(objectId);
- assertTrue(existsObject(objectId));
-
- if (folderId != null) {
- ObjectInFolderData folderChild = getChild(folderId, objectId);
-
- // check canGetProperties
- assertAllowableAction(folderChild.getObject().getAllowableActions(), Action.CAN_GET_PROPERTIES, true);
-
- // check canGetContentStream
- if (contentStream != null) {
- assertAllowableAction(folderChild.getObject().getAllowableActions(), Action.CAN_GET_CONTENT_STREAM,
- true);
- }
-
- // check name
- PropertyData<?> nameProp = properties.getProperties().get(PropertyIds.NAME);
- if (nameProp != null) {
- assertPropertyValue(folderChild.getObject().getProperties(), PropertyIds.NAME, PropertyString.class,
- nameProp.getFirstValue());
- }
-
- // check object type
- PropertyData<?> typeProp = properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
- assertNotNull(typeProp);
- assertPropertyValue(folderChild.getObject().getProperties(), PropertyIds.OBJECT_TYPE_ID, PropertyId.class,
- typeProp.getFirstValue());
-
- // check parent
- List<ObjectParentData> parents = getBinding().getNavigationService().getObjectParents(
- getTestRepositoryId(), objectId, "*", Boolean.TRUE, IncludeRelationships.BOTH, null, Boolean.TRUE,
- null);
- assertNotNull(parents);
- assertEquals(1, parents.size());
-
- ObjectParentData parent = parents.get(0);
- assertNotNull(parent);
- assertNotNull(parent.getRelativePathSegment());
- assertNotNull(parent.getObject());
- assertNotNull(parent.getObject().getProperties().getProperties());
- assertNotNull(parent.getObject().getProperties().getProperties().get(PropertyIds.OBJECT_ID));
- assertEquals(folderId, parent.getObject().getProperties().getProperties().get(PropertyIds.OBJECT_ID)
- .getFirstValue());
-
- // get document by path (check relative path segment)
- assertNotNull(parent.getObject().getProperties().getProperties().get(PropertyIds.PATH));
- String parentPath = parent.getObject().getProperties().getProperties().get(PropertyIds.PATH)
- .getFirstValue().toString();
-
- ObjectData docByPath = getObjectByPath((parentPath.equals("/") ? "" : parentPath) + "/"
- + folderChild.getPathSegment());
-
- PropertyData<?> idProp = docByPath.getProperties().getProperties().get(PropertyIds.OBJECT_ID);
- assertNotNull(idProp);
- assertEquals(objectId, idProp.getFirstValue());
- } else {
- List<ObjectParentData> parents = getBinding().getNavigationService().getObjectParents(
- getTestRepositoryId(), objectId, null, Boolean.TRUE, IncludeRelationships.BOTH, null, Boolean.TRUE,
- null);
- assertNotNull(parents);
- assertEquals(0, parents.size());
- }
-
- return objectId;
- }
-
- /**
- * Creates a document with the default type.
- */
- protected String createDefaultDocument(String folderId, String name, String contentType, byte[] content) {
- VersioningState vs = (isVersionable(getDefaultDocumentType()) ? VersioningState.MAJOR : VersioningState.NONE);
-
- List<PropertyData<?>> propList = new ArrayList<PropertyData<?>>();
- propList.add(getObjectFactory().createPropertyStringData(PropertyIds.NAME, name));
- propList.add(getObjectFactory().createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, getDefaultDocumentType()));
-
- Properties properties = getObjectFactory().createPropertiesData(propList);
-
- ContentStream contentStream = createContentStreamData(contentType, content);
-
- return createDocument(properties, folderId, contentStream, vs, null, null, null);
- }
-
- /**
- * Creates a document from source.
- */
- protected String createDocumentFromSource(String sourceId, Properties properties, String folderId,
- VersioningState versioningState, List<String> policies, Acl addACEs, Acl removeACEs) {
- String objectId = getBinding().getObjectService().createDocumentFromSource(getTestRepositoryId(), sourceId,
- properties, folderId, versioningState, policies, addACEs, removeACEs, null);
- assertNotNull(objectId);
- assertTrue(existsObject(objectId));
-
- if (folderId != null) {
- ObjectInFolderData folderChild = getChild(folderId, objectId);
-
- // check name
- PropertyData<?> nameProp = properties.getProperties().get(PropertyIds.NAME);
- if (nameProp != null) {
- assertPropertyValue(folderChild.getObject().getProperties(), PropertyIds.NAME, PropertyString.class,
- nameProp.getValues().get(0));
- }
-
- // check parent
- List<ObjectParentData> parents = getBinding().getNavigationService().getObjectParents(
- getTestRepositoryId(), objectId, null, Boolean.TRUE, IncludeRelationships.BOTH, null, Boolean.TRUE,
- null);
- assertNotNull(parents);
- assertEquals(1, parents.size());
-
- ObjectParentData parent = parents.get(0);
- assertNotNull(parent);
- assertNotNull(parent.getRelativePathSegment());
- assertNotNull(parent.getObject());
- assertNotNull(parent.getObject().getProperties().getProperties());
- assertNotNull(parent.getObject().getProperties().getProperties().get(PropertyIds.OBJECT_ID));
- assertEquals(folderId, parent.getObject().getProperties().getProperties().get(PropertyIds.OBJECT_ID)
- .getFirstValue());
- }
-
- return objectId;
- }
-
- /**
- * Deletes an object.
- */
- protected void delete(String objectId, boolean allVersions) {
- getBinding().getObjectService().deleteObject(getTestRepositoryId(), objectId, allVersions, null);
- assertFalse(existsObject(objectId));
- }
-
- /**
- * Deletes a tree.
- */
- protected void deleteTree(String folderId) {
- getBinding().getObjectService().deleteTree(getTestRepositoryId(), folderId, Boolean.TRUE, UnfileObject.DELETE,
- Boolean.TRUE, null);
- assertFalse(existsObject(folderId));
- }
-
- /**
- * Gets a content stream.
- */
- protected ContentStream getContent(String objectId, String streamId) {
- ContentStream contentStream = getBinding().getObjectService().getContentStream(getTestRepositoryId(), objectId,
- streamId, null, null, null);
- assertNotNull(contentStream);
- assertNotNull(contentStream.getMimeType());
- assertNotNull(contentStream.getStream());
-
- return contentStream;
- }
-
- /**
- * Reads the content from a content stream into a byte array.
- */
- protected byte[] readContent(ContentStream contentStream) throws Exception {
- assertNotNull(contentStream);
- assertNotNull(contentStream.getStream());
-
- InputStream stream = contentStream.getStream();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- IOUtils.copy(stream, baos);
-
- return baos.toByteArray();
- }
-
- /**
- * Returns a type definition.
- */
- protected TypeDefinition getTypeDefinition(String typeName) {
- TypeDefinition typeDef = getBinding().getRepositoryService().getTypeDefinition(getTestRepositoryId(), typeName,
- null);
-
- assertNotNull(typeDef);
- assertNotNull(typeDef.getId());
-
- return typeDef;
- }
-
- /**
- * Returns if the type is versionable.
- */
- protected boolean isVersionable(String typeName) {
- TypeDefinition type = getTypeDefinition(typeName);
-
- assertTrue(type instanceof DocumentTypeDefinition);
-
- Boolean isVersionable = ((DocumentTypeDefinition) type).isVersionable();
- assertNotNull(isVersionable);
-
- return isVersionable;
- }
-
- // ---- asserts ----
-
- protected void assertEquals(TypeDefinition expected, TypeDefinition actual, boolean checkPropertyDefintions) {
- if (expected == null && actual == null) {
- return;
- }
-
- if (expected == null) {
- fail("Expected type definition is null!");
- }
-
- if (actual == null) {
- fail("Actual type definition is null!");
- }
-
- assertEquals("TypeDefinition id:", expected.getId(), actual.getId());
- assertEquals("TypeDefinition local name:", expected.getLocalName(), actual.getLocalName());
- assertEquals("TypeDefinition local namespace:", expected.getLocalNamespace(), actual.getLocalNamespace());
- assertEquals("TypeDefinition display name:", expected.getDisplayName(), actual.getDisplayName());
- assertEquals("TypeDefinition description:", expected.getDescription(), actual.getDescription());
- assertEquals("TypeDefinition query name:", expected.getQueryName(), actual.getQueryName());
- assertEquals("TypeDefinition parent id:", expected.getParentTypeId(), actual.getParentTypeId());
- assertEquals("TypeDefinition base id:", expected.getBaseTypeId(), actual.getBaseTypeId());
-
- if (!checkPropertyDefintions) {
- return;
- }
-
- if (expected.getPropertyDefinitions() == null && actual.getPropertyDefinitions() == null) {
- return;
- }
-
- if (expected.getPropertyDefinitions() == null) {
- fail("Expected property definition list is null!");
- }
-
- if (actual.getPropertyDefinitions() == null) {
- fail("Actual property definition list is null!");
- }
-
- assertEquals(expected.getPropertyDefinitions().size(), actual.getPropertyDefinitions().size());
-
- for (PropertyDefinition<?> expectedPropDef : expected.getPropertyDefinitions().values()) {
- PropertyDefinition<?> actualPropDef = actual.getPropertyDefinitions().get(expectedPropDef.getId());
-
- assertEquals(expectedPropDef, actualPropDef);
- }
- }
-
- protected void assertEquals(PropertyDefinition<?> expected, PropertyDefinition<?> actual) {
- if (expected == null && actual == null) {
- return;
- }
-
- if (expected == null) {
- fail("Expected property definition is null!");
- }
-
- if (actual == null) {
- fail("Actual property definition is null!");
- }
-
- assertNotNull(expected.getId());
- assertNotNull(actual.getId());
-
- String id = expected.getId();
-
- assertEquals("PropertyDefinition " + id + " id:", expected.getId(), actual.getId());
- assertEquals("PropertyDefinition " + id + " local name:", expected.getLocalName(), actual.getLocalName());
- assertEquals("PropertyDefinition " + id + " local namespace:", expected.getLocalNamespace(),
- actual.getLocalNamespace());
- assertEquals("PropertyDefinition " + id + " query name:", expected.getQueryName(), actual.getQueryName());
- assertEquals("PropertyDefinition " + id + " display name:", expected.getDisplayName(), actual.getDisplayName());
- assertEquals("PropertyDefinition " + id + " description:", expected.getDescription(), actual.getDescription());
- assertEquals("PropertyDefinition " + id + " property type:", expected.getPropertyType(),
- actual.getPropertyType());
- assertEquals("PropertyDefinition " + id + " cardinality:", expected.getCardinality(), actual.getCardinality());
- assertEquals("PropertyDefinition " + id + " updatability:", expected.getUpdatability(),
- actual.getUpdatability());
- }
-
- protected void assertEquals(Properties expected, Properties actual) {
- if (expected == null && actual == null) {
- return;
- }
-
- if (expected == null) {
- fail("Expected properties data is null!");
- }
-
- if (actual == null) {
- fail("Actual properties data is null!");
- }
-
- if (expected.getProperties() == null && actual.getProperties() == null) {
- return;
- }
-
- if (expected.getProperties() == null || actual.getProperties() == null) {
- fail("Properties are null!");
- }
-
- if (expected.getProperties() == null) {
- fail("Expected properties are null!");
- }
-
- if (actual.getProperties() == null) {
- fail("Actual properties are null!");
- }
-
- assertEquals(expected.getProperties().size(), actual.getProperties().size());
-
- for (String id : expected.getProperties().keySet()) {
- PropertyData<?> expectedProperty = expected.getProperties().get(id);
- assertNotNull(expectedProperty);
- assertEquals(id, expectedProperty.getId());
-
- PropertyData<?> actualProperty = actual.getProperties().get(id);
- assertNotNull(actualProperty);
- assertEquals(id, actualProperty.getId());
-
- assertEquals(expectedProperty, actualProperty);
- }
- }
-
- protected void assertEquals(PropertyData<?> expected, PropertyData<?> actual) {
- if (expected == null && actual == null) {
- return;
- }
-
- if (expected == null || actual == null) {
- fail("Properties data is null!");
- }
-
- String id = expected.getId();
-
- assertEquals("PropertyData " + id + " id:", expected.getId(), actual.getId());
- assertEquals("PropertyData " + id + " display name:", expected.getDisplayName(), actual.getDisplayName());
- assertEquals("PropertyData " + id + " local name:", expected.getLocalName(), actual.getLocalName());
- assertEquals("PropertyData " + id + " query name:", expected.getQueryName(), actual.getQueryName());
-
- assertEquals("PropertyData " + id + " values:", expected.getValues().size(), actual.getValues().size());
-
- for (int i = 0; i < expected.getValues().size(); i++) {
- assertEquals("PropertyData " + id + " value[" + i + "]:", expected.getValues().get(i), actual.getValues()
- .get(i));
- }
- }
-
- protected void assertBasicProperties(Properties properties) {
- assertNotNull(properties);
- assertNotNull(properties.getProperties());
-
- assertProperty(properties.getProperties().get(PropertyIds.OBJECT_ID), PropertyIds.OBJECT_ID, PropertyId.class);
- assertProperty(properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID), PropertyIds.OBJECT_TYPE_ID,
- PropertyId.class);
- assertProperty(properties.getProperties().get(PropertyIds.BASE_TYPE_ID), PropertyIds.BASE_TYPE_ID,
- PropertyId.class);
- assertProperty(properties.getProperties().get(PropertyIds.NAME), PropertyIds.NAME, PropertyString.class);
- assertProperty(properties.getProperties().get(PropertyIds.CREATED_BY), PropertyIds.CREATED_BY,
- PropertyString.class);
- assertProperty(properties.getProperties().get(PropertyIds.CREATION_DATE), PropertyIds.CREATION_DATE,
- PropertyDateTime.class);
- assertProperty(properties.getProperties().get(PropertyIds.LAST_MODIFIED_BY), PropertyIds.LAST_MODIFIED_BY,
- PropertyString.class);
- assertProperty(properties.getProperties().get(PropertyIds.LAST_MODIFICATION_DATE),
- PropertyIds.LAST_MODIFICATION_DATE, PropertyDateTime.class);
- }
-
- protected void assertProperty(PropertyData<?> property, String id, Class<?> clazz) {
- assertNotNull(property);
- assertNotNull(property.getId());
- assertEquals("PropertyData " + id + " id:", id, property.getId());
- assertTrue(clazz.isAssignableFrom(property.getClass()));
- assertNotNull(property.getValues());
- assertFalse(property.getValues().isEmpty());
- }
-
- protected void assertPropertyValue(PropertyData<?> property, String id, Class<?> clazz, Object... values) {
- assertProperty(property, id, clazz);
-
- assertEquals("Property " + id + " values:", values.length, property.getValues().size());
-
- int i = 0;
- for (Object value : property.getValues()) {
- assertEquals("Property " + id + " value[" + i + "]:", values[i], value);
- i++;
- }
- }
-
- protected void assertPropertyValue(Properties properties, String id, Class<?> clazz, Object... values) {
- assertNotNull(properties);
- assertNotNull(properties.getProperties());
-
- PropertyData<?> property = properties.getProperties().get(id);
- assertNotNull(property);
-
- assertPropertyValue(property, id, clazz, values);
- }
-
- protected void assertEquals(AllowableActions expected, AllowableActions actual) {
- if (expected == null && actual == null) {
- return;
- }
-
- if (expected == null) {
- fail("Expected allowable action data is null!");
- }
-
- if (actual == null) {
- fail("Actual allowable action data is null!");
- }
-
- assertNotNull(expected.getAllowableActions());
- assertNotNull(actual.getAllowableActions());
-
- assertEquals("Allowable action size:", expected.getAllowableActions().size(), actual.getAllowableActions()
- .size());
-
- for (Action action : expected.getAllowableActions()) {
- boolean expectedBoolean = expected.getAllowableActions().contains(action);
- boolean actualBoolean = actual.getAllowableActions().contains(action);
-
- assertEquals("AllowableAction " + action + ":", expectedBoolean, actualBoolean);
- }
- }
-
- protected void assertAllowableAction(AllowableActions allowableActions, Action action, boolean expected) {
- assertNotNull(allowableActions);
- assertNotNull(allowableActions.getAllowableActions());
- assertNotNull(action);
-
- assertEquals("Allowable action \"" + action + "\":", expected,
- allowableActions.getAllowableActions().contains(action));
- }
-
- protected void assertEquals(Acl expected, Acl actual) {
- if (expected == null && actual == null) {
- return;
- }
-
- if (expected == null) {
- fail("Expected ACL data is null!");
- }
-
- if (actual == null) {
- fail("Actual ACL data is null!");
- }
-
- if (expected.getAces() == null && actual.getAces() == null) {
- return;
- }
-
- if (expected.getAces() == null) {
- fail("Expected ACE data is null!");
- }
-
- if (actual.getAces() == null) {
- fail("Actual ACE data is null!");
- }
-
- // assertEquals(expected.isExact(), actual.isExact());
- assertEquals(expected.getAces().size(), actual.getAces().size());
-
- for (int i = 0; i < expected.getAces().size(); i++) {
- assertEquals(expected.getAces().get(i), actual.getAces().get(i));
- }
- }
-
- protected void assertEquals(Ace expected, Ace actual) {
- if (expected == null && actual == null) {
- return;
- }
-
- if (expected == null) {
- fail("Expected ACE data is null!");
- }
-
- if (actual == null) {
- fail("Actual ACE data is null!");
- }
-
- assertNotNull(expected.getPrincipal());
- assertNotNull(expected.getPrincipal().getId());
- assertNotNull(actual.getPrincipal());
- assertNotNull(actual.getPrincipal().getId());
- assertEquals("ACE Principal:", expected.getPrincipal().getId(), actual.getPrincipal().getId());
-
- assertEqualLists(expected.getPermissions(), actual.getPermissions());
- }
-
- protected void assertEquals(RenditionData expected, RenditionData actual) {
- if (expected == null && actual == null) {
- return;
- }
-
- if (expected == null) {
- fail("Expected rendition is null!");
- }
-
- if (actual == null) {
- fail("Actual rendition is null!");
- }
-
- assertEquals("Rendition kind:", expected.getKind(), actual.getKind());
- assertEquals("Rendition MIME type:", expected.getMimeType(), actual.getMimeType());
- assertEquals("Rendition length:", expected.getBigLength(), actual.getBigLength());
- assertEquals("Rendition stream id:", expected.getStreamId(), actual.getStreamId());
- assertEquals("Rendition title:", expected.getTitle(), actual.getTitle());
- assertEquals("Rendition height:", expected.getBigHeight(), actual.getBigHeight());
- assertEquals("Rendition width:", expected.getBigWidth(), actual.getBigWidth());
- assertEquals("Rendition document id:", expected.getRenditionDocumentId(), actual.getRenditionDocumentId());
- }
-
- protected void assertContent(byte[] expected, byte[] actual) {
- assertNotNull(expected);
- assertNotNull(actual);
-
- assertEquals("Content size:", expected.length, actual.length);
-
- for (int i = 0; i < expected.length; i++) {
- assertEquals("Content not equal.", expected[i], actual[i]);
- }
- }
-
- protected void assertMimeType(String expected, String actual) {
- assertNotNull(expected);
- assertNotNull(actual);
-
- int paramIdx = actual.indexOf(';');
- if (paramIdx != -1) {
- actual = actual.substring(0, paramIdx);
- }
-
- assertEquals(expected, actual);
- }
-
- protected void assertEqualLists(List<?> expected, List<?> actual) {
- if (expected == null && actual == null) {
- return;
- }
-
- if (expected == null) {
- fail("Expected list is null!");
- }
-
- if (actual == null) {
- fail("Actual list is null!");
- }
-
- assertEquals("List size:", expected.size(), actual.size());
-
- for (int i = 0; i < expected.size(); i++) {
- assertEquals("List element " + i + ":", expected.get(i), actual.get(i));
- }
- }
-}
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java
deleted file mode 100644
index 1236199..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.framework;
-
-import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNotEmpty;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.data.Acl;
-import org.apache.chemistry.opencmis.commons.data.AllowableActions;
-import org.apache.chemistry.opencmis.commons.data.ContentStream;
-import org.apache.chemistry.opencmis.commons.data.ObjectData;
-import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
-import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
-import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
-import org.apache.chemistry.opencmis.commons.data.ObjectList;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.data.RenditionData;
-import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
-import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.FolderTypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PolicyTypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
-import org.apache.chemistry.opencmis.commons.enums.Action;
-import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
-import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
-import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
-
-/**
- * Simple read-only tests.
- */
-public abstract class AbstractSimpleReadOnlyTests extends AbstractCmisTestCase {
-
- public static final String TEST_REPOSITORY_INFO = "repositoryInfo";
- public static final String TEST_TYPES = "types";
- public static final String TEST_CONTENT_STREAM = "contentStream";
- public static final String TEST_NAVIGATION = "navigation";
- public static final String TEST_QUERY = "query";
- public static final String TEST_CHECKEDOUT = "checkedout";
- public static final String TEST_CONTENT_CHANGES = "contentChanges";
-
- /**
- * Tests repository info.
- */
- public void testRepositoryInfo() {
- if (!isEnabled(TEST_REPOSITORY_INFO)) {
- return;
- }
-
- RepositoryInfo repInfo = getRepositoryInfo();
-
- Tools.print(repInfo);
-
- assertNotNull(repInfo.getId());
- assertNotNull(repInfo.getCmisVersionSupported());
- assertNotNull(repInfo.getRootFolderId());
- assertNotNull(repInfo.getCapabilities());
- }
-
- /**
- * Some type related tests.
- */
- public void testTypes() {
- if (!isEnabled(TEST_TYPES)) {
- return;
- }
-
- String repId = getTestRepositoryId();
-
- // get standard type
- TypeDefinition docType = getTypeDefinition("cmis:document");
- assertTrue(docType instanceof DocumentTypeDefinition);
- assertEquals("cmis:document", docType.getId());
- assertEquals(BaseTypeId.CMIS_DOCUMENT, docType.getBaseTypeId());
-
- TypeDefinition folderType = getTypeDefinition("cmis:folder");
- assertTrue(folderType instanceof FolderTypeDefinition);
- assertEquals("cmis:folder", folderType.getId());
- assertEquals(BaseTypeId.CMIS_FOLDER, folderType.getBaseTypeId());
-
- try {
- TypeDefinition relationshipType = getTypeDefinition("cmis:relationship");
- assertTrue(relationshipType instanceof RelationshipTypeDefinition);
- assertEquals("cmis:relationship", relationshipType.getId());
- assertEquals(BaseTypeId.CMIS_RELATIONSHIP, relationshipType.getBaseTypeId());
- } catch (Exception e) {
- warning("Relationships type: " + e);
- }
-
- try {
- TypeDefinition policyType = getTypeDefinition("cmis:policy");
- assertTrue(policyType instanceof PolicyTypeDefinition);
- assertEquals("cmis:policy", policyType.getId());
- assertEquals(BaseTypeId.CMIS_POLICY, policyType.getBaseTypeId());
- } catch (Exception e) {
- warning("Policy type: " + e);
- }
-
- // getTypeChildren
- TypeDefinitionList types = getBinding().getRepositoryService().getTypeChildren(repId, null, Boolean.TRUE, null,
- null, null);
- assertNotNull(types);
- assertNotNull(types.hasMoreItems());
- assertNotNull(types.getList());
- assertFalse(types.getList().isEmpty());
- assertTrue(types.getList().size() >= 2);
- assertTrue(types.getList().size() <= 4);
-
- getBinding().clearAllCaches();
-
- for (TypeDefinition type : types.getList()) {
- TypeDefinition type2 = getTypeDefinition(type.getId());
- assertEquals(type, type2, true);
- }
-
- // getTypeDescendants
- List<TypeDefinitionContainer> typesContainers = getBinding().getRepositoryService().getTypeDescendants(repId,
- null, null, Boolean.TRUE, null);
- assertNotNull(typesContainers);
- assertFalse(typesContainers.isEmpty());
-
- for (TypeDefinitionContainer typeContainer : typesContainers) {
- assertNotNull(typeContainer.getTypeDefinition());
- assertNotNull(typeContainer.getTypeDefinition().getId());
- TypeDefinition type2 = getTypeDefinition(typeContainer.getTypeDefinition().getId());
- assertEquals(typeContainer.getTypeDefinition(), type2, true);
- }
-
- Tools.printTypes("Type Descendants", typesContainers);
-
- getBinding().clearAllCaches();
-
- assertTypeContainers(repId, typesContainers);
- }
-
- private void assertTypeContainers(String repId, List<TypeDefinitionContainer> typesContainers) {
- if (typesContainers == null) {
- return;
- }
-
- for (TypeDefinitionContainer container : typesContainers) {
- assertNotNull(container.getTypeDefinition());
-
- TypeDefinition type = container.getTypeDefinition();
- TypeDefinition type2 = getTypeDefinition(type.getId());
-
- assertEquals(type, type2, true);
-
- assertTypeContainers(repId, container.getChildren());
- }
- }
-
- /**
- * Navigation smoke test.
- */
- public void testNavigation() {
- if (!isEnabled(TEST_NAVIGATION)) {
- return;
- }
-
- String repId = getTestRepositoryId();
- String rootFolder = getRootFolderId();
- String testRootFolder = getTestRootFolder();
-
- ObjectData rootFolderObject = getObject(rootFolder);
- String rootPath = getPath(rootFolderObject);
- assertEquals("Root path is not \"/\"!", "/", rootPath);
- assertAllowableAction(rootFolderObject.getAllowableActions(), Action.CAN_GET_OBJECT_PARENTS, false);
-
- ObjectData folderObject = getObject(testRootFolder);
- String path = getPath(folderObject);
-
- ObjectInFolderList children = getBinding().getNavigationService().getChildren(repId, testRootFolder, "*", null,
- Boolean.TRUE, IncludeRelationships.BOTH, null, Boolean.TRUE, null, null, null);
- assertNotNull(children);
- assertNotNull(children.hasMoreItems());
-
- if (supportsDescendants()) {
- List<ObjectInFolderContainer> desc = getBinding().getNavigationService().getDescendants(repId,
- testRootFolder, BigInteger.valueOf(2), "*", Boolean.TRUE, IncludeRelationships.BOTH, null,
- Boolean.TRUE, null);
- assertNotNull(desc);
- Tools.print("Descendants", desc);
-
- assertContainer(desc, 5);
- } else {
- warning("Descendants not supported!");
- }
-
- if (supportsFolderTree()) {
- List<ObjectInFolderContainer> tree = getBinding().getNavigationService().getFolderTree(repId,
- testRootFolder, BigInteger.valueOf(2), "*", Boolean.TRUE, IncludeRelationships.BOTH, null,
- Boolean.TRUE, null);
- assertNotNull(tree);
- Tools.print("Tree", tree);
-
- assertContainer(tree, 5);
- } else {
- warning("Folder Tree not supported!");
- }
-
- for (ObjectInFolderData object : children.getObjects()) {
- assertNotNull(object.getObject());
- assertNotNull(object.getObject().getId());
- assertNotNull(object.getObject().getBaseTypeId());
-
- ObjectData object2 = getObject(object.getObject().getId());
- assertNotNull(object2.getId());
- assertEquals(object.getObject().getId(), object2.getId());
- assertEquals(object.getObject().getProperties(), object2.getProperties());
-
- ObjectData object3 = getObjectByPath((path.equals("/") ? "/" : path + "/") + object.getPathSegment());
- assertNotNull(object3);
- assertNotNull(object3.getId());
- assertEquals(object.getObject().getId(), object3.getId());
- assertEquals(object.getObject().getProperties(), object3.getProperties());
-
- checkObject(object.getObject().getId());
-
- if (object.getObject().getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
- ObjectInFolderList children2 = getBinding().getNavigationService().getChildren(repId,
- object.getObject().getId(), null, null, Boolean.TRUE, IncludeRelationships.BOTH, null,
- Boolean.TRUE, null, null, null);
- assertNotNull(children2);
- } else if (object.getObject().getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
- checkObjectVersions(object.getObject().getId());
- }
- }
- }
-
- private void assertContainer(List<ObjectInFolderContainer> containers, int maxDepth) {
- if (containers == null) {
- return;
- }
-
- if (maxDepth < 1) {
- return;
- }
-
- for (ObjectInFolderContainer container : containers) {
- assertNotNull(container);
- assertNotNull(container.getObject());
- assertNotNull(container.getObject().getObject());
- assertNotNull(container.getObject().getObject().getId());
- assertNotNull(container.getObject().getPathSegment());
-
- ObjectData object = getObject(container.getObject().getObject().getId());
-
- assertEquals(container.getObject().getObject().getProperties(), object.getProperties());
- assertEquals(container.getObject().getObject().getAllowableActions(), object.getAllowableActions());
-
- assertContainer(container.getChildren(), maxDepth - 1);
- }
- }
-
- /**
- * Content stream smoke test.
- */
- public void testContentStream() throws Exception {
- if (!isEnabled(TEST_CONTENT_STREAM)) {
- return;
- }
-
- String repId = getTestRepositoryId();
- String rootFolder = getTestRootFolder();
-
- ObjectInFolderList children = getBinding().getNavigationService().getChildren(repId, rootFolder, null, null,
- Boolean.FALSE, IncludeRelationships.BOTH, null, Boolean.FALSE, null, null, null);
- assertNotNull(children);
- assertNotNull(children.getObjects());
-
- for (ObjectInFolderData object : children.getObjects()) {
- assertNotNull(object.getObject().getId());
- assertNotNull(object.getObject().getBaseTypeId());
-
- if (object.getObject().getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
- ContentStream contentStream = getContent(object.getObject().getId(), null);
- readContent(contentStream);
-
- return;
- }
- }
-
- fail("No document in test folder!");
- }
-
- /**
- * Query smoke test.
- */
- public void testQuery() {
- if (!isEnabled(TEST_QUERY)) {
- return;
- }
-
- if (supportsQuery()) {
- String repId = getTestRepositoryId();
-
- ObjectList rs = getBinding().getDiscoveryService().query(repId, "SELECT * FROM cmis:document", null, null,
- null, null, null, null, null);
- assertNotNull(rs);
-
- if (rs.getObjects() != null) {
- for (ObjectData object : rs.getObjects()) {
- assertNotNull(object);
- assertNotNull(object.getProperties());
- assertNotNull(object.getProperties().getProperties());
- }
- }
-
- } else {
- warning("Query not supported!");
- }
- }
-
- /**
- * Checked out smoke test.
- */
- public void testCheckedout() {
- if (!isEnabled(TEST_CHECKEDOUT)) {
- return;
- }
-
- String repId = getTestRepositoryId();
-
- ObjectList co = getBinding().getNavigationService().getCheckedOutDocs(repId, getTestRootFolder(), null, null,
- Boolean.TRUE, IncludeRelationships.BOTH, null, BigInteger.valueOf(100), null, null);
- assertNotNull(co);
-
- if (co.getObjects() != null) {
- assertTrue(co.getObjects().size() <= 100);
-
- for (ObjectData object : co.getObjects()) {
- assertNotNull(object);
- assertNotNull(object.getId());
- assertEquals(BaseTypeId.CMIS_DOCUMENT, object.getBaseTypeId());
- }
- }
- }
-
- /**
- * Content changes smoke test.
- */
- public void testContentChanges() {
- if (!isEnabled(TEST_CONTENT_CHANGES)) {
- return;
- }
-
- if (supportsContentChanges()) {
- String repId = getTestRepositoryId();
-
- ObjectList cc = getBinding().getDiscoveryService().getContentChanges(repId, null, Boolean.TRUE, "*",
- Boolean.TRUE, Boolean.TRUE, BigInteger.valueOf(100), null);
- assertNotNull(cc);
-
- if (cc.getObjects() != null) {
- assertTrue(cc.getObjects().size() <= 100);
-
- for (ObjectData object : cc.getObjects()) {
- assertNotNull(object);
- assertNotNull(object.getId());
- assertNotNull(object.getChangeEventInfo());
- assertNotNull(object.getChangeEventInfo().getChangeType());
- assertNotNull(object.getChangeEventInfo().getChangeTime());
- }
- }
- } else {
- warning("Content changes not supported!");
- }
- }
-
- /**
- * Tests some of the read-only methods of the Object Service.
- */
- private void checkObject(String objectId) {
- System.out.println("Checking object " + objectId + "...");
-
- ObjectData object = getObject(objectId);
-
- // check properties
- Properties properties = getBinding().getObjectService().getProperties(getTestRepositoryId(), objectId, "*",
- null);
-
- assertEquals(object.getProperties(), properties);
-
- // check allowable actions
- AllowableActions allowableActions = getBinding().getObjectService().getAllowableActions(getTestRepositoryId(),
- objectId, null);
-
- assertEquals(object.getAllowableActions(), allowableActions);
-
- // check ACLS
- if (supportsDiscoverACLs()) {
- Acl acl = getBinding().getAclService().getAcl(getTestRepositoryId(), objectId, Boolean.FALSE, null);
-
- assertEquals(object.getAcl(), acl);
- } else {
- warning("ACLs not supported!");
- }
-
- // check policies
- if (supportsPolicies()) {
- List<ObjectData> policies = getBinding().getPolicyService().getAppliedPolicies(getTestRepositoryId(),
- objectId, null, null);
-
- if (policies == null) {
- assertNull(object.getPolicyIds().getPolicyIds());
- } else {
- assertNotNull(object.getPolicyIds().getPolicyIds());
-
- List<String> policyIds = new ArrayList<String>();
-
- for (ObjectData policy : policies) {
- assertNotNull(policy);
- assertNotNull(policy.getId());
-
- policyIds.add(policy.getId());
- }
-
- assertEqualLists(object.getPolicyIds().getPolicyIds(), policyIds);
- }
- } else {
- warning("Policies not supported!");
- }
-
- // check renditions
- if (supportsRenditions()) {
- List<RenditionData> renditions = getBinding().getObjectService().getRenditions(getTestRepositoryId(),
- objectId, null, null, null, null);
-
- assertEqualLists(object.getRenditions(), renditions);
- } else {
- warning("Renditions not supported!");
- }
-
- // check relationships
- if (supportsRelationships()) {
- ObjectList relationships = getBinding().getRelationshipService().getObjectRelationships(
- getTestRepositoryId(), objectId, Boolean.TRUE, RelationshipDirection.EITHER, null, "*",
- Boolean.TRUE, null, null, null);
- assertNotNull(relationships);
-
- if ((object.getRelationships() != null) && (relationships.getObjects() != null)) {
- assertEquals(object.getRelationships().size(), relationships.getObjects().size());
- for (ObjectData rel1 : relationships.getObjects()) {
- assertBasicProperties(rel1.getProperties());
- boolean found = false;
-
- for (ObjectData rel2 : object.getRelationships()) {
- if (rel2.getId().equals(rel1.getId())) {
- found = true;
- assertEquals(rel2.getProperties(), rel1.getProperties());
- break;
- }
- }
-
- assertTrue(found);
- }
- }
- } else {
- warning("Relationships not supported!");
- }
- }
-
- /**
- * Tests some of the read-only methods of the Versioning Service.
- */
- private void checkObjectVersions(String objectId) {
- System.out.println("Checking versions of object " + objectId + "...");
-
- String versionSeriesId = getVersionSeriesId(objectId);
- assertNotNull(versionSeriesId);
-
- // check latest version
- ObjectData latestVersionObject = getBinding().getVersioningService().getObjectOfLatestVersion(
- getTestRepositoryId(), objectId, versionSeriesId, Boolean.FALSE, "*", Boolean.TRUE,
- IncludeRelationships.BOTH, null, Boolean.TRUE, Boolean.TRUE, null);
- assertNotNull(latestVersionObject);
-
- Properties latestVersionProperties = getBinding().getVersioningService().getPropertiesOfLatestVersion(
- getTestRepositoryId(), objectId, versionSeriesId, Boolean.FALSE, "*", null);
- assertNotNull(latestVersionProperties);
-
- assertEquals(latestVersionObject.getProperties(), latestVersionProperties);
-
- String typeName = (String) latestVersionObject.getProperties().getProperties().get(PropertyIds.BASE_TYPE_ID)
- .getFirstValue();
- if (isVersionable(typeName)) {
- List<ObjectData> allVersions = getBinding().getVersioningService().getAllVersions(getTestRepositoryId(),
- objectId, versionSeriesId, "*", Boolean.FALSE, null);
- assertNotNull(allVersions);
- assertTrue(isNotEmpty(allVersions));
-
- boolean foundObject = false;
- boolean foundLatestObject = false;
- for (ObjectData object : allVersions) {
- assertNotNull(object);
- assertNotNull(object.getId());
-
- if (objectId.equals(object.getId())) {
- foundObject = true;
- }
-
- if (latestVersionObject.getId().equals(object.getId())) {
- foundLatestObject = true;
- assertEquals(latestVersionObject.getProperties(), object.getProperties());
- }
- }
-
- if (!foundObject) {
- fail("Object " + objectId + " not found in it's version history!");
- }
-
- if (!foundLatestObject) {
- fail("Object " + latestVersionObject.getId() + " not found in it's version history!");
- }
- }
- }
-}
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java
deleted file mode 100644
index 557ded3..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.framework;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.data.Ace;
-import org.apache.chemistry.opencmis.commons.data.Acl;
-import org.apache.chemistry.opencmis.commons.data.ContentStream;
-import org.apache.chemistry.opencmis.commons.data.ObjectData;
-import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.data.PropertyData;
-import org.apache.chemistry.opencmis.commons.enums.CapabilityContentStreamUpdates;
-import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
-import org.apache.chemistry.opencmis.commons.enums.VersioningState;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
-import org.apache.chemistry.opencmis.commons.spi.Holder;
-
-/**
- * Simple read-write test.
- */
-public abstract class AbstractSimpleReadWriteTests extends AbstractCmisTestCase {
-
- public static final String TEST_CREATE_FOLDER = "createFolder";
- public static final String TEST_CREATE_DOCUMENT = "createDocument";
- public static final String TEST_CREATE_FROM_SOURCE = "createDocumentFromSource";
- public static final String TEST_SET_AND_DELETE_CONTENT = "setAndDeleteContent";
- public static final String TEST_UPDATE_PROPERTIES = "updateProperties";
- public static final String TEST_DELETE_TREE = "deleteTree";
- public static final String TEST_MOVE_OBJECT = "moveObject";
- public static final String TEST_COPY_OBJECT = "copyObject";
- public static final String TEST_VERSIONING = "versioning";
-
- private static final byte[] CONTENT = "My document test content!".getBytes();
- private static final byte[] CONTENT2 = "Another test content!".getBytes();
- private static final String CONTENT_TYPE = "text/plain";
-
- /**
- * Tests folder creation.
- */
- public void testCreateFolder() {
- if (!isEnabled(TEST_CREATE_FOLDER)) {
- return;
- }
-
- // create folder
- List<PropertyData<?>> propList = new ArrayList<PropertyData<?>>();
- propList.add(getObjectFactory().createPropertyStringData(PropertyIds.NAME, "testfolder"));
- propList.add(getObjectFactory().createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, getDefaultFolderType()));
-
- Properties properties = getObjectFactory().createPropertiesData(propList);
-
- String folderId = createFolder(properties, getTestRootFolder(), null, null, null);
-
- // delete folder
- delete(folderId, true);
- }
-
- /**
- * Tests document creation.
- */
- public void testCreateDocument() throws Exception {
- if (!isEnabled(TEST_CREATE_DOCUMENT)) {
- return;
- }
-
- VersioningState vs = isVersionable(getDefaultDocumentType()) ? VersioningState.MAJOR : VersioningState.NONE;
-
- // create document
- List<PropertyData<?>> propList = new ArrayList<PropertyData<?>>();
- propList.add(getObjectFactory().createPropertyStringData(PropertyIds.NAME, "testdoc.txt"));
- propList.add(getObjectFactory().createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, getDefaultDocumentType()));
-
- Properties properties = getObjectFactory().createPropertiesData(propList);
-
- ContentStream contentStream = createContentStreamData(CONTENT_TYPE, CONTENT);
-
- String docId = createDocument(properties, getTestRootFolder(), contentStream, vs, null, null, null);
-
- // read and assert content
- ContentStream contentStream2 = getContent(docId, null);
- assertMimeType(CONTENT_TYPE, contentStream2.getMimeType());
- if (contentStream2.getBigLength() != null) {
- assertEquals(CONTENT.length, contentStream2.getBigLength().intValue());
- }
-
- byte[] content = readContent(contentStream2);
- assertContent(CONTENT, content);
-
- // apply an ACL
- if (supportsManageACLs()) {
- Ace ace = getObjectFactory()
- .createAccessControlEntry(getUsername(), Collections.singletonList("cmis:read"));
- Acl acl = getObjectFactory().createAccessControlList(Collections.singletonList(ace));
-
- Acl newAcl = getBinding().getAclService().applyAcl(getTestRepositoryId(), docId, acl, null,
- getAclPropagation(), null);
- assertNotNull(newAcl);
-
- Acl readAcl = getBinding().getAclService().getAcl(getTestRepositoryId(), docId, Boolean.FALSE, null);
- assertNotNull(readAcl);
-
- assertEquals(newAcl, readAcl);
- } else {
- warning("ACLs management not supported!");
- }
-
- // delete document
- delete(docId, true);
- }
-
- /**
- * Tests document creation from source.
- */
- public void testCreateDocumentFromSource() throws Exception {
- if (!isEnabled(TEST_CREATE_FROM_SOURCE)) {
- return;
- }
-
- VersioningState vs = isVersionable(getDefaultDocumentType()) ? VersioningState.MAJOR : VersioningState.NONE;
-
- String docId = createDefaultDocument(getTestRootFolder(), "testdoc.org.txt", CONTENT_TYPE, CONTENT);
-
- // create a copy
- List<PropertyData<?>> propList2 = new ArrayList<PropertyData<?>>();
- propList2.add(getObjectFactory().createPropertyStringData(PropertyIds.NAME, "testdoc.copy.txt"));
-
- Properties properties2 = getObjectFactory().createPropertiesData(propList2);
-
- String docId2 = createDocumentFromSource(docId, properties2, getTestRootFolder(), vs, null, null, null);
-
- // get objects
- getObject(docId);
- getObject(docId2);
-
- // read and assert content
- ContentStream contentStream2 = getContent(docId, null);
- ContentStream contentStream3 = getContent(docId2, null);
-
- assertEquals(contentStream2.getMimeType(), contentStream3.getMimeType());
- assertEquals(contentStream2.getBigLength(), contentStream3.getBigLength());
-
- byte[] content2 = readContent(contentStream2);
- byte[] content3 = readContent(contentStream3);
- assertContent(content2, content3);
-
- // delete documents
- delete(docId, true);
- delete(docId2, true);
- }
-
- /**
- * Tests setting and deleting content stream.
- */
- public void testSetAndDeleteContent() throws Exception {
- if (!isEnabled(TEST_SET_AND_DELETE_CONTENT)) {
- return;
- }
-
- boolean requiresCheckOut = getRepositoryInfo().getCapabilities().getContentStreamUpdatesCapability() == CapabilityContentStreamUpdates.PWCONLY;
-
- boolean isVersionable = isVersionable(getDefaultDocumentType());
-
- String docId = createDefaultDocument(getTestRootFolder(), "testcontent.txt", CONTENT_TYPE, CONTENT);
-
- // if a check out is required, do it
- Holder<String> docIdHolder = new Holder<String>(docId);
- if (requiresCheckOut) {
- if (isVersionable) {
- getBinding().getVersioningService().checkOut(getTestRepositoryId(), docIdHolder, null, null);
- } else {
- warning("Default document type is not versionable!");
- delete(docId, true);
- return;
- }
- }
-
- String docIdWorkingCopy = docIdHolder.getValue();
-
- // delete content
- try {
- getBinding().getObjectService().deleteContentStream(getTestRepositoryId(), docIdHolder, null, null);
- } catch (CmisNotSupportedException e) {
- warning("deleteContentStream not supported!");
- }
-
- // set content
- ContentStream contentStream2 = createContentStreamData(CONTENT_TYPE, CONTENT2);
-
- docIdHolder = new Holder<String>(docIdWorkingCopy);
- getBinding().getObjectService().setContentStream(getTestRepositoryId(), docIdHolder, true, null,
- contentStream2, null);
-
- // read and assert content
- String newVersionDocId = (docIdHolder.getValue() == null ? docIdWorkingCopy : docIdHolder.getValue());
- ContentStream contentStream3 = getContent(newVersionDocId, null);
- assertMimeType(CONTENT_TYPE, contentStream3.getMimeType());
- if (contentStream3.getBigLength() != null) {
- assertEquals(CONTENT2.length, contentStream3.getBigLength().intValue());
- }
-
- byte[] content = readContent(contentStream3);
- assertContent(CONTENT2, content);
-
- // if it has been checked out, cancel that
- if (requiresCheckOut) {
- getBinding().getVersioningService().cancelCheckOut(getTestRepositoryId(), docIdWorkingCopy, null);
- }
-
- // delete document
- delete(docId, true);
- }
-
- /**
- * Tests property updates.
- */
- public void testUpdateProperties() {
- if (!isEnabled(TEST_UPDATE_PROPERTIES)) {
- return;
- }
-
- String name1 = "updateTest1.txt";
- String name2 = "updateTest2.txt";
-
- // create document
- String docId = createDefaultDocument(getTestRootFolder(), name1, CONTENT_TYPE, CONTENT);
-
- // update
- List<PropertyData<?>> updatePropList = new ArrayList<PropertyData<?>>();
- updatePropList.add(getObjectFactory().createPropertyStringData(PropertyIds.NAME, name2));
-
- Properties updateProperties = getObjectFactory().createPropertiesData(updatePropList);
-
- Holder<String> docIdHolder = new Holder<String>(docId);
- getBinding().getObjectService().updateProperties(getTestRepositoryId(), docIdHolder, null, updateProperties,
- null);
-
- // get new id and check name property
- docId = docIdHolder.getValue();
-
- ObjectData updatedObject = getObject(docId);
- String updatedName = (String) updatedObject.getProperties().getProperties().get(PropertyIds.NAME)
- .getFirstValue();
- assertNotNull(updatedName);
- assertEquals(name2, updatedName);
-
- // delete document
- delete(docId, true);
- }
-
- /**
- * Tests delete tree.
- */
- public void testDeleteTree() {
- if (!isEnabled(TEST_DELETE_TREE)) {
- return;
- }
-
- // create a folder tree
- String folder1 = createDefaultFolder(getTestRootFolder(), "folder1");
- String folder11 = createDefaultFolder(folder1, "folder11");
- String folder12 = createDefaultFolder(folder1, "folder12");
- String folder121 = createDefaultFolder(folder12, "folder121");
- String folder122 = createDefaultFolder(folder12, "folder122");
-
- // create a few documents
- String doc111 = createDefaultDocument(folder11, "doc111.txt", CONTENT_TYPE, CONTENT);
- String doc1221 = createDefaultDocument(folder122, "doc1221.txt", CONTENT_TYPE, CONTENT2);
-
- // delete the tree
- getBinding().getObjectService().deleteTree(getTestRepositoryId(), folder1, Boolean.TRUE, UnfileObject.DELETE,
- Boolean.TRUE, null);
-
- assertFalse(existsObject(folder1));
- assertFalse(existsObject(folder11));
- assertFalse(existsObject(folder12));
- assertFalse(existsObject(folder121));
- assertFalse(existsObject(folder122));
- assertFalse(existsObject(doc111));
- assertFalse(existsObject(doc1221));
- }
-
- /**
- * Tests move object.
- */
- public void testMoveObject() {
- if (!isEnabled(TEST_MOVE_OBJECT)) {
- return;
- }
-
- // create folders
- String folder1 = createDefaultFolder(getTestRootFolder(), "folder1");
- String folder2 = createDefaultFolder(getTestRootFolder(), "folder2");
-
- // create document
- String docId = createDefaultDocument(folder1, "testdoc.txt", CONTENT_TYPE, CONTENT);
-
- // move it
- Holder<String> docIdHolder = new Holder<String>(docId);
- getBinding().getObjectService().moveObject(getTestRepositoryId(), docIdHolder, folder2, folder1, null);
- assertNotNull(docIdHolder.getValue());
-
- assertTrue(existsObject(docIdHolder.getValue()));
- getChild(folder2, docIdHolder.getValue());
-
- deleteTree(folder1);
- deleteTree(folder2);
- }
-
- /**
- * Tests copy object.
- */
- public void testCopyObject() {
- if (!isEnabled(TEST_COPY_OBJECT)) {
- return;
- }
-
- // create folders
- String folder1 = createDefaultFolder(getTestRootFolder(), "folder1");
- String folder2 = createDefaultFolder(getTestRootFolder(), "folder2");
-
- // create document
- String docId = createDefaultDocument(folder1, "testdoc.txt", CONTENT_TYPE, CONTENT);
-
- // copy it with new properties
- List<PropertyData<?>> updatePropList = new ArrayList<PropertyData<?>>();
- updatePropList.add(getObjectFactory().createPropertyStringData(PropertyIds.NAME, "newdocname"));
- Properties updateProperties = getObjectFactory().createPropertiesData(updatePropList);
-
- String copyId = getBinding().getObjectService().createDocumentFromSource(getTestRepositoryId(), docId,
- updateProperties, folder2, null, null, null, null, null);
- assertNotNull(copyId);
-
- assertTrue(existsObject(copyId));
- ObjectInFolderData copy = getChild(folder2, copyId);
- String updatedName = (String) copy.getObject().getProperties().getProperties().get(PropertyIds.NAME)
- .getFirstValue();
- assertEquals("newdocname", updatedName);
-
- deleteTree(folder1);
- deleteTree(folder2);
- }
-
- /**
- * Test check-in/check-out.
- */
- public void testVersioning() {
- if (!isEnabled(TEST_VERSIONING)) {
- return;
- }
-
- if (!isVersionable(getDefaultDocumentType())) {
- warning("Default document type is not versionable!");
- return;
- }
-
- // create document
- String docId = createDefaultDocument(getTestRootFolder(), "versionTest.txt", CONTENT_TYPE, CONTENT);
-
- // there must be only one version in the version series
- List<ObjectData> allVersions = getBinding().getVersioningService().getAllVersions(getTestRepositoryId(), docId,
- getVersionSeriesId(docId), "*", Boolean.FALSE, null);
- assertNotNull(allVersions);
- assertEquals(1, allVersions.size());
-
- assertEquals(docId, allVersions.get(0).getId());
-
- // check out
- Holder<String> versionIdHolder = new Holder<String>(docId);
- getBinding().getVersioningService().checkOut(getTestRepositoryId(), versionIdHolder, null, null);
- String versionId = versionIdHolder.getValue();
-
- // object must be marked as checked out
- assertTrue(isCheckedOut(docId));
-
- // cancel check out
- getBinding().getVersioningService().cancelCheckOut(getTestRepositoryId(), versionId, null);
-
- // object must NOT be marked as checked out
- assertFalse(isCheckedOut(docId));
-
- // check out again
- versionIdHolder.setValue(docId);
- getBinding().getVersioningService().checkOut(getTestRepositoryId(), versionIdHolder, null, null);
- versionId = versionIdHolder.getValue();
-
- // object must be marked as checked out
- assertTrue(isCheckedOut(docId));
-
- versionIdHolder.setValue(versionId);
- getBinding().getVersioningService().checkIn(getTestRepositoryId(), versionIdHolder, Boolean.TRUE, null, null,
- "Test Version 2", null, null, null, null);
- docId = versionIdHolder.getValue();
-
- // object must NOT be marked as checked out
- assertFalse(isCheckedOut(docId));
-
- // there must be exactly two versions in the version series
- allVersions = getBinding().getVersioningService().getAllVersions(getTestRepositoryId(), docId,
- getVersionSeriesId(docId), "*", Boolean.FALSE, null);
- assertNotNull(allVersions);
- assertEquals(2, allVersions.size());
-
- // delete document
- delete(docId, true);
- }
-
- private boolean isCheckedOut(String docId) {
- ObjectData object = getObject(docId);
- PropertyData<?> isCheckedOut = object.getProperties().getProperties()
- .get(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
- assertNotNull(isCheckedOut);
- assertTrue(isCheckedOut.getFirstValue() instanceof Boolean);
-
- return ((Boolean) isCheckedOut.getFirstValue()).booleanValue();
- }
-}
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java
deleted file mode 100644
index 177c490..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.framework;
-
-import java.util.List;
-
-import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
-
-public class Tools {
-
- private Tools() {
- }
-
- public static void print(RepositoryInfo repositoryInfo) {
- if (repositoryInfo == null) {
- return;
- }
-
- System.out.println("-------------");
- System.out.println("Id: " + repositoryInfo.getId());
- System.out.println("Name: " + repositoryInfo.getName());
- System.out.println("CMIS Version: " + repositoryInfo.getCmisVersionSupported());
- System.out.println("Product: " + repositoryInfo.getVendorName() + " / "
- + repositoryInfo.getProductName() + " " + repositoryInfo.getProductVersion());
- System.out.println("Root Folder: " + repositoryInfo.getRootFolderId());
- System.out.println("Capabilities: " + repositoryInfo.getCapabilities());
- System.out.println("ACL Capabilities: " + repositoryInfo.getAclCapabilities());
- System.out.println("-------------");
- }
-
- public static void printTypes(String title, List<TypeDefinitionContainer> typeContainerList) {
- System.out.println("-------------");
- System.out.println(title);
- System.out.println("-------------");
-
- printTypes(typeContainerList, 0);
- }
-
- private static void printTypes(List<TypeDefinitionContainer> typeContainerList, int level) {
- if (typeContainerList == null) {
- return;
- }
-
- for (TypeDefinitionContainer container : typeContainerList) {
- for (int i = 0; i < level; i++) {
- System.out.print(" ");
- }
-
- container.getTypeDefinition().getId();
- System.out.println(container.getTypeDefinition().getId());
-
- printTypes(container.getChildren(), level + 1);
- }
- }
-
- public static void print(String title, List<ObjectInFolderContainer> containerList) {
- System.out.println("-------------");
- System.out.println(title);
- System.out.println("-------------");
-
- print(containerList, 0);
- }
-
- private static void print(List<ObjectInFolderContainer> containerList, int level) {
- if (containerList == null) {
- return;
- }
-
- for (ObjectInFolderContainer container : containerList) {
- for (int i = 0; i < level; i++) {
- System.out.print(" ");
- }
-
- Properties properties = container.getObject().getObject().getProperties();
- System.out.println(properties.getProperties().get(PropertyIds.NAME).getFirstValue() + " ("
- + properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID).getFirstValue() + ")");
-
- print(container.getChildren(), level + 1);
- }
- }
-}
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java
deleted file mode 100644
index 45560e9..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.webservices;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.chemistry.opencmis.client.bindings.framework.AbstractSimpleReadOnlyTests;
-import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
-
-public class SimpleReadOnlyTests extends AbstractSimpleReadOnlyTests {
-
- private final Set<String> fTests;
-
- public SimpleReadOnlyTests() {
- fTests = new HashSet<String>();
- fTests.add(TEST_REPOSITORY_INFO);
- fTests.add(TEST_TYPES);
- fTests.add(TEST_NAVIGATION);
- fTests.add(TEST_CONTENT_STREAM);
- fTests.add(TEST_QUERY);
- fTests.add(TEST_CHECKEDOUT);
- fTests.add(TEST_CONTENT_CHANGES);
- }
-
- @Override
- protected CmisBinding createBinding() {
- return WebServicesTestBindingFactory.createBinding(getWebServicesURL(), getUsername(), getPassword());
- }
-
- @Override
- protected Set<String> getEnabledTests() {
- return fTests;
- }
-}
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java
deleted file mode 100644
index 3dd7e3a..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.webservices;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.chemistry.opencmis.client.bindings.framework.AbstractSimpleReadWriteTests;
-import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
-
-public class SimpleReadWriteTests extends AbstractSimpleReadWriteTests {
-
- private final Set<String> fTests;
-
- public SimpleReadWriteTests() {
- fTests = new HashSet<String>();
- fTests.add(TEST_CREATE_FOLDER);
- fTests.add(TEST_CREATE_DOCUMENT);
- fTests.add(TEST_CREATE_FROM_SOURCE);
- fTests.add(TEST_SET_AND_DELETE_CONTENT);
- fTests.add(TEST_UPDATE_PROPERTIES);
- fTests.add(TEST_DELETE_TREE);
- fTests.add(TEST_MOVE_OBJECT);
- fTests.add(TEST_COPY_OBJECT);
- fTests.add(TEST_VERSIONING);
- }
-
- @Override
- protected CmisBinding createBinding() {
- return WebServicesTestBindingFactory.createBinding(getWebServicesURL(), getUsername(), getPassword());
- }
-
- @Override
- protected Set<String> getEnabledTests() {
- return fTests;
- }
-}
diff --git a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java b/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java
deleted file mode 100644
index a04308d..0000000
--- a/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.chemistry.opencmis.client.bindings.webservices;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
-import org.apache.chemistry.opencmis.commons.SessionParameter;
-import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
-
-/**
- * Web Services Binding Factory.
- */
-public class WebServicesTestBindingFactory {
-
- private WebServicesTestBindingFactory() {
- }
-
- public static CmisBinding createBinding(String url, String username, String password) {
- boolean isPrefix = true;
-
- url = url.trim();
- String urlLower = url.toLowerCase(Locale.ENGLISH);
-
- if (urlLower.endsWith("?wsdl")) {
- isPrefix = false;
- } else if (urlLower.endsWith(".wsdl")) {
- isPrefix = false;
- } else if (urlLower.endsWith(".xml")) {
- isPrefix = false;
- } else if (urlLower.endsWith(".aspx")) {
- isPrefix = false;
- } else if (urlLower.endsWith("/wsdl")) {
- isPrefix = false;
- }
-
- return createBinding(url, isPrefix, username, password);
- }
-
- public static CmisBinding createBinding(String url, boolean isPrefix, String username, String password) {
- // gather parameters
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put(SessionParameter.USER, username);
- parameters.put(SessionParameter.PASSWORD, password);
-
- if (!isPrefix) {
- parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url);
- parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url);
- parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url);
- parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url);
- parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url);
- parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url);
- parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url);
- parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url);
- parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url);
- } else {
- parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url + "RepositoryService?wsdl");
- parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url + "NavigationService?wsdl");
- parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url + "ObjectService?wsdl");
- parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url + "VersioningService?wsdl");
- parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url + "DiscoveryService?wsdl");
- parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url + "RelationshipService?wsdl");
- parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url + "MultiFilingService?wsdl");
- parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url + "PolicyService?wsdl");
- parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url + "ACLService?wsdl");
- }
-
- // get factory and create provider
- CmisBindingFactory factory = CmisBindingFactory.newInstance();
- CmisBinding binding = factory.createCmisWebServicesBinding(parameters);
-
- return binding;
- }
-}
diff --git a/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/pom.xml b/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/pom.xml
index 6c86f95..1f6ec9a 100644
--- a/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/pom.xml
+++ b/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/pom.xml
@@ -45,8 +45,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>woodstox-core-asl</artifactId>
+ <groupId>com.fasterxml.woodstox</groupId>
+ <artifactId>woodstox-core</artifactId>
<version>${woodstox.version}</version>
<exclusions>
<exclusion> <!-- included in Java 6 and above -->
diff --git a/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java b/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
index 98a8289..12f5ef2 100644
--- a/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
+++ b/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
@@ -24,6 +24,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.GregorianCalendar;
+import java.util.regex.Pattern;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -60,8 +61,8 @@
try {
// Woodstox is the only supported and tested StAX implementation
- WstxInputFactory wstxFactory = (WstxInputFactory) ClassLoaderUtil.loadClass(
- "com.ctc.wstx.stax.WstxInputFactory").getDeclaredConstructor().newInstance();
+ WstxInputFactory wstxFactory = (WstxInputFactory) ClassLoaderUtil
+ .loadClass("com.ctc.wstx.stax.WstxInputFactory").getDeclaredConstructor().newInstance();
wstxFactory.configureForSpeed();
factory = wstxFactory;
@@ -92,8 +93,8 @@
try {
// Woodstox is the only supported and tested StAX implementation
- WstxOutputFactory wstxFactory = (WstxOutputFactory) ClassLoaderUtil.loadClass(
- "com.ctc.wstx.stax.WstxOutputFactory").getDeclaredConstructor().newInstance();
+ WstxOutputFactory wstxFactory = (WstxOutputFactory) ClassLoaderUtil
+ .loadClass("com.ctc.wstx.stax.WstxOutputFactory").getDeclaredConstructor().newInstance();
wstxFactory.configureForSpeed();
wstxFactory.setProperty(WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER,
new InvalidCharHandler.ReplacingHandler(' '));
@@ -400,8 +401,8 @@
/**
* Parses a stream and returns the DOM document.
*/
- public static Document parseDomDocument(InputStream stream) throws ParserConfigurationException, SAXException,
- IOException {
+ public static Document parseDomDocument(InputStream stream)
+ throws ParserConfigurationException, SAXException, IOException {
return newDocumentBuilder().parse(stream);
}
@@ -429,4 +430,15 @@
return transformer;
}
+
+ // --------------------------
+ // ---- Misc ---
+ // --------------------------
+
+ private static Pattern CLEAN_PATTERN = Pattern
+ .compile("[^\\\\x09\\\\x0A\\\\x0D\\\\x20-\\\\xD7FF\\\\xE000-\\\\xFFFD\\\\x10000-\\\\x10FFFF]");
+
+ public static String cleanXmlString(String s) {
+ return CLEAN_PATTERN.matcher(s).replaceAll(" ");
+ }
}
diff --git a/chemistry-opencmis-server/chemistry-opencmis-server-archetype/src/main/resources/archetype-resources/pom.xml b/chemistry-opencmis-server/chemistry-opencmis-server-archetype/src/main/resources/archetype-resources/pom.xml
index b4754aa..35dfe89 100644
--- a/chemistry-opencmis-server/chemistry-opencmis-server-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/chemistry-opencmis-server/chemistry-opencmis-server-archetype/src/main/resources/archetype-resources/pom.xml
@@ -53,9 +53,9 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
- <!-- requires at least Java 7 -->
- <target>1.7</target>
- <source>1.7</source>
+ <!-- requires at least Java 8 -->
+ <target>1.8</target>
+ <source>1.8</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
diff --git a/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java b/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
index 80cc1c3..28d7d6d 100644
--- a/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
+++ b/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
@@ -241,7 +241,7 @@
if (ex != null) {
if (ex instanceof CmisBaseException) {
fault.setCode(((CmisBaseException) ex).getCode());
- fault.setMessage(ex.getMessage());
+ fault.setMessage(XMLUtils.cleanXmlString(ex.getMessage()));
if (ex instanceof CmisConstraintException) {
fault.setType(EnumServiceException.CONSTRAINT);
@@ -285,11 +285,11 @@
root.appendChild(entry);
Element key = doc.createElement("key");
- key.appendChild(doc.createTextNode(e.getKey()));
+ key.appendChild(doc.createTextNode(XMLUtils.cleanXmlString(e.getKey())));
entry.appendChild(key);
Element value = doc.createElement("value");
- value.appendChild(doc.createTextNode(e.getValue()));
+ value.appendChild(doc.createTextNode(XMLUtils.cleanXmlString(e.getValue())));
entry.appendChild(value);
}
diff --git a/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java b/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java
index ca59107..a83d92e 100644
--- a/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java
+++ b/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java
@@ -70,7 +70,7 @@
Element node = doc.createElementNS("http://chemistry.apache.org/opencmis/exception", "stacktrace");
doc.appendChild(node);
- node.appendChild(doc.createTextNode(st));
+ node.appendChild(doc.createTextNode(XMLUtils.cleanXmlString(st)));
return node;
}
diff --git a/chemistry-opencmis-server/chemistry-opencmis-server-extension-archetype/src/main/resources/archetype-resources/pom.xml b/chemistry-opencmis-server/chemistry-opencmis-server-extension-archetype/src/main/resources/archetype-resources/pom.xml
index bd5fd89..ebd4463 100644
--- a/chemistry-opencmis-server/chemistry-opencmis-server-extension-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/chemistry-opencmis-server/chemistry-opencmis-server-extension-archetype/src/main/resources/archetype-resources/pom.xml
@@ -19,10 +19,11 @@
<plugin>
<inherited>true</inherited>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.0</version>
+ <version>3.7.0</version>
<configuration>
- <target>1.6</target>
- <source>1.6</source>
+ <!-- requires at least Java 8 -->
+ <target>1.8</target>
+ <source>1.8</source>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
diff --git a/chemistry-opencmis-test/chemistry-opencmis-test-fit/pom.xml b/chemistry-opencmis-test/chemistry-opencmis-test-fit/pom.xml
index fd7511d..b611931 100644
--- a/chemistry-opencmis-test/chemistry-opencmis-test-fit/pom.xml
+++ b/chemistry-opencmis-test/chemistry-opencmis-test-fit/pom.xml
@@ -92,7 +92,7 @@
<reuseForks>true</reuseForks>
<forkCount>1</forkCount>
<forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
- <argLine>-ea:org.apache.chemistry --add-modules java.xml.ws</argLine>
+ <argLine>-ea:org.apache.chemistry</argLine>
<systemPropertyVariables>
<systemProperty>
<name>org.apache.chemistry.opencmis.session.repository.id</name>
diff --git a/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AbstractTckIT.java b/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AbstractTckIT.java
index bfc1e41..9f2ae06 100644
--- a/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AbstractTckIT.java
+++ b/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/tck/AbstractTckIT.java
@@ -267,7 +267,7 @@
assertTrue("The test '" + test.getName() + "' returned a failure: " + result.getMessage(),
result.getStatus() != CmisTestResultStatus.FAILURE);
assertTrue(
- "The test '" + test.getName() + "' returned at an unexcepted exception: "
+ "The test '" + test.getName() + "' returned at an unexpected exception: "
+ result.getMessage(),
result.getStatus() != CmisTestResultStatus.UNEXPECTED_EXCEPTION);
}
diff --git a/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/InvalidQueryTest.java b/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/InvalidQueryTest.java
index 729a34f..191b1d9 100644
--- a/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/InvalidQueryTest.java
+++ b/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/InvalidQueryTest.java
@@ -82,8 +82,8 @@
} catch (CmisInvalidArgumentException e) {
// excepted
} catch (Exception ex) {
- addResult(createResult(FAILURE, "This query is invalid and an unexcepted exception (" + ex.toString()
- + ") has been thrown: " + stmt, ex, false));
+ addResult(createResult(FAILURE, "This query is invalid and an unexpected exception (" + ex.toString()
+ + ") has been thrown: \"" + stmt + "\"", ex, false));
}
}
}
diff --git a/pom.xml b/pom.xml
index 16d79d4..c6f443c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -124,8 +124,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compile.source>1.7</maven.compile.source>
- <maven.compile.target>1.7</maven.compile.target>
+ <maven.compile.source>1.8</maven.compile.source>
+ <maven.compile.target>1.8</maven.compile.target>
<docs.start.url>https://chemistry.apache.org/java/opencmis.html</docs.start.url>
<docs.download.directory>${project.build.directory}/downloaded-site</docs.download.directory>
<!--
@@ -148,17 +148,17 @@
<site.staging.url>${site.staging.protocol}://${site.staging.host}${site.staging.folder}</site.staging.url>
<parentBasedir>${project.basedir}</parentBasedir>
- <woodstox.version>4.4.1</woodstox.version>
- <osgi.version>5.0.0</osgi.version>
+ <woodstox.version>5.0.3</woodstox.version>
+ <osgi.version>6.0.0</osgi.version>
<felix.plugin.version>3.3.0</felix.plugin.version>
<junit.version>4.12</junit.version>
- <surefire.version>2.19.1</surefire.version>
- <failsafe.version>2.19.1</failsafe.version>
+ <surefire.version>2.20.1</surefire.version>
+ <failsafe.version>2.20.1</failsafe.version>
<jacoco.version>0.7.5.201505241946</jacoco.version>
<slf4j.version>1.7.25</slf4j.version>
- <log4j.version>2.6.1</log4j.version>
+ <log4j.version>2.9.0</log4j.version>
<apacheclient.version>4.2.6</apacheclient.version>
- <cxf.version>3.1.14</cxf.version>
+ <cxf.version>3.2.1</cxf.version>
<okhttp.version>3.8.1</okhttp.version>
</properties>