You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dc...@apache.org on 2010/04/16 16:02:40 UTC

svn commit: r934881 [11/12] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src: main/java/org/apache/chemistry/opencmis/client/bindings/cache/ main/java/org/apache/chemistry/opencmis/client/binding...

Modified: 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=934881&r1=934880&r2=934881&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadOnlyTests.java Fri Apr 16 14:02:38 2010
@@ -48,514 +48,494 @@ import org.apache.chemistry.opencmis.com
 
 /**
  * Simple read-only tests.
- *
+ * 
  * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;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;
-    }
-
-    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() 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(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() 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(),
-        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() == 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() 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(BaseTypeId.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
-    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) 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);
-
-    Properties latestVersionProperties = getBinding().getVersioningService()
-        .getPropertiesOfLatestVersion(getTestRepositoryId(), 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(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!");
-      }
-    }
-  }
+	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;
+		}
+
+		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() 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(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() 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(), 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() == 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() 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(BaseTypeId.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
+		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) 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);
+
+		Properties latestVersionProperties = getBinding().getVersioningService().getPropertiesOfLatestVersion(
+				getTestRepositoryId(), 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(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!");
+			}
+		}
+	}
 }

Modified: 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=934881&r1=934880&r2=934881&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/AbstractSimpleReadWriteTests.java Fri Apr 16 14:02:38 2010
@@ -37,389 +37,369 @@ import org.apache.chemistry.opencmis.com
 
 /**
  * Simple read-write test.
- *
+ * 
  * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;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.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 property updates.
-   */
-  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
-    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
-    ContentStream 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();
-    }
-    ContentStream contentStream3 = getContent(docId, 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(), 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.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() 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,
-        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() 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.IS_VERSION_SERIES_CHECKED_OUT);
-    assertNotNull(isCheckedOut);
-    assertTrue(isCheckedOut.getFirstValue() instanceof Boolean);
+	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.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 property updates.
+	 */
+	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
+		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
+		ContentStream 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();
+		}
+		ContentStream contentStream3 = getContent(docId, 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(), 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.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() 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, 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() 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.IS_VERSION_SERIES_CHECKED_OUT);
+		assertNotNull(isCheckedOut);
+		assertTrue(isCheckedOut.getFirstValue() instanceof Boolean);
 
-    return ((Boolean) isCheckedOut.getFirstValue()).booleanValue();
-  }
+		return ((Boolean) isCheckedOut.getFirstValue()).booleanValue();
+	}
 }

Modified: 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=934881&r1=934880&r2=934881&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/framework/Tools.java Fri Apr 16 14:02:38 2010
@@ -32,73 +32,72 @@ import org.apache.chemistry.opencmis.com
  */
 public class 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);
-    }
-  }
+	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);
+		}
+	}
 }

Modified: 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=934881&r1=934880&r2=934881&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/ConverterTest.java Fri Apr 16 14:02:38 2010
@@ -56,197 +56,190 @@ import org.apache.chemistry.opencmis.com
 
 /**
  * Tests converter methods.
- *
+ * 
  * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
- *
+ * 
  */
 public class ConverterTest extends TestCase {
 
-  public void testRepositoryInfo() throws Exception {
-    // dry run
-    RepositoryInfoImpl obj1 = new RepositoryInfoImpl();
-    RepositoryInfo obj2 = Converter.convert(Converter.convert(obj1));
-
-    assertDataObjectsEquals("RepositoryInfo", obj1, obj2);
-
-    // values
-    obj1 = new RepositoryInfoImpl();
-    obj1.setChangesIncomplete(Boolean.TRUE);
-    obj1.setChangesOnType(Collections.singletonList(BaseTypeId.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");
-
-    RepositoryCapabilitiesImpl cap1 = new RepositoryCapabilitiesImpl();
-    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(CapabilityRenditions.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<PermissionDefinition> pddList = new ArrayList<PermissionDefinition>();
-    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);
-    Map<String, PermissionMapping> pmd = new LinkedHashMap<String, PermissionMapping>();
-    PermissionMappingDataImpl pmd1 = new PermissionMappingDataImpl();
-    pmd1.setKey(PermissionMapping.CAN_CREATE_DOCUMENT_FOLDER);
-    pmd1.setPermissions(Arrays.asList(new String[] { "p1", "p2" }));
-    pmd.put(pmd1.getKey(), pmd1);
-    PermissionMappingDataImpl pmd2 = new PermissionMappingDataImpl();
-    pmd2.setKey(PermissionMapping.CAN_DELETE_OBJECT);
-    pmd2.setPermissions(Arrays.asList(new String[] { "p3", "p4" }));
-    pmd.put(pmd2.getKey(), pmd2);
-    acl1.setPermissionMappingData(pmd);
-    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.setBaseTypeId(BaseTypeId.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.setParentTypeId("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);
-    }
-  }
+	public void testRepositoryInfo() throws Exception {
+		// dry run
+		RepositoryInfoImpl obj1 = new RepositoryInfoImpl();
+		RepositoryInfo obj2 = Converter.convert(Converter.convert(obj1));
+
+		assertDataObjectsEquals("RepositoryInfo", obj1, obj2);
+
+		// values
+		obj1 = new RepositoryInfoImpl();
+		obj1.setChangesIncomplete(Boolean.TRUE);
+		obj1.setChangesOnType(Collections.singletonList(BaseTypeId.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");
+
+		RepositoryCapabilitiesImpl cap1 = new RepositoryCapabilitiesImpl();
+		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(CapabilityRenditions.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<PermissionDefinition> pddList = new ArrayList<PermissionDefinition>();
+		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);
+		Map<String, PermissionMapping> pmd = new LinkedHashMap<String, PermissionMapping>();
+		PermissionMappingDataImpl pmd1 = new PermissionMappingDataImpl();
+		pmd1.setKey(PermissionMapping.CAN_CREATE_DOCUMENT_FOLDER);
+		pmd1.setPermissions(Arrays.asList(new String[] { "p1", "p2" }));
+		pmd.put(pmd1.getKey(), pmd1);
+		PermissionMappingDataImpl pmd2 = new PermissionMappingDataImpl();
+		pmd2.setKey(PermissionMapping.CAN_DELETE_OBJECT);
+		pmd2.setPermissions(Arrays.asList(new String[] { "p3", "p4" }));
+		pmd.put(pmd2.getKey(), pmd2);
+		acl1.setPermissionMappingData(pmd);
+		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.setBaseTypeId(BaseTypeId.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.setParentTypeId("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);
+		}
+	}
 }

Modified: 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=934881&r1=934880&r2=934881&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/MiscTest.java Fri Apr 16 14:02:38 2010
@@ -30,32 +30,31 @@ import org.apache.chemistry.opencmis.com
  */
 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());
-  }
+	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());
+	}
 }

Modified: 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=934881&r1=934880&r2=934881&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java Fri Apr 16 14:02:38 2010
@@ -30,27 +30,26 @@ import org.apache.chemistry.opencmis.com
  */
 public class SimpleReadOnlyTests extends AbstractSimpleReadOnlyTests {
 
-  private Set<String> fTests;
+	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);
-  }
+	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 CmisBinding createBinding() {
+		return WebServicesTestBindingFactory.createBinding(getWebServicesURL(), getUsername(), getPassword());
+	}
 
-  @Override
-  protected Set<String> getEnabledTests() {
-    return fTests;
-  }
+	@Override
+	protected Set<String> getEnabledTests() {
+		return fTests;
+	}
 }