You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2010/04/15 12:33:51 UTC
svn commit: r934361 [8/9] - in /incubator/chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/
chemistry-opencmis-client/chemistry-opencmis-client-bindings/s...
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,560 @@
+/*
+ * 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.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.api.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.api.FolderTypeDefinition;
+import org.apache.chemistry.opencmis.commons.api.PolicyTypeDefinition;
+import org.apache.chemistry.opencmis.commons.api.RelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.commons.api.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.api.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.api.TypeDefinitionList;
+import org.apache.chemistry.opencmis.commons.enums.BaseObjectTypeIds;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
+import org.apache.chemistry.opencmis.commons.provider.AccessControlList;
+import org.apache.chemistry.opencmis.commons.provider.AllowableActionsData;
+import org.apache.chemistry.opencmis.commons.provider.ContentStreamData;
+import org.apache.chemistry.opencmis.commons.provider.ObjectData;
+import org.apache.chemistry.opencmis.commons.provider.ObjectInFolderContainer;
+import org.apache.chemistry.opencmis.commons.provider.ObjectInFolderData;
+import org.apache.chemistry.opencmis.commons.provider.ObjectInFolderList;
+import org.apache.chemistry.opencmis.commons.provider.ObjectList;
+import org.apache.chemistry.opencmis.commons.provider.PropertiesData;
+import org.apache.chemistry.opencmis.commons.provider.RenditionData;
+import org.apache.chemistry.opencmis.commons.provider.RepositoryInfoData;
+
+/**
+ * Simple read-only tests.
+ *
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+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() throws Exception {
+ if (!isEnabled(TEST_REPOSITORY_INFO)) {
+ return;
+ }
+
+ RepositoryInfoData repInfo = getRepositoryInfo();
+
+ Tools.print(repInfo);
+
+ assertNotNull(repInfo.getRepositoryId());
+ assertNotNull(repInfo.getCmisVersionSupported());
+ assertNotNull(repInfo.getRootFolderId());
+ assertNotNull(repInfo.getRepositoryCapabilities());
+ }
+
+ /**
+ * Some type related tests.
+ */
+ public void testTypes() throws Exception {
+ 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(BaseObjectTypeIds.CMIS_DOCUMENT, docType.getBaseId());
+
+ TypeDefinition folderType = getTypeDefinition("cmis:folder");
+ assertTrue(folderType instanceof FolderTypeDefinition);
+ assertEquals("cmis:folder", folderType.getId());
+ assertEquals(BaseObjectTypeIds.CMIS_FOLDER, folderType.getBaseId());
+
+ try {
+ TypeDefinition relationshipType = getTypeDefinition("cmis:relationship");
+ assertTrue(relationshipType instanceof RelationshipTypeDefinition);
+ assertEquals("cmis:relationship", relationshipType.getId());
+ assertEquals(BaseObjectTypeIds.CMIS_RELATIONSHIP, relationshipType.getBaseId());
+ }
+ catch (Exception e) {
+ warning("Relationships type: " + e);
+ }
+
+ try {
+ TypeDefinition policyType = getTypeDefinition("cmis:policy");
+ assertTrue(policyType instanceof PolicyTypeDefinition);
+ assertEquals("cmis:policy", policyType.getId());
+ assertEquals(BaseObjectTypeIds.CMIS_POLICY, policyType.getBaseId());
+ }
+ 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() throws Exception {
+ 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(),
+ AllowableActionsData.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(5), "*", 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(5), "*", 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() == BaseObjectTypeIds.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() == BaseObjectTypeIds.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() == BaseObjectTypeIds.CMIS_DOCUMENT) {
+ ContentStreamData contentStream = getContent(object.getObject().getId(), null);
+ readContent(contentStream);
+
+ return;
+ }
+ }
+
+ fail("No document in test folder!");
+ }
+
+ /**
+ * Query smoke test.
+ */
+ public void testQuery() throws Exception {
+ 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() throws Exception {
+ 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(BaseObjectTypeIds.CMIS_DOCUMENT, object.getBaseTypeId());
+ }
+ }
+ }
+
+ /**
+ * Content changes smoke test.
+ */
+ public void testContentChanges() throws Exception {
+ 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) throws Exception {
+ System.out.println("Checking object " + objectId + "...");
+
+ ObjectData object = getObject(objectId);
+
+ // check properties
+ PropertiesData properties = getBinding().getObjectService().getProperties(
+ getTestRepositoryId(), objectId, "*", null);
+
+ assertEquals(object.getProperties(), properties);
+
+ // check allowable actions
+ AllowableActionsData allowableActions = getBinding().getObjectService().getAllowableActions(
+ getTestRepositoryId(), objectId, null);
+
+ assertEquals(object.getAllowableActions(), allowableActions);
+
+ // check ACLS
+ if (supportsDiscoverACLs()) {
+ AccessControlList 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) throws Exception {
+ System.out.println("Checking versions of object " + objectId + "...");
+
+ String versionSeriesId = getVersionSeriesId(objectId);
+ assertNotNull(versionSeriesId);
+
+ // check latest version
+ ObjectData latestVersionObject = getBinding().getVersioningService().getObjectOfLatestVersion(
+ getTestRepositoryId(), versionSeriesId, Boolean.FALSE, "*", Boolean.TRUE,
+ IncludeRelationships.BOTH, null, Boolean.TRUE, Boolean.TRUE, null);
+ assertNotNull(latestVersionObject);
+
+ PropertiesData latestVersionProperties = getBinding().getVersioningService()
+ .getPropertiesOfLatestVersion(getTestRepositoryId(), versionSeriesId, Boolean.FALSE, "*",
+ null);
+ assertNotNull(latestVersionProperties);
+
+ assertEquals(latestVersionObject.getProperties(), latestVersionProperties);
+
+ String typeName = (String) latestVersionObject.getProperties().getProperties().get(
+ PropertyIds.CMIS_BASE_TYPE_ID).getFirstValue();
+ if (isVersionable(typeName)) {
+ List<ObjectData> allVersions = getBinding().getVersioningService().getAllVersions(
+ getTestRepositoryId(), objectId, versionSeriesId, "*", Boolean.FALSE, null);
+ assertNotNull(allVersions);
+ assertTrue(allVersions.size() > 0);
+
+ 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!");
+ }
+ }
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,425 @@
+/*
+ * 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.enums.CapabilityContentStreamUpdates;
+import org.apache.chemistry.opencmis.commons.enums.UnfileObjects;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.chemistry.opencmis.commons.provider.AccessControlEntry;
+import org.apache.chemistry.opencmis.commons.provider.AccessControlList;
+import org.apache.chemistry.opencmis.commons.provider.ContentStreamData;
+import org.apache.chemistry.opencmis.commons.provider.Holder;
+import org.apache.chemistry.opencmis.commons.provider.ObjectData;
+import org.apache.chemistry.opencmis.commons.provider.PropertiesData;
+import org.apache.chemistry.opencmis.commons.provider.PropertyData;
+
+/**
+ * Simple read-write test.
+ *
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+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_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() throws Exception {
+ if (!isEnabled(TEST_CREATE_FOLDER)) {
+ return;
+ }
+
+ // create folder
+ List<PropertyData<?>> propList = new ArrayList<PropertyData<?>>();
+ propList.add(getObjectFactory().createPropertyStringData(PropertyIds.CMIS_NAME, "testfolder"));
+ propList.add(getObjectFactory().createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID,
+ getDefaultFolderType()));
+
+ PropertiesData 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.CMIS_NAME, "testdoc.txt"));
+ propList.add(getObjectFactory().createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID,
+ getDefaultDocumentType()));
+
+ PropertiesData properties = getObjectFactory().createPropertiesData(propList);
+
+ ContentStreamData contentStream = createContentStreamData(CONTENT_TYPE, CONTENT);
+
+ String docId = createDocument(properties, getTestRootFolder(), contentStream, vs, null, null,
+ null);
+
+ // read and assert content
+ ContentStreamData contentStream2 = getContent(docId, null);
+ assertMimeType(CONTENT_TYPE, contentStream2.getMimeType());
+ if (contentStream2.getLength() != null) {
+ assertEquals(CONTENT.length, contentStream2.getLength().intValue());
+ }
+
+ byte[] content = readContent(contentStream2);
+ assertContent(CONTENT, content);
+
+ // apply an ACL
+ if (supportsManageACLs()) {
+ AccessControlEntry ace = getObjectFactory().createAccessControlEntry(getUsername(),
+ Collections.singletonList("cmis:read"));
+ AccessControlList acl = getObjectFactory().createAccessControlList(
+ Collections.singletonList(ace));
+
+ AccessControlList newAcl = getBinding().getAclService().applyAcl(getTestRepositoryId(),
+ docId, acl, null, getAclPropagation(), null);
+ assertNotNull(newAcl);
+
+ AccessControlList 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.CMIS_NAME,
+ "testdoc.copy.txt"));
+
+ PropertiesData properties2 = getObjectFactory().createPropertiesData(propList2);
+
+ String docId2 = createDocumentFromSource(docId, properties2, getTestRootFolder(), vs, null,
+ null, null);
+
+ // get objects
+ getObject(docId);
+ getObject(docId2);
+
+ // read and assert content
+ ContentStreamData contentStream2 = getContent(docId, null);
+ ContentStreamData contentStream3 = getContent(docId2, null);
+
+ assertEquals(contentStream2.getMimeType(), contentStream3.getMimeType());
+ assertEquals(contentStream2.getLength(), contentStream3.getLength());
+
+ byte[] content2 = readContent(contentStream2);
+ byte[] content3 = readContent(contentStream3);
+ assertContent(content2, content3);
+
+ // delete documents
+ delete(docId, true);
+ delete(docId2, true);
+ }
+
+ /**
+ * Tests property updates.
+ */
+ public void testSetAndDeleteContent() throws Exception {
+ if (!isEnabled(TEST_SET_AND_DELETE_CONTENT)) {
+ return;
+ }
+
+ boolean requiresCheckOut = getRepositoryInfo().getRepositoryCapabilities()
+ .getCapabilityContentStreamUpdatability() == CapabilityContentStreamUpdates.PWCONLY;
+
+ boolean isVersionable = isVersionable(getDefaultDocumentType());
+
+ String docId = createDefaultDocument(getTestRootFolder(), "testcontent.txt", CONTENT_TYPE,
+ CONTENT);
+
+ // if a check out is required, do it
+ if (requiresCheckOut) {
+ if (isVersionable) {
+ getBinding().getVersioningService().checkOut(getTestRepositoryId(),
+ new Holder<String>(docId), null, null);
+ }
+ else {
+ warning("Default document type is not versionable!");
+ delete(docId, true);
+ return;
+ }
+ }
+
+ // delete content
+ Holder<String> docIdHolder = new Holder<String>(docId);
+ try {
+ getBinding().getObjectService().deleteContentStream(getTestRepositoryId(), docIdHolder,
+ null, null);
+ }
+ catch (CmisNotSupportedException e) {
+ warning("deleteContentStream not supported!");
+ }
+
+ // set content
+ ContentStreamData contentStream2 = createContentStreamData(CONTENT_TYPE, CONTENT2);
+
+ docIdHolder = new Holder<String>(docId);
+ getBinding().getObjectService().setContentStream(getTestRepositoryId(), docIdHolder, true,
+ null, contentStream2, null);
+
+ // read and assert content
+ if (docIdHolder.getValue() != null) {
+ docId = docIdHolder.getValue();
+ }
+ ContentStreamData contentStream3 = getContent(docId, null);
+ assertMimeType(CONTENT_TYPE, contentStream3.getMimeType());
+ if (contentStream3.getLength() != null) {
+ assertEquals(CONTENT2.length, contentStream3.getLength().intValue());
+ }
+
+ byte[] content = readContent(contentStream3);
+ assertContent(CONTENT2, content);
+
+ // if it has been checked out, cancel that
+ if (requiresCheckOut) {
+ getBinding().getVersioningService().cancelCheckOut(getTestRepositoryId(), docId, null);
+ }
+
+ // delete document
+ delete(docId, true);
+ }
+
+ /**
+ * Tests property updates.
+ */
+ public void testUpdateProperties() throws Exception {
+ 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.CMIS_NAME, name2));
+
+ PropertiesData 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.CMIS_NAME).getFirstValue();
+ assertNotNull(updatedName);
+ assertEquals(name2, updatedName);
+
+ // delete document
+ delete(docId, true);
+ }
+
+ /**
+ * Tests delete tree.
+ */
+ public void testDeleteTree() throws Exception {
+ 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,
+ UnfileObjects.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() throws Exception {
+ 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);
+ }
+
+ /**
+ * Test check-in/check-out.
+ */
+ public void testVersioning() throws Exception {
+ 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.CMIS_IS_VERSION_SERIES_CHECKED_OUT);
+ assertNotNull(isCheckedOut);
+ assertTrue(isCheckedOut.getFirstValue() instanceof Boolean);
+
+ return ((Boolean) isCheckedOut.getFirstValue()).booleanValue();
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,104 @@
+/*
+ * 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.api.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.provider.ObjectInFolderContainer;
+import org.apache.chemistry.opencmis.commons.provider.PropertiesData;
+import org.apache.chemistry.opencmis.commons.provider.RepositoryInfoData;
+
+/**
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+public class Tools {
+
+ public static void print(RepositoryInfoData repositoryInfo) {
+ if (repositoryInfo == null) {
+ return;
+ }
+
+ System.out.println("-------------");
+ System.out.println("Id: " + repositoryInfo.getRepositoryId());
+ System.out.println("Name: " + repositoryInfo.getRepositoryName());
+ 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.getRepositoryCapabilities());
+ 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(" ");
+ }
+
+ PropertiesData properties = container.getObject().getObject().getProperties();
+ System.out.println(properties.getProperties().get(PropertyIds.CMIS_NAME).getFirstValue()
+ + " (" + properties.getProperties().get(PropertyIds.CMIS_OBJECT_TYPE_ID).getFirstValue()
+ + ")");
+
+ print(container.getChildren(), level + 1);
+ }
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,251 @@
+/*
+ * 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.misc;
+
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.opencmis.commons.api.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
+import org.apache.chemistry.opencmis.commons.enums.BaseObjectTypeIds;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityAcl;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityChanges;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityContentStreamUpdates;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityJoin;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityRendition;
+import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
+import org.apache.chemistry.opencmis.commons.impl.Converter;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AclCapabilitiesDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionDefinitionDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionMappingDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoDataImpl;
+import org.apache.chemistry.opencmis.commons.provider.ObjectData;
+import org.apache.chemistry.opencmis.commons.provider.PermissionDefinitionData;
+import org.apache.chemistry.opencmis.commons.provider.PermissionMappingData;
+import org.apache.chemistry.opencmis.commons.provider.RepositoryInfoData;
+
+/**
+ * Tests converter methods.
+ *
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+public class ConverterTest extends TestCase {
+
+ public void testRepositoryInfo() throws Exception {
+ // dry run
+ RepositoryInfoDataImpl obj1 = new RepositoryInfoDataImpl();
+ RepositoryInfoData obj2 = Converter.convert(Converter.convert(obj1));
+
+ assertDataObjectsEquals("RepositoryInfo", obj1, obj2);
+
+ // values
+ obj1 = new RepositoryInfoDataImpl();
+ obj1.setChangesIncomplete(Boolean.TRUE);
+ obj1.setChangesOnType(Collections.singletonList(BaseObjectTypeIds.CMIS_DOCUMENT));
+ obj1.setCmisVersionSupported("1.0");
+ obj1.setLatestChangeLogToken("changeLogToken");
+ obj1.setPrincipalAnonymous("principalAnonymous");
+ obj1.setPrincipalAnyone("principalAnyone");
+ obj1.setProductName("productName");
+ obj1.setProductVersion("productVersion");
+ obj1.setRepositoryDescription("description");
+ obj1.setRepositoryId("id");
+ obj1.setRepositoryName("name");
+ obj1.setRootFolder("rootFolderId");
+ obj1.setThinClientUri("thinClientUri");
+ obj1.setVendorName("vendorName");
+
+ RepositoryCapabilitiesDataImpl cap1 = new RepositoryCapabilitiesDataImpl();
+ cap1.setAllVersionsSearchable(Boolean.TRUE);
+ cap1.setCapabilityAcl(CapabilityAcl.DISCOVER);
+ cap1.setCapabilityChanges(CapabilityChanges.ALL);
+ cap1.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME);
+ cap1.setCapabilityJoin(CapabilityJoin.INNERANDOUTER);
+ cap1.setCapabilityQuery(CapabilityQuery.BOTHCOMBINED);
+ cap1.setCapabilityRendition(CapabilityRendition.READ);
+ cap1.setIsPwcSearchable(Boolean.TRUE);
+ cap1.setIsPwcUpdatable(Boolean.TRUE);
+ cap1.setSupportsGetDescendants(Boolean.TRUE);
+ cap1.setSupportsGetFolderTree(Boolean.TRUE);
+ cap1.setSupportsMultifiling(Boolean.TRUE);
+ cap1.setSupportsUnfiling(Boolean.TRUE);
+ cap1.setSupportsVersionSpecificFiling(Boolean.TRUE);
+ obj1.setRepositoryCapabilities(cap1);
+
+ AclCapabilitiesDataImpl acl1 = new AclCapabilitiesDataImpl();
+ acl1.setAclPropagation(AclPropagation.PROPAGATE);
+ List<PermissionDefinitionData> pddList = new ArrayList<PermissionDefinitionData>();
+ PermissionDefinitionDataImpl pdd1 = new PermissionDefinitionDataImpl();
+ pdd1.setPermission("test:perm1");
+ pdd1.setDescription("Permission1");
+ pddList.add(pdd1);
+ PermissionDefinitionDataImpl pdd2 = new PermissionDefinitionDataImpl();
+ pdd2.setPermission("test:perm2");
+ pdd2.setDescription("Permission2");
+ pddList.add(pdd2);
+ acl1.setPermissionDefinitionData(pddList);
+ List<PermissionMappingData> pmdList = new ArrayList<PermissionMappingData>();
+ PermissionMappingDataImpl pmd1 = new PermissionMappingDataImpl();
+ pmd1.setKey(PermissionMappingData.KEY_CAN_CREATE_DOCUMENT_FOLDER);
+ pmd1.setPermissions(Arrays.asList(new String[] { "p1", "p2" }));
+ pmdList.add(pmd1);
+ PermissionMappingDataImpl pmd2 = new PermissionMappingDataImpl();
+ pmd2.setKey(PermissionMappingData.KEY_CAN_DELETE_OBJECT);
+ pmd2.setPermissions(Arrays.asList(new String[] { "p3", "p4" }));
+ pmdList.add(pmd2);
+ acl1.setPermissionMappingData(pmdList);
+ obj1.setAclCapabilities(acl1);
+
+ obj2 = Converter.convert(Converter.convert(obj1));
+
+ assertDataObjectsEquals("RepositoryInfo", obj1, obj2);
+ }
+
+ public void testTypeDefinition() throws Exception {
+ // dry run
+ DocumentTypeDefinitionImpl obj1 = new DocumentTypeDefinitionImpl();
+ TypeDefinition obj2 = Converter.convert(Converter.convert(obj1));
+
+ assertDataObjectsEquals("TypeDefinition", obj1, obj2);
+
+ // simple values
+ obj1 = new DocumentTypeDefinitionImpl();
+ obj1.setBaseId(BaseObjectTypeIds.CMIS_DOCUMENT);
+ obj1.setContentStreamAllowed(ContentStreamAllowed.ALLOWED);
+ obj1.setDescription("description");
+ obj1.setDisplayName("displayName");
+ obj1.setId("id");
+ obj1.setIsControllableAcl(Boolean.TRUE);
+ obj1.setIsControllablePolicy(Boolean.TRUE);
+ obj1.setIsCreatable(Boolean.TRUE);
+ obj1.setIsFileable(Boolean.TRUE);
+ obj1.setIsIncludedInSupertypeQuery(Boolean.TRUE);
+ obj1.setIsQueryable(Boolean.TRUE);
+ obj1.setIsVersionable(Boolean.TRUE);
+ obj1.setLocalName("localName");
+ obj1.setLocalNamespace("localNamespace");
+ obj1.setParentId("parentId");
+ obj1.setQueryName("queryName");
+
+ obj2 = Converter.convert(Converter.convert(obj1));
+
+ assertDataObjectsEquals("TypeDefinition", obj1, obj2);
+ }
+
+ public void testObject() throws Exception {
+ // dry run
+ ObjectDataImpl obj1 = new ObjectDataImpl();
+ ObjectData obj2 = Converter.convert(Converter.convert(obj1));
+
+ assertDataObjectsEquals("Object", obj1, obj2);
+ }
+
+ /**
+ * Asserts OpenCMIS data objects.
+ */
+ protected void assertDataObjectsEquals(String name, Object expected, Object actual)
+ throws Exception {
+ System.out.println(name);
+
+ if ((expected == null) && (actual == null)) {
+ return;
+ }
+
+ if ((expected == null) && (actual instanceof Collection<?>)) {
+ assertTrue(((Collection<?>) actual).isEmpty());
+ return;
+ }
+ else if ((expected instanceof Collection<?>) && (actual == null)) {
+ assertTrue(((Collection<?>) expected).isEmpty());
+ return;
+ }
+ else if ((expected == null) || (actual == null)) {
+ fail("Data object is null! name: " + name + " / expected: " + expected + " / actual: "
+ + actual);
+ }
+
+ // handle simple types
+ if ((expected instanceof String) || (expected instanceof Boolean)
+ || (expected instanceof BigInteger) || (expected instanceof BigDecimal)
+ || (expected instanceof Enum<?>)) {
+ assertEquals(expected, actual);
+
+ return;
+ }
+ else if (expected instanceof List<?>) {
+ List<?> expectedList = (List<?>) expected;
+ List<?> actualList = (List<?>) actual;
+
+ assertEquals(expectedList.size(), actualList.size());
+
+ for (int i = 0; i < expectedList.size(); i++) {
+ assertDataObjectsEquals(name + "[" + i + "]", expectedList.get(i), actualList.get(i));
+ }
+
+ return;
+ }
+ else if (expected instanceof Map<?, ?>) {
+ Map<?, ?> expectedMap = (Map<?, ?>) expected;
+ Map<?, ?> actualMap = (Map<?, ?>) actual;
+
+ assertEquals(expectedMap.size(), actualMap.size());
+
+ for (Map.Entry<?, ?> entry : expectedMap.entrySet()) {
+ assertTrue(actualMap.containsKey(entry.getKey()));
+ assertDataObjectsEquals(name + "[" + entry.getKey() + "]", entry.getValue(), actualMap
+ .get(entry.getKey()));
+ }
+
+ return;
+ }
+
+ for (Method m : expected.getClass().getMethods()) {
+ if (!m.getName().startsWith("get") && !m.getName().startsWith("supports")) {
+ continue;
+ }
+
+ if (m.getName().equals("getClass")) {
+ continue;
+ }
+
+ if (m.getParameterTypes().length != 0) {
+ continue;
+ }
+
+ Object expectedValue = m.invoke(expected, new Object[0]);
+ Object actualValue = m.invoke(actual, new Object[0]);
+
+ assertDataObjectsEquals(name + "." + m.getName(), expectedValue, actualValue);
+ }
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,61 @@
+/*
+ * 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.misc;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+
+/**
+ * Tests miscellaneous details.
+ *
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+public class MiscTest extends TestCase {
+
+ public void testUrlBuilder() {
+ assertEquals("http://host/test", (new UrlBuilder("http://host/test")).toString());
+ assertEquals("http://host/test?query=value", (new UrlBuilder("http://host/test?query=value"))
+ .toString());
+ assertEquals("http://host/test", (new UrlBuilder("http://host/test?")).toString());
+
+ UrlBuilder urlBuilder;
+
+ urlBuilder = new UrlBuilder("http://host/test");
+ urlBuilder.addParameter("query", "value");
+ assertEquals("http://host/test?query=value", urlBuilder.toString());
+
+ urlBuilder = new UrlBuilder("http://host/test");
+ urlBuilder.addPath("path");
+ assertEquals("http://host/test/path", urlBuilder.toString());
+
+ urlBuilder = new UrlBuilder("http://host/test/");
+ urlBuilder.addPath("path");
+ assertEquals("http://host/test/path", urlBuilder.toString());
+
+ urlBuilder = new UrlBuilder("http://host/test");
+ urlBuilder.addPath("/path");
+ assertEquals("http://host/test/path", urlBuilder.toString());
+
+ urlBuilder = new UrlBuilder("http://host/test/");
+ urlBuilder.addPath("/path");
+ assertEquals("http://host/test/path", urlBuilder.toString());
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,56 @@
+/*
+ * 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.provider.CmisBinding;
+
+/**
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+public class SimpleReadOnlyTests extends AbstractSimpleReadOnlyTests {
+
+ private 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;
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,57 @@
+/*
+ * 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.provider.CmisBinding;
+
+/**
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+public class SimpleReadWriteTests extends AbstractSimpleReadWriteTests {
+
+ private 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_VERSIONING);
+ }
+
+ @Override
+ protected CmisBinding createBinding() {
+ return WebServicesTestBindingFactory.createBinding(getWebServicesURL(), getUsername(),
+ getPassword());
+ }
+
+ @Override
+ protected Set<String> getEnabledTests() {
+ return fTests;
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,92 @@
+/*
+ * 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.Map;
+
+import org.apache.chemistry.opencmis.client.bindings.factory.CmisBindingFactory;
+import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.provider.CmisBinding;
+
+/**
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+public class WebServicesTestBindingFactory {
+
+ public static CmisBinding createBinding(String url, String username, String password) {
+ boolean isPrefix = true;
+ String urlLower = url.toLowerCase();
+
+ if (urlLower.endsWith("?wsdl")) {
+ isPrefix = false;
+ }
+ else if (urlLower.endsWith(".wsdl")) {
+ isPrefix = false;
+ }
+ else if (urlLower.endsWith(".xml")) {
+ 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;
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractBindingIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractBindingIT.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractBindingIT.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractBindingIT.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,140 @@
+/*
+ * 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.fit.bindings;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.enums.UnfileObjects;
+import org.apache.chemistry.opencmis.commons.provider.CmisBinding;
+import org.apache.chemistry.opencmis.commons.provider.PropertiesData;
+import org.apache.chemistry.opencmis.commons.provider.PropertyData;
+import org.apache.chemistry.opencmis.commons.provider.RepositoryInfoData;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * Base class for binding layer tests. It makes sure that the provider object is only created once
+ * and that there is a test folder.
+ *
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+public abstract class AbstractBindingIT {
+ public static String FOLDER_TYPE = "cmis:folder";
+ public static String DOCUMENT_TYPE = "cmis:document";
+
+ private static CmisBinding binding;
+ private static String fRepositoryId;
+ private static String fTestFolderId;
+
+ /**
+ * Returns the id of test folder. Tests should only use this folder.
+ */
+ protected String getTestFolderId() {
+ return fTestFolderId;
+ }
+
+ /**
+ * Returns the current binding object.
+ */
+ protected static CmisBinding getBinding() {
+ return binding;
+ }
+
+ /**
+ * Returns a new binding object.
+ */
+ protected abstract CmisBinding createBinding();
+
+ /**
+ * Returns the repository id of the test repository.
+ */
+ protected abstract String getRepositoryId();
+
+ @BeforeClass
+ public static void setUpClass() {
+ binding = null;
+ }
+
+ @Before
+ public void setUpTest() {
+ // only the first test creates the test environment
+ if (binding == null) {
+ System.out.println("Creating provider...");
+
+ binding = createBinding();
+ fRepositoryId = getRepositoryId();
+ createTestFolder();
+ }
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ deleteTestFolder();
+ binding = null;
+ }
+
+ /**
+ * Creates a folder that will be used by all read-write tests.
+ */
+ private void createTestFolder() {
+ System.out.println("Creating test folder...");
+
+ // get root folder id
+ RepositoryInfoData ri = getBinding().getRepositoryService().getRepositoryInfo(fRepositoryId,
+ null);
+ assertNotNull(ri);
+ assertNotNull(ri.getRootFolderId());
+
+ String rootFolderId = ri.getRootFolderId();
+
+ // set up properties
+ List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();
+ propertyList.add(getBinding().getObjectFactory().createPropertyStringData(
+ PropertyIds.CMIS_NAME, "provider-tests-" + System.currentTimeMillis()));
+ propertyList.add(getBinding().getObjectFactory().createPropertyIdData(
+ PropertyIds.CMIS_OBJECT_TYPE_ID, FOLDER_TYPE));
+
+ PropertiesData properties = getBinding().getObjectFactory().createPropertiesData(propertyList);
+
+ // create the folder
+ fTestFolderId = getBinding().getObjectService().createFolder(fRepositoryId, properties,
+ rootFolderId, null, null, null, null);
+ }
+
+ /**
+ * Deletes the test folder.
+ */
+ private static void deleteTestFolder() {
+ if (fTestFolderId == null) {
+ return;
+ }
+
+ System.out.println("Deleting test folder...");
+
+ // delete the whole tree
+ getBinding().getObjectService().deleteTree(fRepositoryId, fTestFolderId, true,
+ UnfileObjects.DELETE, true, null);
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractBindingIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractBindingIT.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractBindingIT.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractBindingIT.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractSimpleBindingIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractSimpleBindingIT.java?rev=934361&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractSimpleBindingIT.java (added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/bindings/AbstractSimpleBindingIT.java Thu Apr 15 10:33:49 2010
@@ -0,0 +1,92 @@
+/*
+ * 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.fit.bindings;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+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.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.provider.ContentStreamData;
+import org.apache.chemistry.opencmis.commons.provider.ObjectData;
+import org.apache.chemistry.opencmis.commons.provider.PropertiesData;
+import org.apache.chemistry.opencmis.commons.provider.PropertyData;
+import org.apache.chemistry.opencmis.commons.provider.RepositoryInfoData;
+import org.junit.Test;
+
+/**
+ * Really simple binding layer test. It just contains a few smoke tests to make sure that the
+ * provider layer is working properly in the integration test environment.
+ *
+ * @author <a href="mailto:fmueller@opentext.com">Florian Müller</a>
+ *
+ */
+public abstract class AbstractSimpleBindingIT extends AbstractBindingIT {
+
+ @Test
+ public void testRepositoryInfo() {
+ RepositoryInfoData ri = getBinding().getRepositoryService().getRepositoryInfo(
+ getRepositoryId(), null);
+ assertNotNull(ri);
+
+ assertEquals(getRepositoryId(), ri.getRepositoryId());
+ assertNotNull(ri.getProductName());
+ assertNotNull(ri.getRootFolderId());
+ assertNotNull(ri.getRepositoryCapabilities());
+ }
+
+ @Test
+ public void testCreateDocument() {
+ // set up properties
+ List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();
+ propertyList.add(getBinding().getObjectFactory().createPropertyStringData(
+ PropertyIds.CMIS_NAME, "testdoc.txt"));
+ propertyList.add(getBinding().getObjectFactory().createPropertyIdData(
+ PropertyIds.CMIS_OBJECT_TYPE_ID, DOCUMENT_TYPE));
+
+ PropertiesData properties = getBinding().getObjectFactory().createPropertiesData(propertyList);
+
+ // set up content
+ byte[] content = "This is a test file!".getBytes();
+
+ ContentStreamData contentStream = getBinding().getObjectFactory()
+ .createContentStream(BigInteger.valueOf(content.length), "text/plain", "test",
+ new ByteArrayInputStream(content));
+
+ // create document
+ String docId = getBinding().getObjectService().createDocument(getRepositoryId(), properties,
+ getTestFolderId(), contentStream, VersioningState.NONE, null, null, null, null);
+ assertNotNull(docId);
+
+ // get the document
+ ObjectData object = getBinding().getObjectService().getObject(getRepositoryId(), docId, null,
+ false, IncludeRelationships.NONE, null, false, false, null);
+ assertNotNull(object);
+ assertEquals(docId, object.getId());
+
+ // delete the document
+ getBinding().getObjectService().deleteObject(getRepositoryId(), docId, true, null);
+ }
+}