chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sklev...@apache.org
Subject svn commit: r923360 - in /incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl: ./ src/test/java/org/apache/opencmis/client/runtime/ src/test/java/org/apache/opencmis/client/runtime/mock/ src/test/java/org/apache/opencmis/client/runt...
Date Mon, 15 Mar 2010 17:35:58 GMT
Author: sklevenz
Date: Mon Mar 15 17:35:58 2010
New Revision: 923360

URL: http://svn.apache.org/viewvc?rev=923360&view=rev
Log:
Client Runtime Junit Test Improvment using InMemory Provider

Added:
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureData.java   (with props)
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSessionParameter.java   (contents, props changed)
      - copied, changed from r923107, incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestSessionParameter.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSetup.java   (contents, props changed)
      - copied, changed from r923107, incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/DataSetup.java
Removed:
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/DataSetup.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestSessionParameter.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/suite/
Modified:
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/pom.xml
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/Fixture.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyAclCapabilityTest.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyContentStreamTest.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyDiscoverTest.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyNavigationTest.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyObjectTest.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyTypeTest.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/mock/MockSessionFactory.java

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/pom.xml?rev=923360&r1=923359&r2=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/pom.xml (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/pom.xml Mon Mar 15 17:35:58 2010
@@ -84,7 +84,7 @@
 							<groupId>org.apache.maven.plugins</groupId>
 							<artifactId>maven-surefire-plugin</artifactId>
 							<configuration>
-								<argLine>-Dorg.apache.opencmis.client.runtime.suite.config.path=${org.apache.opencmis.client.runtime.suite.config.path}</argLine>
+								<argLine>-Dorg.apache.opencmis.client.runtime.test.config.path=${org.apache.opencmis.client.runtime.test.config.path}</argLine>
 							</configuration>
 						</plugin>
 					</plugins>

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/Fixture.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/Fixture.java?rev=923360&r1=923359&r2=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/Fixture.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/Fixture.java Mon Mar 15 17:35:58 2010
@@ -47,22 +47,10 @@ public class Fixture {
 
 	private static Log log = LogFactory.getLog(Fixture.class);
 
-	public static String PROPERTY_FILTER = "*";
 	/*
 	 * general
 	 */
-	public static String TEST_ROOT_FOLDER_NAME = null;
-	public static String FOLDER_TYPE_ID = "test.folder";
-	public static String DOCUMENT_TYPE_ID = "test.file";
-	public static String QUERY = "SELECT * FROM cmis:document";
-
-	/*
-	 * cmis objects
-	 */
-	public static String FOLDER1_NAME = "folder.1";
-	public static String FOLDER2_NAME = "folder.2";
-	public static String DOCUMENT1_NAME = "document.1.txt";
-	public static String DOCUMENT2_NAME = "document.2.txt";
+	public static String TEST_ROOT_FOLDER_NAME = "test_" + UUID.randomUUID().toString();
 
 	/*
 	 * properties
@@ -91,11 +79,7 @@ public class Fixture {
 	/*
 	 * test data setup
 	 */
-	private static DataSetup testData = new DataSetup();
-
-	static {
-		Fixture.TEST_ROOT_FOLDER_NAME = "test_" + UUID.randomUUID().toString();
-	}
+	private static FixtureSetup testData = new FixtureSetup();
 
 	/**
 	 * @return session parameter
@@ -110,18 +94,8 @@ public class Fixture {
 	 * @param paramter
 	 */
 	public static void setParamter(Map<String, String> paramter) {
+		FixtureData.changeValues(paramter);
 		Fixture.parameter = paramter;
-
-		/* overload fixture values */
-		String value;
-
-		value = Fixture.parameter.get(TestSessionParameter.DOCUMENT_TYPE_ID);
-		Fixture.DOCUMENT_TYPE_ID = (value != null ? value
-				: Fixture.DOCUMENT_TYPE_ID);
-
-		value = Fixture.parameter.get(TestSessionParameter.FOLDER_TYPE_ID);
-		Fixture.FOLDER_TYPE_ID = (value != null ? value
-				: Fixture.FOLDER_TYPE_ID);
 	}
 
 	/**
@@ -157,7 +131,7 @@ public class Fixture {
 
 	public static void init() {
 		/* get optional path from system properties */
-		String pathname = System.getProperty(TestSessionParameter.CONFIG_PATH);
+		String pathname = System.getProperty(FixtureSessionParameter.CONFIG_PATH);
 		pathname = (pathname != null) ? pathname.trim() : null;
 		Properties properties = null;
 		Map<String, String> sessionParameter = null;
@@ -190,7 +164,7 @@ public class Fixture {
 
 			/* load factory class */
 			factoryClassName = sessionParameter
-					.get(TestSessionParameter.SESSION_FACTORY);
+					.get(FixtureSessionParameter.SESSION_FACTORY);
 			if (factoryClassName != null
 					&& !"".equalsIgnoreCase(factoryClassName)) {
 				Class<?> clazz = Class.forName(factoryClassName);
@@ -231,7 +205,7 @@ public class Fixture {
 			Fixture.log
 					.info("---------------------------------------------------------------");
 			Fixture.log.info("config path (prop): "
-					+ System.getProperty(TestSessionParameter.CONFIG_PATH));
+					+ System.getProperty(FixtureSessionParameter.CONFIG_PATH));
 			Fixture.log.info("session factory:    "
 					+ Fixture.getSessionFactory().getClass());
 			Fixture.log.info("session parameter:  " + Fixture.getParamter());

Added: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureData.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureData.java?rev=923360&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureData.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureData.java Mon Mar 15 17:35:58 2010
@@ -0,0 +1,81 @@
+/*
+ * 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.opencmis.client.runtime;
+
+import java.util.Map;
+
+public enum FixtureData {
+	FOLDER_TYPE_ID("org.apache.opencmis.client.runtime.test.folder.type.id",
+			"cmis:folder"), DOCUMENT_TYPE_ID(
+			"org.apache.opencmis.client.runtime.test.document.type.id",
+			"cmis:document"), QUERY(
+			"org.apache.opencmis.client.runtime.test.query",
+			"SELECT * FROM cmis:document"), PROPERTY_FILTER(
+			"org.apache.opencmis.client.runtime.test.property.filter", "*"), FOLDER1_NAME(
+			"org.apache.opencmis.client.runtime.test.folder1.name", "folder1"), FOLDER2_NAME(
+			"org.apache.opencmis.client.runtime.test.folder2.name", "folder2"), DOCUMENT1_NAME(
+			"org.apache.opencmis.client.runtime.test.document1.name",
+			"document1.txt"), DOCUMENT2_NAME(
+			"org.apache.opencmis.client.runtime.test.document2.name",
+			"document2.txt"), ;
+
+	// XXX("org.apache.opencmis.client.runtime.test.XXX", "XXX"),
+
+	private String key;
+	private String value;
+
+	FixtureData(String key, String value) {
+		this.key = key;
+		this.value = value;
+	}
+
+	public String value() {
+		return this.value;
+	}
+
+	public static void changeValues(Map<String, String> map) {
+		for (FixtureData fd : FixtureData.values()) {
+			String v = map.get(fd.key);
+			if (v != null) {
+				fd.changeValue(v);
+			}
+		}
+	}
+
+	public static FixtureData get(String key) {
+		for (FixtureData fd : FixtureData.values()) {
+			if (fd.key.equals(key)) {
+				return fd;
+			}
+		}
+		throw new IllegalArgumentException(key);
+	}
+
+	void changeValue(String newValue) {
+		this.value = newValue;
+	}
+
+	public String toString() {
+		return this.value();
+	}
+
+	public String key() {
+		return this.key;
+	}
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureData.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSessionParameter.java (from r923107, incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestSessionParameter.java)
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSessionParameter.java?p2=incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSessionParameter.java&p1=incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestSessionParameter.java&r1=923107&r2=923360&rev=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestSessionParameter.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSessionParameter.java Mon Mar 15 17:35:58 2010
@@ -18,18 +18,17 @@
  */
 package org.apache.opencmis.client.runtime;
 
-public interface TestSessionParameter {
+public interface FixtureSessionParameter {
 
 	/*
 	 * session parameter
 	 */
-	static final String FOLDER_TYPE_ID =   "org.apache.opencmis.client.runtime.test.folder.type.id";
-	static final String DOCUMENT_TYPE_ID = "org.apache.opencmis.client.runtime.test.document.type.id";
 
-	/*
-	 * environment
+	/**
+	 * CONFIG_PATH is referenced in pom.xml! If you change here then change pom.
 	 */
 	static final String CONFIG_PATH =         "org.apache.opencmis.client.runtime.test.config.path";
+
 	static final String SESSION_FACTORY =     "org.apache.opencmis.client.runtime.test.session.factory";
 	static final String TEST_ROOT_FOLDER_ID = "org.apache.opencmis.client.runtime.test.root.folder.id";
 

Propchange: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSessionParameter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSetup.java (from r923107, incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/DataSetup.java)
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSetup.java?p2=incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSetup.java&p1=incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/DataSetup.java&r1=923107&r2=923360&rev=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/DataSetup.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSetup.java Mon Mar 15 17:35:58 2010
@@ -33,7 +33,7 @@ import org.apache.opencmis.commons.provi
 import org.apache.opencmis.util.repository.ObjectGenerator;
 import org.junit.Assert;
 
-public class DataSetup {
+public class FixtureSetup {
 
 	private CmisProvider provider = null;
 	private String rootFolderId = null; // root
@@ -63,10 +63,10 @@ public class DataSetup {
 
 		// root folder
 		if (Fixture.getParamter().containsKey(
-				TestSessionParameter.TEST_ROOT_FOLDER_ID)) {
+				FixtureSessionParameter.TEST_ROOT_FOLDER_ID)) {
 			// test root folder
 			this.rootFolderId = Fixture.getParamter().get(
-					TestSessionParameter.TEST_ROOT_FOLDER_ID);
+					FixtureSessionParameter.TEST_ROOT_FOLDER_ID);
 			Assert.assertNotNull(this.rootFolderId);
 		} else {
 			RepositoryInfoData rid = this.provider.getRepositoryService()
@@ -77,18 +77,15 @@ public class DataSetup {
 		}
 
 		// object types
-		String documentTypeId = Fixture.getParamter().get(
-				TestSessionParameter.DOCUMENT_TYPE_ID);
+		String documentTypeId = FixtureData.DOCUMENT_TYPE_ID.value();
 		Assert.assertNotNull(documentTypeId);
-		String folderTypeId = Fixture.getParamter().get(
-				TestSessionParameter.FOLDER_TYPE_ID);
-		;
+		String folderTypeId = FixtureData.FOLDER_TYPE_ID.value();
 		Assert.assertNotNull(folderTypeId);
 
 		// create test root folder
 		List<PropertyData<?>> propList = new ArrayList<PropertyData<?>>();
 		propList.add(this.provider.getObjectFactory().createPropertyStringData(
-				PropertyIds.CMIS_NAME, UUID.randomUUID().toString()));
+				PropertyIds.CMIS_NAME, Fixture.TEST_ROOT_FOLDER_NAME));
 		propList.add(this.provider.getObjectFactory().createPropertyIdData(
 				PropertyIds.CMIS_OBJECT_TYPE_ID, folderTypeId));
 
@@ -107,6 +104,6 @@ public class DataSetup {
 		og.setFolderPropertiesToGenerate(new ArrayList<String>());
 
 		og.createFolderHierachy(2, 2, this.testRootFolderId);
-
 	}
+	
 }

Propchange: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/FixtureSetup.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyAclCapabilityTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyAclCapabilityTest.java?rev=923360&r1=923359&r2=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyAclCapabilityTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyAclCapabilityTest.java Mon Mar 15 17:35:58 2010
@@ -38,8 +38,6 @@ public class ReadOnlyAclCapabilityTest e
 
   @Before
   public void setup() throws Exception {
-    super.setUp();
-
     RepositoryInfo r = this.session.getRepositoryInfo();
     // capabilities
     RepositoryCapabilities repcap = r.getCapabilities();

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyContentStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyContentStreamTest.java?rev=923360&r1=923359&r2=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyContentStreamTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyContentStreamTest.java Mon Mar 15 17:35:58 2010
@@ -30,27 +30,28 @@ import org.apache.opencmis.client.api.Do
 
 public class ReadOnlyContentStreamTest extends AbstractSessionTest {
 
-  @Test
-  public void readContentStream() throws IOException {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.DOCUMENT1_NAME;
-    Document document = (Document) this.session.getObjectByPath(path);
-    Assert.assertNotNull("document not found: " + path, document);
-
-    ContentStream s = document.getContentStream();
-
-    Assert.assertNotNull(s.getMimeType());
-    Assert.assertTrue(s.getLength() > 0);
-    Assert.assertNotNull(s.getFileName());
-
-    InputStream is = s.getStream();
-    Assert.assertNotNull(is);
-
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    baos.write(is.read());
-    byte[] b = baos.toByteArray();
-
-    Assert.assertNotNull(b);
-    Assert.assertTrue(b.length > 0);
-  }
+	@Test
+	public void readContentStream() throws IOException {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.DOCUMENT1_NAME.toString();
+		Document document = (Document) this.session.getObjectByPath(path);
+		Assert.assertNotNull("document not found: " + path, document);
+
+		ContentStream s = document.getContentStream();
+
+		Assert.assertNotNull(s.getMimeType());
+		s.getLength();
+		s.getFileName();
+
+		InputStream is = s.getStream();
+		Assert.assertNotNull(is);
+
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		baos.write(is.read());
+		byte[] b = baos.toByteArray();
+
+		Assert.assertNotNull(b);
+		Assert.assertTrue(b.length > 0);
+	}
 
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyDiscoverTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyDiscoverTest.java?rev=923360&r1=923359&r2=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyDiscoverTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyDiscoverTest.java Mon Mar 15 17:35:58 2010
@@ -47,7 +47,7 @@ public class ReadOnlyDiscoverTest extend
       ReadOnlyDiscoverTest.log.info("queries not supported");
       break;
     default:
-      PagingList<QueryResult> resultSet = this.session.query(Fixture.QUERY, false, -1);
+      PagingList<QueryResult> resultSet = this.session.query(FixtureData.QUERY.toString(), false, -1);
       Assert.assertNotNull(resultSet);
       //Assert.assertFalse(resultSet.isEmpty());
       for (List<QueryResult> lo : resultSet) {

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyNavigationTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyNavigationTest.java?rev=923360&r1=923359&r2=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyNavigationTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyNavigationTest.java Mon Mar 15 17:35:58 2010
@@ -29,70 +29,163 @@ import org.apache.opencmis.client.api.ut
 import org.apache.opencmis.client.api.util.PagingList;
 import org.junit.Test;
 
-import sun.reflect.generics.tree.Tree;
-
 public class ReadOnlyNavigationTest extends AbstractSessionTest {
 
-  @Test
-  public void navigateChildren() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
-    Folder folder = (Folder) this.session.getObjectByPath(path);
-    Assert.assertNotNull("folder not found: " + path, folder);
-
-    PagingList<CmisObject> pl = folder.getChildren(null, -1);
-    Assert.assertNotNull(pl);
-    //Assert.assertFalse(pl.isEmpty());
-
-    for (List<CmisObject> cl : pl) {
-      for (CmisObject o : cl) {
-        Assert.assertNotNull(o);
-      }
-    }
-  }
-
-  @Test
-  public void navigateDescendants() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
-    Folder folder = (Folder) this.session.getObjectByPath(path);
-    Assert.assertNotNull("folder not found: " + path, folder);
-
-    List<Container<FileableCmisObject>> desc = folder.getDescendants(-1);
-    Assert.assertNotNull(desc);
-    Assert.assertFalse(desc.isEmpty());
-
-    for (Container<FileableCmisObject> o : desc) {
-      Assert.assertNotNull(o);
-      Assert.assertNotNull(o.getItem());
-    }
-  }
-
-  @Test
-  public void navigateTree() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
-    Folder folder = (Folder) this.session.getObjectByPath(path);
-    Assert.assertNotNull("folder not found: " + path, folder);
-
-    List<Container<FileableCmisObject>> tree = folder.getFolderTree(-1);
-    Assert.assertNotNull(tree);
-    Assert.assertFalse(tree.isEmpty());
-
-    for (Container<FileableCmisObject> o : tree) {
-      Assert.assertNotNull(o);
-      Assert.assertNotNull(o.getItem());
-    }
-  }
-
-  @Test
-  public void navigatePagingRandom() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
-    Folder folder = (Folder) this.session.getObjectByPath(path);
-    Assert.assertNotNull("folder not found: " + path, folder);
-
-    PagingList<CmisObject> pl = folder.getChildren(null, -1);
-    Assert.assertNotNull(pl);
-    //Assert.assertFalse(pl.isEmpty());
-
-    List<CmisObject> firstPage = pl.get(0);
-    Assert.assertNotNull(firstPage);
-  }
+	@Test
+	public void navigateChildrenMin() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		PagingList<CmisObject> pl = folder.getChildren(1);
+		Assert.assertNotNull(pl);
+		// Assert.assertFalse(pl.isEmpty());
+
+		for (List<CmisObject> cl : pl) {
+			for (CmisObject o : cl) {
+				Assert.assertNotNull(o);
+			}
+		}
+	}
+
+	@Test
+	public void navigateChildrenMax() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		PagingList<CmisObject> pl = folder.getChildren(1000);
+		Assert.assertNotNull(pl);
+		// Assert.assertFalse(pl.isEmpty());
+
+		for (List<CmisObject> cl : pl) {
+			for (CmisObject o : cl) {
+				Assert.assertNotNull(o);
+			}
+		}
+	}
+
+	@Test
+	public void navigateChildrenMed() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		PagingList<CmisObject> pl = folder.getChildren(2);
+		Assert.assertNotNull(pl);
+		// Assert.assertFalse(pl.isEmpty());
+
+		for (List<CmisObject> cl : pl) {
+			for (CmisObject o : cl) {
+				Assert.assertNotNull(o);
+			}
+		}
+	}
+
+	
+	@Test
+	public void navigateDescendantsMin() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		List<Container<FileableCmisObject>> desc = folder.getDescendants(1);
+		Assert.assertNotNull(desc);
+		Assert.assertFalse(desc.isEmpty());
+
+		for (Container<FileableCmisObject> o : desc) {
+			Assert.assertNotNull(o);
+			Assert.assertNotNull(o.getItem());
+		}
+	}
+	@Test
+	public void navigateDescendantsMax() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		List<Container<FileableCmisObject>> desc = folder.getDescendants(1000);
+		Assert.assertNotNull(desc);
+		Assert.assertFalse(desc.isEmpty());
+
+		for (Container<FileableCmisObject> o : desc) {
+			Assert.assertNotNull(o);
+			Assert.assertNotNull(o.getItem());
+		}
+	}
+	@Test
+	public void navigateDescendantsMed() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		List<Container<FileableCmisObject>> desc = folder.getDescendants(2);
+		Assert.assertNotNull(desc);
+		Assert.assertFalse(desc.isEmpty());
+
+		for (Container<FileableCmisObject> o : desc) {
+			Assert.assertNotNull(o);
+			Assert.assertNotNull(o.getItem());
+		}
+	}
+
+	@Test
+	public void navigateTreeMed() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		List<Container<FileableCmisObject>> tree = folder.getFolderTree(2);
+		Assert.assertNotNull(tree);
+		Assert.assertFalse(tree.isEmpty());
+
+		for (Container<FileableCmisObject> o : tree) {
+			Assert.assertNotNull(o);
+			Assert.assertNotNull(o.getItem());
+		}
+	}
+	@Test
+	public void navigateTreeMin() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		List<Container<FileableCmisObject>> tree = folder.getFolderTree(1);
+		Assert.assertNotNull(tree);
+		Assert.assertFalse(tree.isEmpty());
+
+		for (Container<FileableCmisObject> o : tree) {
+			Assert.assertNotNull(o);
+			Assert.assertNotNull(o.getItem());
+		}
+	}
+	@Test
+	public void navigateTreeMax() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		List<Container<FileableCmisObject>> tree = folder.getFolderTree(1000);
+		Assert.assertNotNull(tree);
+		Assert.assertFalse(tree.isEmpty());
+
+		for (Container<FileableCmisObject> o : tree) {
+			Assert.assertNotNull(o);
+			Assert.assertNotNull(o.getItem());
+		}
+	}
+
+	@Test
+	public void navigatePagingRandom() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		PagingList<CmisObject> pl = folder.getChildren(2);
+		Assert.assertNotNull(pl);
+		// Assert.assertFalse(pl.isEmpty());
+
+		List<CmisObject> firstPage = pl.get(0);
+		Assert.assertNotNull(firstPage);
+	}
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyObjectTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyObjectTest.java?rev=923360&r1=923359&r2=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyObjectTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyObjectTest.java Mon Mar 15 17:35:58 2010
@@ -44,17 +44,11 @@ public class ReadOnlyObjectTest extends 
     Folder root = this.session.getRootFolder();
     Assert.assertNotNull(root);
 
-    Assert.assertEquals("", root.getName());
+    root.getName();
     Assert.assertNotNull(root.getId());
     Assert.assertNull(root.getFolderParent());
     Assert.assertNotNull(root.getType());
-    Assert.assertEquals(Fixture.FOLDER_TYPE_ID, root.getType().getId());
-
-    Assert.assertEquals("", root.getName());
-    Assert.assertNotNull(root.getId());
-    Assert.assertNull(root.getFolderParent());
-    Assert.assertNotNull(root.getType());
-    Assert.assertEquals(Fixture.FOLDER_TYPE_ID, root.getType().getId());
+    Assert.assertEquals(FixtureData.FOLDER_TYPE_ID.toString(), root.getType().getId());
   }
 
   @Test
@@ -67,7 +61,7 @@ public class ReadOnlyObjectTest extends 
     Assert.assertNotNull(folder.getId());
     Assert.assertNotNull(folder.getFolderParent());
     Assert.assertNotNull(folder.getType());
-    Assert.assertEquals(Fixture.FOLDER_TYPE_ID, folder.getType().getId());
+    Assert.assertEquals(FixtureData.FOLDER_TYPE_ID.toString(), folder.getType().getId());
     Assert.assertNotNull(folder.getBaseType());
     Assert.assertEquals(ObjectType.FOLDER_BASETYPE_ID, folder.getBaseType().getId());
 
@@ -83,21 +77,20 @@ public class ReadOnlyObjectTest extends 
 
   @Test
   public void readTestDocument() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.DOCUMENT1_NAME;
+    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + FixtureData.DOCUMENT1_NAME;
     Document document = (Document) this.session.getObjectByPath(path);
     Assert.assertNotNull("document not found: " + path, document);
 
     Assert.assertNotNull(document.getId());
     Assert.assertNotNull(document.getBaseType());
     Assert.assertEquals(ObjectType.DOCUMENT_BASETYPE_ID, document.getBaseType().getId());
-    Assert.assertEquals(Fixture.DOCUMENT1_NAME, document.getName());
+    Assert.assertEquals(FixtureData.DOCUMENT1_NAME.toString(), document.getName());
     Assert.assertNotNull(document.getType());
-    Assert.assertEquals(Fixture.DOCUMENT_TYPE_ID, document.getType().getId());
-
+    Assert.assertEquals(FixtureData.DOCUMENT_TYPE_ID.toString(), document.getType().getId());
   }
 
   public void readDocumentDefaultProperties() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.DOCUMENT1_NAME;
+    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + FixtureData.DOCUMENT1_NAME;
     Document document = (Document) this.session.getObjectByPath(path);
     Assert.assertNotNull("document not found: " + path, document);
 
@@ -112,7 +105,7 @@ public class ReadOnlyObjectTest extends 
 
   @Test
   public void readDocumentPropertiesWithFilter() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.DOCUMENT1_NAME;
+    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + FixtureData.DOCUMENT1_NAME;
     Document document = (Document) this.session.getObjectByPath(path);
     Assert.assertNotNull("document not found: " + path, document);
 
@@ -187,7 +180,7 @@ public class ReadOnlyObjectTest extends 
 
   @Test
   public void readDocumentProperties() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.DOCUMENT1_NAME;
+    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + FixtureData.DOCUMENT1_NAME;
     Document document = (Document) this.session.getObjectByPath(path);
     Assert.assertNotNull("document not found: " + path, document);
 
@@ -261,7 +254,7 @@ public class ReadOnlyObjectTest extends 
 
   @Test
   public void readSingleProperty() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.DOCUMENT1_NAME;
+    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + FixtureData.DOCUMENT1_NAME;
     Document document = (Document) this.session.getObjectByPath(path);
     Assert.assertNotNull("document not found: " + path, document);
 
@@ -278,7 +271,7 @@ public class ReadOnlyObjectTest extends 
 
   @Test
   public void readMultiValueProperty() {
-    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.DOCUMENT1_NAME;
+    String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/" + FixtureData.DOCUMENT1_NAME;
     Document document = (Document) this.session.getObjectByPath(path);
     Assert.assertNotNull("document not found: " + path, document);
 

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyTypeTest.java?rev=923360&r1=923359&r2=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyTypeTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlyTypeTest.java Mon Mar 15 17:35:58 2010
@@ -29,93 +29,114 @@ import org.apache.opencmis.client.api.ob
 import org.apache.opencmis.client.api.objecttype.RelationshipType;
 import org.apache.opencmis.client.api.util.Container;
 import org.apache.opencmis.client.api.util.PagingList;
+import org.apache.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.junit.Test;
 
 public class ReadOnlyTypeTest extends AbstractSessionTest {
 
-  @Test
-  public void readBaseTypePolicy() {
-    ObjectType otd = this.session.getTypeDefinition(ObjectType.POLICY_BASETYPE_ID);
-    Assert.assertNotNull(otd);
-    Assert.assertTrue(otd instanceof PolicyType);
-    Assert.assertEquals(ObjectType.POLICY_BASETYPE_ID, otd.getId());
-    Assert.assertEquals(null, otd.getBaseType());
-  }
-
-  @Test
-  public void readBaseTypeRelation() {
-    ObjectType otd = this.session.getTypeDefinition(ObjectType.RELATIONSHIP_BASETYPE_ID);
-    Assert.assertNotNull(otd);
-    Assert.assertTrue(otd instanceof RelationshipType);
-    Assert.assertEquals(ObjectType.RELATIONSHIP_BASETYPE_ID, otd.getId());
-    Assert.assertEquals(null, otd.getBaseType());
-  }
-
-  @Test
-  public void readBaseTypeDocument() {
-    ObjectType otd = this.session.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID);
-    Assert.assertNotNull(otd);
-    Assert.assertTrue(otd instanceof DocumentType);
-    Assert.assertEquals(ObjectType.DOCUMENT_BASETYPE_ID, otd.getId());
-    Assert.assertEquals(null, otd.getBaseType());
-
-  }
-
-  @Test
-  public void readBaseTypeFolder() {
-    ObjectType otf = this.session.getTypeDefinition(ObjectType.FOLDER_BASETYPE_ID);
-    Assert.assertNotNull(otf);
-    Assert.assertTrue(otf instanceof FolderType);
-    Assert.assertEquals(ObjectType.FOLDER_BASETYPE_ID, otf.getId());
-    Assert.assertEquals(null, otf.getBaseType());
-  }
-
-  @Test
-  public void readTypeChildrenDocument() {
-    ObjectType otd = this.session.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID);
-    Assert.assertNotNull(otd);
-    PagingList<ObjectType> pc = this.session.getTypeChildren(otd.getId(), true, -1);
-    Assert.assertNotNull(pc);
-
-    for (List<ObjectType> children : pc) {
-      for (ObjectType ot1 : children) {
-        ObjectType ot2 = this.session.getTypeDefinition(ot1.getId());
-        Assert.assertEquals(ot1, ot2);
-      }
-    }
-  }
-
-  @Test
-  public void readTypeChildrenFolder() {
-    ObjectType otd = this.session.getTypeDefinition(ObjectType.FOLDER_BASETYPE_ID);
-    Assert.assertNotNull(otd);
-    PagingList<ObjectType> pc = this.session.getTypeChildren(otd.getId(), true, -1);
-    Assert.assertNotNull(pc);
-
-    for (List<ObjectType> children : pc) {
-      for (ObjectType ot1 : children) {
-        ObjectType ot2 = this.session.getTypeDefinition(ot1.getId());
-        Assert.assertEquals(ot1, ot2);
-      }
-    }
-  }
-
-  @Test
-  public void readTypeDescandantsDocument() {
-    ObjectType otd = this.session.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID);
-    Assert.assertNotNull(otd);
-    List<Container<ObjectType>> desc = this.session.getTypeDescendants(otd.getId(), 1, true);
-    Assert.assertNotNull(desc);
-    Assert.assertFalse(desc.isEmpty());
-  }
-
-  @Test
-  public void readTypeDescandantsFolder() {
-    ObjectType otd = this.session.getTypeDefinition(ObjectType.FOLDER_BASETYPE_ID);
-    Assert.assertNotNull(otd);
-    List<Container<ObjectType>> desc = this.session.getTypeDescendants(otd.getId(), 1, true);
-    Assert.assertNotNull(desc);
-    Assert.assertFalse(desc.isEmpty());
-  }
+	@Test
+	public void readOptionalBaseTypePolicy() {
+		try {
+			ObjectType otd = this.session
+					.getTypeDefinition(ObjectType.POLICY_BASETYPE_ID);
+			Assert.assertTrue(otd instanceof PolicyType);
+			Assert.assertEquals(ObjectType.POLICY_BASETYPE_ID, otd.getId());
+			Assert.assertEquals(null, otd.getBaseType());
+		} catch (CmisObjectNotFoundException e) {
+			// policies not supported
+		}
+	}
+
+	@Test
+	public void readOptionalBaseTypeRelation() {
+		try {
+			ObjectType otd = this.session
+					.getTypeDefinition(ObjectType.RELATIONSHIP_BASETYPE_ID);
+			Assert.assertNotNull(otd);
+			Assert.assertTrue(otd instanceof RelationshipType);
+			Assert.assertEquals(ObjectType.RELATIONSHIP_BASETYPE_ID, otd
+					.getId());
+			Assert.assertEquals(null, otd.getBaseType());
+		} catch (CmisObjectNotFoundException e) {
+			// policies not supported
+		}
+	}
+
+	@Test
+	public void readBaseTypeDocument() {
+		ObjectType otd = this.session
+				.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID);
+		Assert.assertNotNull(otd);
+		Assert.assertTrue(otd instanceof DocumentType);
+		Assert.assertEquals(ObjectType.DOCUMENT_BASETYPE_ID, otd.getId());
+		Assert.assertEquals(null, otd.getBaseType());
+
+	}
+
+	@Test
+	public void readBaseTypeFolder() {
+		ObjectType otf = this.session
+				.getTypeDefinition(ObjectType.FOLDER_BASETYPE_ID);
+		Assert.assertNotNull(otf);
+		Assert.assertTrue(otf instanceof FolderType);
+		Assert.assertEquals(ObjectType.FOLDER_BASETYPE_ID, otf.getId());
+		Assert.assertEquals(null, otf.getBaseType());
+	}
+
+	@Test
+	public void readTypeChildrenDocument() {
+		ObjectType otd = this.session
+				.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID);
+		Assert.assertNotNull(otd);
+		PagingList<ObjectType> pc = this.session.getTypeChildren(otd.getId(),
+				true, 2);
+		Assert.assertNotNull(pc);
+
+		for (List<ObjectType> children : pc) {
+			for (ObjectType ot1 : children) {
+				ObjectType ot2 = this.session.getTypeDefinition(ot1.getId());
+				Assert.assertEquals(ot1, ot2);
+			}
+		}
+	}
+
+	@Test
+	public void readTypeChildrenFolder() {
+		ObjectType otd = this.session
+				.getTypeDefinition(ObjectType.FOLDER_BASETYPE_ID);
+		Assert.assertNotNull(otd);
+		PagingList<ObjectType> pc = this.session.getTypeChildren(otd.getId(),
+				true, 2);
+		Assert.assertNotNull(pc);
+
+		for (List<ObjectType> children : pc) {
+			for (ObjectType ot1 : children) {
+				ObjectType ot2 = this.session.getTypeDefinition(ot1.getId());
+				Assert.assertEquals(ot1, ot2);
+			}
+		}
+	}
+
+	@Test
+	public void readTypeDescandantsDocument() {
+		ObjectType otd = this.session
+				.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID);
+		Assert.assertNotNull(otd);
+		List<Container<ObjectType>> desc = this.session.getTypeDescendants(otd
+				.getId(), 1, true);
+		Assert.assertNotNull(desc);
+		Assert.assertFalse(desc.isEmpty());
+	}
+
+	@Test
+	public void readTypeDescandantsFolder() {
+		ObjectType otd = this.session
+				.getTypeDefinition(ObjectType.FOLDER_BASETYPE_ID);
+		Assert.assertNotNull(otd);
+		List<Container<ObjectType>> desc = this.session.getTypeDescendants(otd
+				.getId(), 1, true);
+		Assert.assertNotNull(desc);
+		Assert.assertFalse(desc.isEmpty());
+	}
 
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/mock/MockSessionFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/mock/MockSessionFactory.java?rev=923360&r1=923359&r2=923360&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/mock/MockSessionFactory.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/mock/MockSessionFactory.java Mon Mar 15 17:35:58 2010
@@ -26,7 +26,6 @@ import java.io.ByteArrayInputStream;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.GregorianCalendar;
@@ -61,6 +60,7 @@ import org.apache.opencmis.client.api.re
 import org.apache.opencmis.client.api.util.Container;
 import org.apache.opencmis.client.api.util.PagingList;
 import org.apache.opencmis.client.runtime.Fixture;
+import org.apache.opencmis.client.runtime.FixtureData;
 import org.apache.opencmis.commons.PropertyIds;
 import org.apache.opencmis.commons.SessionParameter;
 import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
@@ -133,17 +133,16 @@ public class MockSessionFactory implemen
 				this.createMockRepositoryInfo()).anyTimes();
 		expect(session.getRootFolder()).andReturn(rootFolder).anyTimes();
 
-    String id = rootFolder.getId();
-    ObjectId objectId = createMockObjectId(id);
-    expect(session.createObjectId(id)).andReturn(objectId).anyTimes();
+		String id = rootFolder.getId();
+		ObjectId objectId = createMockObjectId(id);
+		expect(session.createObjectId(id)).andReturn(objectId).anyTimes();
 
-		
-		expect(session.getDefaultContext()).andReturn(this.createMockOperationContext())
-				.anyTimes();
+		expect(session.getDefaultContext()).andReturn(
+				this.createMockOperationContext()).anyTimes();
 		expect(session.getLocale()).andReturn(new Locale("EN")).anyTimes();
 		expect(session.getObjectFactory()).andReturn(
 				this.createMockObjectFactory()).anyTimes();
-		
+
 		expect(session.getTypeDefinition(ObjectType.DOCUMENT_BASETYPE_ID))
 				.andReturn(
 						this.idTypeIndex.get(ObjectType.DOCUMENT_BASETYPE_ID))
@@ -159,34 +158,53 @@ public class MockSessionFactory implemen
 						this.idTypeIndex
 								.get(ObjectType.RELATIONSHIP_BASETYPE_ID))
 				.anyTimes();
-		expect(session.getTypeDefinition(Fixture.DOCUMENT_TYPE_ID)).andReturn(
-				this.idTypeIndex.get(Fixture.DOCUMENT_TYPE_ID)).anyTimes();
-		expect(session.getTypeDefinition(Fixture.FOLDER_TYPE_ID)).andReturn(
-				this.idTypeIndex.get(Fixture.FOLDER_TYPE_ID)).anyTimes();
 
+		if (!FixtureData.DOCUMENT_TYPE_ID.toString().equalsIgnoreCase(
+				ObjectType.DOCUMENT_BASETYPE_ID)) {
+			expect(
+					session.getTypeDefinition(FixtureData.DOCUMENT_TYPE_ID
+							.toString())).andReturn(
+					this.idTypeIndex.get(FixtureData.DOCUMENT_TYPE_ID
+							.toString())).anyTimes();
+		}
+		if (!FixtureData.FOLDER_TYPE_ID.toString().equalsIgnoreCase(
+				ObjectType.FOLDER_BASETYPE_ID)) {
+			expect(
+					session.getTypeDefinition(FixtureData.FOLDER_TYPE_ID
+							.toString()))
+					.andReturn(
+							this.idTypeIndex.get(FixtureData.FOLDER_TYPE_ID
+									.toString())).anyTimes();
+		}
 		/* document child/descendants types */
 		List<ObjectType> dtl = new ArrayList<ObjectType>();
-		dtl.add(this.idTypeIndex.get(Fixture.DOCUMENT_TYPE_ID));
+		dtl.add(this.idTypeIndex.get(FixtureData.DOCUMENT_TYPE_ID.toString()));
 		PagingList<ObjectType> plot = this.createMockPaging(dtl);
-		Container<ObjectType> ctdoc = this.createMockContainer(this.idTypeIndex.get(Fixture.DOCUMENT_TYPE_ID), null);
+		Container<ObjectType> ctdoc = this.createMockContainer(this.idTypeIndex
+				.get(FixtureData.DOCUMENT_TYPE_ID.toString()), null);
 		expect(
-				session.getTypeChildren(BaseObjectTypeIds.CMIS_DOCUMENT.value(), true, -1))
-						.andReturn(plot).anyTimes();
+				session.getTypeChildren(
+						BaseObjectTypeIds.CMIS_DOCUMENT.value(), true, 2))
+				.andReturn(plot).anyTimes();
 		expect(
-				session.getTypeDescendants(BaseObjectTypeIds.CMIS_DOCUMENT.value(), 1, true))
-						.andReturn(Collections.singletonList(ctdoc)).anyTimes();
+				session.getTypeDescendants(BaseObjectTypeIds.CMIS_DOCUMENT
+						.value(), 1, true)).andReturn(
+				Collections.singletonList(ctdoc)).anyTimes();
 
 		/* folder child/descendants types */
 		List<ObjectType> ftl = new ArrayList<ObjectType>();
-		ftl.add(this.idTypeIndex.get(Fixture.FOLDER_TYPE_ID));
+		ftl.add(this.idTypeIndex.get(FixtureData.FOLDER_TYPE_ID.toString()));
 		PagingList<ObjectType> plfot = this.createMockPaging(ftl);
-    Container<ObjectType> ctfolder = this.createMockContainer(this.idTypeIndex.get(Fixture.FOLDER_TYPE_ID), null);
+		Container<ObjectType> ctfolder = this.createMockContainer(
+				this.idTypeIndex.get(FixtureData.FOLDER_TYPE_ID.toString()),
+				null);
 		expect(
-				session.getTypeChildren(BaseObjectTypeIds.CMIS_FOLDER.value(), true, -1))
-				    .andReturn(plfot).anyTimes();
+				session.getTypeChildren(BaseObjectTypeIds.CMIS_FOLDER.value(),
+						true, 2)).andReturn(plfot).anyTimes();
 		expect(
-				session.getTypeDescendants(BaseObjectTypeIds.CMIS_FOLDER.value(), 1, true))
-						.andReturn(Collections.singletonList(ctfolder)).anyTimes();
+				session.getTypeDescendants(BaseObjectTypeIds.CMIS_FOLDER
+						.value(), 1, true)).andReturn(
+				Collections.singletonList(ctfolder)).anyTimes();
 
 		/* change support */
 		List<ChangeEvent> cel = this.createMockChangeEvents();
@@ -195,12 +213,12 @@ public class MockSessionFactory implemen
 
 		/* query support */
 		List<QueryResult> queryList = new ArrayList<QueryResult>();
-		for(CmisObject cm :this.idObjectIndex.values()) {
-		  queryList.add(createMockQueryResult(cm));
+		for (CmisObject cm : this.idObjectIndex.values()) {
+			queryList.add(createMockQueryResult(cm));
 		}
 		PagingList<QueryResult> plq = this.createMockPaging(queryList);
-		expect(session.query(Fixture.QUERY, false, -1)).andReturn(plq)
-				.anyTimes();
+		expect(session.query(FixtureData.QUERY.toString(), false, -1))
+				.andReturn(plq).anyTimes();
 
 		this.makeObjectsAccessible(session);
 
@@ -249,17 +267,17 @@ public class MockSessionFactory implemen
 	}
 
 	private ObjectId createMockObjectId(String id) {
-	  ObjectId oid = createNiceMock(ObjectId.class);
-	  
-	  expect(oid.getId()).andReturn(id).anyTimes();
-	  
-	  replay(oid);
-	  
-	  return oid;
+		ObjectId oid = createNiceMock(ObjectId.class);
+
+		expect(oid.getId()).andReturn(id).anyTimes();
+
+		replay(oid);
+
+		return oid;
 	}
-	
+
 	private OperationContext createMockOperationContext() {
-	  OperationContext oc = createNiceMock(OperationContext.class);
+		OperationContext oc = createNiceMock(OperationContext.class);
 
 		replay(oc);
 
@@ -273,34 +291,46 @@ public class MockSessionFactory implemen
 		expect(f.getName()).andReturn(Fixture.TEST_ROOT_FOLDER_NAME).anyTimes();
 		expect(f.getFolderParent()).andReturn(parent).anyTimes();
 		expect(f.getType()).andReturn(
-				this.idTypeIndex.get(Fixture.FOLDER_TYPE_ID)).anyTimes();
+				this.idTypeIndex.get(FixtureData.FOLDER_TYPE_ID.toString()))
+				.anyTimes();
 		expect(f.getBaseType()).andReturn(
 				this.idTypeIndex.get(BaseObjectTypeIds.CMIS_FOLDER.value()))
 				.anyTimes();
 		List<CmisObject> children = new ArrayList<CmisObject>();
 		children.add(this.createMockTestFolder(f, "/"
-				+ Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.FOLDER1_NAME,
-				Fixture.FOLDER1_NAME));
+				+ Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.FOLDER1_NAME.toString(), FixtureData.FOLDER1_NAME
+				.toString()));
 		children.add(this.createMockTestFolder(f, "/"
-				+ Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.FOLDER2_NAME,
-				Fixture.FOLDER2_NAME));
+				+ Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.FOLDER2_NAME.toString(), FixtureData.FOLDER2_NAME
+				.toString()));
 		children.add(this.createMockTestDocument(f, "/"
-				+ Fixture.TEST_ROOT_FOLDER_NAME + "/" + Fixture.DOCUMENT1_NAME,
-				Fixture.DOCUMENT1_NAME));
+				+ Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.DOCUMENT1_NAME.toString(),
+				FixtureData.DOCUMENT1_NAME.toString()));
 
 		PagingList<CmisObject> pl = this.createMockPaging(children);
-		expect(f.getChildren(null, -1)).andReturn(pl).anyTimes();
+		expect(f.getChildren(1)).andReturn(pl).anyTimes();
+		expect(f.getChildren(2)).andReturn(pl).anyTimes();
+		expect(f.getChildren(1000)).andReturn(pl).anyTimes();
 
 		List<Container<FileableCmisObject>> ct = new ArrayList<Container<FileableCmisObject>>();
-		Folder f1 = this.createMockTestFolder(f, "/" + Fixture.FOLDER1_NAME,
-				Fixture.FOLDER1_NAME);
-		Folder f2 = this.createMockTestFolder(f, "/" + Fixture.FOLDER2_NAME,
-				Fixture.FOLDER2_NAME);
+		Folder f1 = this.createMockTestFolder(f, "/"
+				+ FixtureData.FOLDER1_NAME.toString(), FixtureData.FOLDER1_NAME
+				.toString());
+		Folder f2 = this.createMockTestFolder(f, "/"
+				+ FixtureData.FOLDER2_NAME.toString(), FixtureData.FOLDER2_NAME
+				.toString());
 		ct.add(this.createMockContainer((FileableCmisObject) f1, null));
-    ct.add(this.createMockContainer((FileableCmisObject) f2, null));
-		
-		expect(f.getDescendants(-1)).andReturn(ct).anyTimes();
-		expect(f.getFolderTree(-1)).andReturn(ct).anyTimes();
+		ct.add(this.createMockContainer((FileableCmisObject) f2, null));
+
+		expect(f.getDescendants(1)).andReturn(ct).anyTimes();
+		expect(f.getDescendants(2)).andReturn(ct).anyTimes();
+		expect(f.getDescendants(1000)).andReturn(ct).anyTimes();
+		expect(f.getFolderTree(1)).andReturn(ct).anyTimes();
+		expect(f.getFolderTree(2)).andReturn(ct).anyTimes();
+		expect(f.getFolderTree(1000)).andReturn(ct).anyTimes();
 		this.createMockProperties(f);
 
 		replay(f);
@@ -343,8 +373,8 @@ public class MockSessionFactory implemen
 			a.add(this.createMockUriProperty(UUID.randomUUID().toString()));
 
 			expect(o.getProperties()).andReturn(a).anyTimes();
-			//expect(o.getProperties(Fixture.PROPERTY_FILTER)).andReturn(a)
-			//		.anyTimes();
+			// expect(o.getProperties(Fixture.PROPERTY_FILTER)).andReturn(a)
+			// .anyTimes();
 
 			/* single property */
 			Property<Object> p1 = (Property<Object>) createMockStringProperty(CmisProperties.OBJECT_ID
@@ -513,7 +543,8 @@ public class MockSessionFactory implemen
 		expect(d.getId()).andReturn(UUID.randomUUID().toString()).anyTimes();
 		expect(d.getName()).andReturn(name).anyTimes();
 		expect(d.getType()).andReturn(
-				this.idTypeIndex.get(Fixture.DOCUMENT_TYPE_ID)).anyTimes();
+				this.idTypeIndex.get(FixtureData.DOCUMENT_TYPE_ID.toString()))
+				.anyTimes();
 		expect(d.getBaseType()).andReturn(
 				this.idTypeIndex.get(BaseObjectTypeIds.CMIS_DOCUMENT.value()))
 				.anyTimes();
@@ -551,15 +582,18 @@ public class MockSessionFactory implemen
 		expect(f.getName()).andReturn(name).anyTimes();
 		expect(f.getFolderParent()).andReturn(parent).anyTimes();
 		expect(f.getType()).andReturn(
-				this.idTypeIndex.get(Fixture.FOLDER_TYPE_ID)).anyTimes();
+				this.idTypeIndex.get(FixtureData.FOLDER_TYPE_ID.toString()))
+				.anyTimes();
 		expect(f.getBaseType()).andReturn(
 				this.idTypeIndex.get(BaseObjectTypeIds.CMIS_FOLDER.value()))
 				.anyTimes();
 		List<CmisObject> children = new ArrayList<CmisObject>();
 		children.add(this.createMockTestDocument(f, path + "/"
-				+ Fixture.DOCUMENT1_NAME, Fixture.DOCUMENT1_NAME));
+				+ FixtureData.DOCUMENT1_NAME.toString(),
+				FixtureData.DOCUMENT1_NAME.toString()));
 		children.add(this.createMockTestDocument(f, path + "/"
-				+ Fixture.DOCUMENT2_NAME, Fixture.DOCUMENT2_NAME));
+				+ FixtureData.DOCUMENT2_NAME.toString(),
+				FixtureData.DOCUMENT2_NAME.toString()));
 
 		PagingList<CmisObject> pl = this.createMockPaging(children);
 		expect(f.getChildren(null, -1)).andReturn(pl).anyTimes();
@@ -576,12 +610,11 @@ public class MockSessionFactory implemen
 	}
 
 	private QueryResult createMockQueryResult(CmisObject cmisObject) {
-	  QueryResult qr = createNiceMock(QueryResult.class);
-  
-	  return qr;
+		QueryResult qr = createNiceMock(QueryResult.class);
+
+		return qr;
 	}
-	
-	
+
 	@SuppressWarnings( { "unchecked" })
 	private <T> PagingList<T> createMockPaging(List<T> items) {
 		PagingList<T> pl = createNiceMock(PagingList.class);
@@ -591,7 +624,7 @@ public class MockSessionFactory implemen
 		Iterator<List<T>> i = a.iterator();
 
 		expect(pl.get(0)).andReturn(items).anyTimes();
-		//expect(pl.isEmpty()).andReturn(false).anyTimes();
+		// expect(pl.isEmpty()).andReturn(false).anyTimes();
 		expect(pl.iterator()).andReturn(i).anyTimes();
 
 		replay(pl);
@@ -599,18 +632,19 @@ public class MockSessionFactory implemen
 		return pl;
 	}
 
-  @SuppressWarnings("unchecked")
-  private <T> Container<T> createMockContainer(T item, List<Container<T>> children) {
-    Container<T> c = createNiceMock(Container.class);
-	  
-	  expect(c.getItem()).andReturn(item).anyTimes();
-	  expect(c.getChildren()).andReturn(children).anyTimes();
-	  
-	  replay(c);
-	  
-	  return c;
+	@SuppressWarnings("unchecked")
+	private <T> Container<T> createMockContainer(T item,
+			List<Container<T>> children) {
+		Container<T> c = createNiceMock(Container.class);
+
+		expect(c.getItem()).andReturn(item).anyTimes();
+		expect(c.getChildren()).andReturn(children).anyTimes();
+
+		replay(c);
+
+		return c;
 	}
-	
+
 	private void createMockGlobalTypes() {
 		FolderType bft = createNiceMock(FolderType.class);
 		expect(bft.getId()).andReturn(ObjectType.FOLDER_BASETYPE_ID).anyTimes();
@@ -618,7 +652,8 @@ public class MockSessionFactory implemen
 		expect(bft.getBaseType()).andReturn(null).anyTimes();
 
 		FolderType ft = createNiceMock(FolderType.class);
-		expect(ft.getId()).andReturn(Fixture.FOLDER_TYPE_ID).anyTimes();
+		expect(ft.getId()).andReturn(FixtureData.FOLDER_TYPE_ID.toString())
+				.anyTimes();
 		expect(ft.isBaseType()).andReturn(false);
 		expect(ft.getBaseType()).andReturn(bft).anyTimes();
 
@@ -640,7 +675,8 @@ public class MockSessionFactory implemen
 		expect(bdt.getBaseType()).andReturn(null).anyTimes();
 
 		DocumentType dt = createNiceMock(DocumentType.class);
-		expect(dt.getId()).andReturn(Fixture.DOCUMENT_TYPE_ID).anyTimes();
+		expect(dt.getId()).andReturn(FixtureData.DOCUMENT_TYPE_ID.toString())
+				.anyTimes();
 		expect(dt.isBaseType()).andReturn(false);
 		expect(dt.getBaseType()).andReturn(bft).anyTimes();
 
@@ -651,10 +687,12 @@ public class MockSessionFactory implemen
 		replay(bpt);
 		replay(brt);
 
-		this.idTypeIndex.put(bft.getId(), bft);
 		this.idTypeIndex.put(ft.getId(), ft);
-		this.idTypeIndex.put(bdt.getId(), bdt);
+		this.idTypeIndex.put(bft.getId(), bft); // can overwrite ft
+
 		this.idTypeIndex.put(dt.getId(), dt);
+		this.idTypeIndex.put(bdt.getId(), bdt); // can overwrite dt
+
 		this.idTypeIndex.put(bpt.getId(), bpt);
 		this.idTypeIndex.put(brt.getId(), brt);
 
@@ -667,7 +705,8 @@ public class MockSessionFactory implemen
 		expect(f.getName()).andReturn("").anyTimes(); // or "root" ?
 		expect(f.getFolderParent()).andReturn(null).anyTimes();
 		expect(f.getType()).andReturn(
-				this.idTypeIndex.get(Fixture.FOLDER_TYPE_ID)).anyTimes();
+				this.idTypeIndex.get(FixtureData.FOLDER_TYPE_ID.toString()))
+				.anyTimes();
 		this.createMockProperties(f);
 
 		replay(f);
@@ -739,8 +778,8 @@ public class MockSessionFactory implemen
 	private interface BooleanProperty extends Property<Boolean> {
 	}
 
-  public List<Repository> getRepositories(Map<String, String> parameters) {
-    return null;
-  }
+	public List<Repository> getRepositories(Map<String, String> parameters) {
+		return null;
+	}
 
 }



Mime
View raw message