chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sklev...@apache.org
Subject svn commit: r927962 [3/4] - in /incubator/chemistry/trunk/opencmis: opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/misc/ openc...
Date Fri, 26 Mar 2010 16:48:29 GMT
Modified: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/pom.xml?rev=927962&r1=927961&r2=927962&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/pom.xml (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/pom.xml Fri Mar 26 16:48:27 2010
@@ -114,7 +114,7 @@
       </plugin>
     </plugins>
   </build>
-  
+
   <reporting>
     <plugins>
       <plugin>
@@ -166,4 +166,31 @@
       <type>war</type>
     </dependency>
   </dependencies>
+	<profiles>
+		<profile>
+			<!--
+				call mvn test
+				-Dorg.apache.opencmis.fit.runtime.config.path=myServer.properties
+				to run test using profile parameters
+			-->
+			<activation>
+				<property>
+					<name>org.apache.opencmis.fit.runtime.config.path</name>
+				</property>
+			</activation>
+			<build>
+				<pluginManagement>
+					<plugins>
+						<plugin>
+							<groupId>org.apache.maven.plugins</groupId>
+							<artifactId>maven-surefire-plugin</artifactId>
+							<configuration>
+								<argLine>-Dorg.apache.opencmis.fit.runtime.config.path=${org.apache.opencmis.fit.runtime.config.path}</argLine>
+							</configuration>
+						</plugin>
+					</plugins>
+				</pluginManagement>
+			</build>
+		</profile>
+	</profiles>
 </project>
\ No newline at end of file

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/AbstractSessionTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/AbstractSessionTest.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/AbstractSessionTest.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/AbstractSessionTest.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,93 @@
+/*
+ * 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.fit.runtime;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.opencmis.client.api.Session;
+import org.apache.opencmis.client.api.SessionFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.MethodRule;
+import org.junit.rules.TestWatchman;
+import org.junit.runners.model.FrameworkMethod;
+
+/**
+ * Create a OpenCMIS test session based on fixture parameter.
+ */
+public abstract class AbstractSessionTest {
+
+  protected Log log = LogFactory.getLog(this.getClass());
+
+  /**
+   * trace each junit error
+   */
+  @Rule
+  public MethodRule watch = new TestWatchman() {
+    @Override
+    public void failed(Throwable e, FrameworkMethod method) {
+      super.failed(e, method);
+      AbstractSessionTest.this.log.error(method.getName(), e);
+    }
+  };
+
+  @BeforeClass
+  public static void classSetup() {
+    AbstractSessionTest.initializeLogging();
+    Fixture.logHeader();
+  }
+
+  /**
+   * Initialize logging support.
+   */
+  private static void initializeLogging() {
+    Properties p = new Properties();
+    try {
+      p.load(AbstractSessionTest.class.getResourceAsStream("/log4j.properties"));
+    }
+    catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+    PropertyConfigurator.configure(p);
+  }
+
+  /**
+   * test session
+   */
+  protected Session session = null;
+
+  @Before
+  public void setUp() throws Exception {
+    SessionFactory factory = Fixture.getSessionFactory();
+    this.session = factory.createSession(Fixture.getParamter());
+    Fixture.setUpTestData(this.session);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    Fixture.teardownTestData(this.session);
+  }
+
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/Fixture.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/Fixture.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/Fixture.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/Fixture.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,211 @@
+/*
+ * 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.fit.runtime;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.Map.Entry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.client.api.Session;
+import org.apache.opencmis.client.api.SessionFactory;
+import org.apache.opencmis.client.runtime.SessionFactoryImpl;
+import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
+
+/**
+ * Definition of unit environment for running test cases. Default implementation
+ * supports InMemory binding of OpenCMIS which can be used for stand alone test
+ * cases. Within test unit suite it is possible to overwrite the fixture.
+ * 
+ */
+public class Fixture {
+
+	private static String CONNECTION_PATH = Fixture.CONNECTION_ATOM_PATH;
+	private static final String CONNECTION_ATOM_PATH = "/inmemory.atom.properties";
+	private static final String CONNECTION_WS_PATH = "/inmemory.ws.properties";
+
+	private static Log log = LogFactory.getLog(Fixture.class);
+
+	/*
+	 * general
+	 */
+	public static String TEST_ROOT_FOLDER_NAME = "fit_"
+			+ UUID.randomUUID().toString();
+
+	/*
+	 * test data setup
+	 */
+	private static FixtureSetup testData = new FixtureSetup();
+
+	/**
+	 * @return session parameter
+	 */
+	public static Map<String, String> getParamter() {
+		return parameter;
+	}
+
+	/**
+	 * Overwriting default session parameter.
+	 * 
+	 * @param paramter
+	 */
+	public static void setParamter(Map<String, String> paramter) {
+		FixtureData.changeValues(paramter);
+		Fixture.parameter = paramter;
+	}
+
+	/**
+	 * session parameter.
+	 */
+	private static Map<String, String> parameter = null;
+
+	/**
+	 * Overwriting default session factory.
+	 * 
+	 * @param factory
+	 */
+	public static void setSessionFactory(SessionFactory factory) {
+		Fixture.factory = factory;
+	}
+
+	/**
+	 * @return factory
+	 */
+	public static SessionFactory getSessionFactory() {
+		return Fixture.factory;
+	}
+
+	/**
+	 * factory
+	 */
+	private static SessionFactory factory = null;
+
+	static {
+		// Mock as default
+		Fixture.init();
+	}
+
+	public static void init() {
+		/* get optional path from system properties */
+		String pathname = System
+				.getProperty(FixtureSessionParameter.CONFIG_PATH);
+		pathname = (pathname != null) ? pathname.trim() : null;
+		Properties properties = null;
+		Map<String, String> sessionParameter = null;
+		SessionFactory factory = null;
+		String factoryClassName = null;
+		try {
+			if (pathname != null && !"".equalsIgnoreCase(pathname)) {
+				// read from file
+				properties = new Properties();
+				FileInputStream in = new FileInputStream(new File(pathname));
+				properties.load(in);
+			} else {
+				// get default settings
+				InputStream in = Fixture.class
+						.getResourceAsStream(Fixture.CONNECTION_PATH);
+				properties = new Properties();
+				properties.load(in);
+			}
+
+			/* convert to map, filter empty values */
+			sessionParameter = new Hashtable<String, String>();
+			for (Entry<Object, Object> se : properties.entrySet()) {
+				String key = (String) se.getKey();
+				String value = ((String) se.getValue()).trim();
+				if (value != null && !"".equalsIgnoreCase(value)) {
+					sessionParameter.put(key, value);
+				}
+			}
+			Fixture.setParamter(sessionParameter);
+
+			/* load factory class */
+			factoryClassName = sessionParameter
+					.get(FixtureSessionParameter.SESSION_FACTORY);
+			if (factoryClassName != null
+					&& !"".equalsIgnoreCase(factoryClassName)) {
+				Class<?> clazz = Class.forName(factoryClassName);
+				factory = (SessionFactory) clazz.newInstance();
+			} else {
+				/* default */
+				factory = SessionFactoryImpl.newInstance();
+			}
+			Fixture.setSessionFactory(factory);
+		} catch (IOException e) {
+			Fixture.log.error(pathname, e);
+			throw new CmisRuntimeException(pathname, e);
+		} catch (Exception e) {
+			Fixture.log.error(factoryClassName, e);
+			throw new CmisRuntimeException(factoryClassName, e);
+		}
+	}
+
+	public static void setUpTestData(Session session) {
+		Fixture.testData.setup();
+	}
+
+	public static void teardownTestData(Session session) {
+		Fixture.testData.teardown();
+	}
+
+	private static boolean isLogged = false;
+
+	public static void logHeader() {
+		if (!Fixture.isLogged) {
+			/*
+			 * log header only once
+			 */
+			Fixture.log
+					.info("---------------------------------------------------------------");
+			Fixture.log
+					.info("--- OpenCMIS FIT Test Suite (1) --------------------------------");
+			Fixture.log
+					.info("---------------------------------------------------------------");
+			Fixture.log.info("config path (prop): "
+					+ System.getProperty(FixtureSessionParameter.CONFIG_PATH));
+			Fixture.log.info("session factory:    "
+					+ Fixture.getSessionFactory().getClass());
+			Fixture.log.info("session parameter:  " + Fixture.getParamter());
+
+			Fixture.log
+					.info("---------------------------------------------------------------");
+
+			Fixture.isLogged = true;
+		}
+	}
+
+	public static void enableAtomPub() {
+		Fixture.CONNECTION_PATH = Fixture.CONNECTION_ATOM_PATH;
+	}
+	
+	public static void enableWebServices() {
+		Fixture.CONNECTION_PATH = Fixture.CONNECTION_WS_PATH;
+	}
+	public static String getTestRootId() {
+		return Fixture.testData.getTestRootId();
+	}
+
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureData.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureData.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureData.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureData.java Fri Mar 26 16:48:27 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.fit.runtime;
+
+import java.util.Map;
+
+public enum FixtureData {
+	FOLDER_TYPE_ID("org.apache.opencmis.fit.runtime.folder.type.id",
+			"cmis:folder"), DOCUMENT_TYPE_ID(
+			"org.apache.opencmis.fit.runtime.document.type.id",
+			"cmis:document"), QUERY(
+			"org.apache.opencmis.fit.runtime.query",
+			"SELECT * FROM cmis:document"), PROPERTY_FILTER(
+			"org.apache.opencmis.fit.runtime.property.filter", "*"), FOLDER1_NAME(
+			"org.apache.opencmis.fit.runtime.folder1.name", "folder1"), FOLDER2_NAME(
+			"org.apache.opencmis.fit.runtime.folder2.name", "folder2"), DOCUMENT1_NAME(
+			"org.apache.opencmis.fit.runtime.document1.name",
+			"document1.txt"), DOCUMENT2_NAME(
+			"org.apache.opencmis.fit.runtime.document2.name",
+			"document2.txt"), 
+			PROPERTY_NAME_STRING_MULTI_VALUED("org.apache.opencmis.fit.runtime.multi.valued.property.name", null);
+			;
+
+	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-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureData.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureSessionParameter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureSessionParameter.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureSessionParameter.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureSessionParameter.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,35 @@
+/*
+ * 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.fit.runtime;
+
+public interface FixtureSessionParameter {
+
+	/*
+	 * session parameter
+	 */
+
+	/**
+	 * CONFIG_PATH is referenced in pom.xml! If you change here then change pom.
+	 */
+	static final String CONFIG_PATH =         "org.apache.opencmis.fit.runtime.config.path";
+
+	static final String SESSION_FACTORY =     "org.apache.opencmis.fit.runtime.session.factory";
+	static final String TEST_ROOT_FOLDER_ID = "org.apache.opencmis.fit.runtime.root.folder.id";
+
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureSetup.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureSetup.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureSetup.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/FixtureSetup.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,113 @@
+/*
+ * 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.fit.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.opencmis.client.provider.factory.CmisProviderFactory;
+import org.apache.opencmis.commons.PropertyIds;
+import org.apache.opencmis.commons.SessionParameter;
+import org.apache.opencmis.commons.enums.UnfileObjects;
+import org.apache.opencmis.commons.provider.CmisProvider;
+import org.apache.opencmis.commons.provider.PropertiesData;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+import org.apache.opencmis.util.repository.ObjectGenerator;
+import org.junit.Assert;
+
+public class FixtureSetup {
+
+	private CmisProvider provider = null;
+	private String rootFolderId = null; // root
+	private String testRootFolderId = null; // test root
+	private String repositoryId = null;
+
+	public void teardown() {
+		this.provider.getObjectService().deleteTree(this.repositoryId,
+				this.testRootFolderId, true, UnfileObjects.DELETE, true, null);
+	}
+
+	public void setup() {
+		this.repositoryId = Fixture.getParamter().get(
+				SessionParameter.REPOSITORY_ID);
+		Assert.assertNotNull(this.repositoryId);
+
+		this.provider = CmisProviderFactory.newInstance().createCmisProvider(
+				Fixture.getParamter());
+		Assert.assertNotNull(this.provider);
+
+		// root folder
+		if (Fixture.getParamter().containsKey(
+				FixtureSessionParameter.TEST_ROOT_FOLDER_ID)) {
+			// test root folder
+			this.rootFolderId = Fixture.getParamter().get(
+					FixtureSessionParameter.TEST_ROOT_FOLDER_ID);
+			Assert.assertNotNull(this.rootFolderId);
+		} else {
+			RepositoryInfoData rid = this.provider.getRepositoryService()
+					.getRepositoryInfo(this.repositoryId, null);
+			Assert.assertNotNull(rid);
+			this.rootFolderId = rid.getRootFolderId();
+			Assert.assertNotNull(this.rootFolderId);
+		}
+
+		// object types
+		String documentTypeId = FixtureData.DOCUMENT_TYPE_ID.value();
+		Assert.assertNotNull(documentTypeId);
+		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, Fixture.TEST_ROOT_FOLDER_NAME));
+		propList.add(this.provider.getObjectFactory().createPropertyIdData(
+				PropertyIds.CMIS_OBJECT_TYPE_ID, folderTypeId));
+
+		PropertiesData properties = this.provider.getObjectFactory()
+				.createPropertiesData(propList);
+
+		this.testRootFolderId = this.provider.getObjectService().createFolder(
+				this.repositoryId, properties, this.rootFolderId, null, null,
+				null, null);
+		Assert.assertNotNull(this.testRootFolderId);
+
+		ObjectGenerator og = new ObjectGenerator(provider.getObjectFactory(),
+				provider.getNavigationService(), provider.getObjectService(),
+				this.repositoryId);
+
+		og.setContentSizeInKB(10);
+		og.setDocumentTypeId(documentTypeId);
+		og.setFolderTypeId(folderTypeId);
+		og.setNumberOfDocumentsToCreatePerFolder(2);
+		og.setDocumentPropertiesToGenerate(new ArrayList<String>());
+		og.setFolderPropertiesToGenerate(new ArrayList<String>());
+
+		og.createFolderHierachy(2, 2, this.testRootFolderId);
+	}
+
+	public String getTestRootId() {
+		if (this.testRootFolderId == null) {
+			this.testRootFolderId = Fixture.TEST_ROOT_FOLDER_NAME;
+		}
+		return this.testRootFolderId;
+	}
+
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyAclCapabilityIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyAclCapabilityIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyAclCapabilityIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyAclCapabilityIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,75 @@
+/*
+ * 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.fit.runtime;
+
+import java.util.List;
+
+import org.apache.opencmis.client.api.AclPermission;
+import org.apache.opencmis.client.api.repository.AclPermissionMapping;
+import org.apache.opencmis.client.api.repository.RepositoryAclCapabilities;
+import org.apache.opencmis.client.api.repository.RepositoryCapabilities;
+import org.apache.opencmis.client.api.repository.RepositoryInfo;
+import org.apache.opencmis.commons.enums.AclPropagation;
+import org.apache.opencmis.commons.enums.CapabilityAcl;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ReadOnlyAclCapabilityIT extends AbstractSessionTest {
+
+  private RepositoryAclCapabilities aclCapabilities = null;
+
+  @Before
+  public void setup() throws Exception {
+    RepositoryInfo r = this.session.getRepositoryInfo();
+    // capabilities
+    RepositoryCapabilities repcap = r.getCapabilities();
+    CapabilityAcl capacl = repcap.getAclSupport();
+
+    if (capacl != CapabilityAcl.NONE) {
+      // acl capabilities
+      this.aclCapabilities = r.getAclCapabilities();
+    }
+
+    Assume.assumeNotNull(this.aclCapabilities);
+  }
+
+  @Test
+  public void repositoryCapabilitiesAclPropagation() {
+    AclPropagation aclprop = this.aclCapabilities.getAclPropagation();
+    switch (aclprop) {
+    case OBJECTONLY:
+      break;
+    case PROPAGATE:
+      break;
+    case REPOSITORYDETERMINED:
+      break;
+    default:
+      Assert.fail("enumeration not supported");
+    }
+  }
+
+  @Test
+  public void repositoryCapabilitiesAclPermissionMapping() {
+    AclPermissionMapping apm = this.aclCapabilities.getAddPolicyObjectPermissions();
+    List<AclPermission> aclps = apm.getPermissions();
+    Assert.assertNotNull(aclps);
+  }
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyContentStreamIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyContentStreamIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyContentStreamIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyContentStreamIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.opencmis.fit.runtime;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import junit.framework.Assert;
+
+import org.apache.opencmis.client.api.ContentStream;
+import org.apache.opencmis.client.api.Document;
+import org.junit.Test;
+
+public class ReadOnlyContentStreamIT extends AbstractSessionTest {
+
+	@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);
+	}
+
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyCreateSessionIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyCreateSessionIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyCreateSessionIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyCreateSessionIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,85 @@
+/*
+ * 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.fit.runtime;
+
+import java.util.Hashtable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.client.api.Session;
+import org.apache.opencmis.client.api.SessionFactory;
+import org.apache.opencmis.client.api.TransientSession;
+import org.apache.opencmis.commons.SessionParameter;
+import org.apache.opencmis.commons.enums.SessionType;
+import org.apache.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Independent session creation test (read only)
+ */
+public class ReadOnlyCreateSessionIT {
+
+  protected Log log = LogFactory.getLog(this.getClass());
+
+  @Before
+  public void setup() {
+  }
+
+  @Test
+  public void createDefaultSession() {
+    SessionFactory factory = Fixture.getSessionFactory();
+
+    Hashtable<String, String> parameter = new Hashtable<String, String>(Fixture.getParamter());
+    parameter.remove(SessionParameter.SESSION_TYPE);
+
+    Session s = factory.createSession(parameter);
+    Assert.assertNotNull(s);
+  }
+
+  @Test
+  public void createPersistentSession() {
+    SessionFactory factory = Fixture.getSessionFactory();
+
+    Hashtable<String, String> parameter = new Hashtable<String, String>(Fixture.getParamter());
+    parameter.put(SessionParameter.SESSION_TYPE, SessionType.PERSISTENT.value());
+
+    Session s = factory.createSession(parameter);
+    Assert.assertNotNull(s);
+  }
+
+  @Test
+  public void createTransientSession() {
+    SessionFactory factory = Fixture.getSessionFactory();
+
+    Hashtable<String, String> parameter = new Hashtable<String, String>(Fixture.getParamter());
+    parameter.put(SessionParameter.SESSION_TYPE, SessionType.TRANSIENT.value());
+
+    try {
+      @SuppressWarnings("unused")
+      TransientSession s = factory.createSession(parameter);
+      Assert
+          .fail("CmisNotSupportedException expected, because Transient Session is not supported yet.");
+    }
+    catch (CmisNotSupportedException e) {
+
+    }
+  }
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyDiscoverIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyDiscoverIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyDiscoverIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyDiscoverIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,73 @@
+/*
+ * 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.fit.runtime;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.client.api.QueryResult;
+import org.apache.opencmis.client.api.util.PagingList;
+import org.apache.opencmis.commons.enums.CapabilityChanges;
+import org.apache.opencmis.commons.enums.CapabilityQuery;
+import org.junit.Test;
+
+public class ReadOnlyDiscoverIT extends AbstractSessionTest {
+
+  private static Log log = LogFactory.getLog(ReadOnlyDiscoverIT.class);
+
+  @Test
+  public void query() {
+    CapabilityQuery query = this.session.getRepositoryInfo().getCapabilities().getQuerySupport();
+
+    switch (query) {
+    case NONE:
+      ReadOnlyDiscoverIT.log.info("queries not supported");
+      break;
+    default:
+      PagingList<QueryResult> resultSet = this.session.query(FixtureData.QUERY.toString(), false, 2);
+      Assert.assertNotNull(resultSet);
+      //Assert.assertFalse(resultSet.isEmpty());
+      for (List<QueryResult> lo : resultSet) {
+        for (QueryResult o : lo) {
+          Assert.assertNotNull(o);
+        }
+      }
+
+      break;
+    }
+
+  }
+
+  @Test
+  public void changes() {
+    CapabilityChanges changes = this.session.getRepositoryInfo().getCapabilities()
+        .getChangesSupport();
+
+    switch (changes) {
+    case NONE:
+      ReadOnlyDiscoverIT.log.info("changes not supported");
+      break;
+    default:
+      break;
+    }
+  }
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyNavigationIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyNavigationIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyNavigationIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyNavigationIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,191 @@
+/*
+ * 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.fit.runtime;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.opencmis.client.api.CmisObject;
+import org.apache.opencmis.client.api.FileableCmisObject;
+import org.apache.opencmis.client.api.Folder;
+import org.apache.opencmis.client.api.util.Container;
+import org.apache.opencmis.client.api.util.PagingList;
+import org.junit.Test;
+
+public class ReadOnlyNavigationIT extends AbstractSessionTest {
+
+	@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);
+	}
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyObjectIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyObjectIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyObjectIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyObjectIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,293 @@
+/*
+ * 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.fit.runtime;
+
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.opencmis.client.api.Document;
+import org.apache.opencmis.client.api.Folder;
+import org.apache.opencmis.client.api.Property;
+import org.apache.opencmis.client.api.objecttype.ObjectType;
+import org.apache.opencmis.commons.SessionParameter;
+import org.apache.opencmis.commons.enums.CmisProperties;
+import org.apache.opencmis.commons.enums.PropertyType;
+import org.junit.Test;
+
+/**
+ * Readonly tests on files and documents
+ */
+public class ReadOnlyObjectIT extends AbstractSessionTest {
+
+	@Test
+	public void verifyRoot() {
+		Folder root = this.session.getRootFolder();
+		Assert.assertNotNull(root);
+
+		root.getName();
+		Assert.assertNotNull(root.getId());
+		Assert.assertNull(root.getFolderParent());
+		Assert.assertNotNull(root.getType());
+		Assert.assertEquals(FixtureData.FOLDER_TYPE_ID.toString(), root
+				.getType().getId());
+	}
+
+	@Test
+	public void readTestFolder() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME;
+		Folder folder = (Folder) this.session.getObjectByPath(path);
+		Assert.assertNotNull("folder not found: " + path, folder);
+
+		Assert.assertEquals(Fixture.TEST_ROOT_FOLDER_NAME, folder.getName());
+		Assert.assertNotNull(folder.getId());
+		Assert.assertNotNull(folder.getFolderParent());
+		Assert.assertNotNull(folder.getType());
+		Assert.assertEquals(FixtureData.FOLDER_TYPE_ID.toString(), folder
+				.getType().getId());
+		Assert.assertNotNull(folder.getBaseType());
+		Assert.assertEquals(ObjectType.FOLDER_BASETYPE_ID, folder.getBaseType()
+				.getId());
+
+		Assert.assertNotNull(folder.getCreatedBy());
+		Assert.assertEquals(Fixture.getParamter().get(SessionParameter.USER),
+				folder.getCreatedBy());
+		Assert.assertNotNull(folder.getLastModifiedBy());
+		Assert.assertEquals(Fixture.getParamter().get(SessionParameter.USER),
+				folder.getLastModifiedBy());
+		Assert.assertNotNull(folder.getLastModificationDate());
+		Assert.assertNotNull(folder.getCreationDate());
+
+	}
+
+	@Test
+	public void readTestDocument() {
+		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(FixtureData.DOCUMENT1_NAME.toString(), document
+				.getName());
+		Assert.assertNotNull(document.getType());
+		Assert.assertEquals(FixtureData.DOCUMENT_TYPE_ID.toString(), document
+				.getType().getId());
+	}
+
+	public void readDocumentDefaultProperties() {
+		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.getCreatedBy());
+		Assert.assertEquals(Fixture.getParamter().get(SessionParameter.USER),
+				document.getCreatedBy());
+		Assert.assertNotNull(document.getLastModifiedBy());
+		Assert.assertEquals(Fixture.getParamter().get(SessionParameter.USER),
+				document.getLastModifiedBy());
+		Assert.assertNotNull(document.getLastModificationDate());
+		Assert.assertNotNull(document.getCreationDate());
+	}
+
+	@Test
+	public void readDocumentPropertiesWithFilter() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.DOCUMENT1_NAME;
+		Document document = (Document) this.session.getObjectByPath(path);
+		Assert.assertNotNull("document not found: " + path, document);
+
+		List<Property<?>> l = document.getProperties();
+		Assert.assertNotNull(l);
+		Assert.assertEquals(false, l.isEmpty());
+		Iterator<Property<?>> i = l.iterator();
+		while (i.hasNext()) {
+			Property<?> p = i.next();
+			Object value = p.getValue();
+			PropertyType t = p.getType();
+
+			Assert.assertNotNull(p);
+			Assert.assertNotNull(t);
+
+			switch (t) {
+			case INTEGER:
+				BigInteger n = (BigInteger) value;
+				Assert.assertNotNull(n);
+				break;
+			case STRING:
+				// String s = (String) value;
+				// can be null Assert.assertNotNull(s);
+				break;
+			case BOOLEAN:
+				Boolean b = (Boolean) value;
+				Assert.assertNotNull(b);
+				break;
+			case DATETIME:
+				Calendar c = (Calendar) value;
+				Assert.assertNotNull(c);
+				break;
+			case DECIMAL:
+				Number num = (Number) value;
+				if (num instanceof Double) {
+					Double d = (Double) num;
+					Assert.assertNotNull(d);
+				} else if (num instanceof Float) {
+					Float f = (Float) num;
+					Assert.assertNotNull(f);
+				} else {
+					Assert.fail("Number not supported: " + num.toString());
+				}
+				break;
+			case HTML:
+				String html = (String) value;
+				Assert.assertNotNull(html);
+				break;
+			case ID:
+				// String id = (String) value;
+				// can be null Assert.assertNotNull(id);
+				break;
+			case URI:
+				URI uri = (URI) value;
+				Assert.assertNotNull(uri);
+				break;
+			default:
+				Assert.fail("PropertyType not supported: " + t);
+			}
+		}
+
+	}
+
+	@Test
+	public void readDocumentProperties() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.DOCUMENT1_NAME;
+		Document document = (Document) this.session.getObjectByPath(path);
+		Assert.assertNotNull("document not found: " + path, document);
+
+		List<Property<?>> l = document.getProperties();
+		Assert.assertNotNull(l);
+		Assert.assertEquals(false, l.isEmpty());
+		Iterator<Property<?>> i = l.iterator();
+		while (i.hasNext()) {
+			Property<?> p = i.next();
+			Object value = p.getValue();
+			PropertyType t = p.getType();
+
+			Assert.assertNotNull(p);
+			Assert.assertNotNull(t);
+
+			switch (t) {
+			case INTEGER:
+				BigInteger n = (BigInteger) value;
+				Assert.assertNotNull(n);
+				break;
+			case STRING:
+				// String s = (String) value;
+				// can be null Assert.assertNotNull(s);
+				break;
+			case BOOLEAN:
+				Boolean b = (Boolean) value;
+				Assert.assertNotNull(b);
+				break;
+			case DATETIME:
+				Calendar c = (Calendar) value;
+				Assert.assertNotNull(c);
+				break;
+			case DECIMAL:
+				Number num = (Number) value;
+				if (num instanceof Double) {
+					Double d = (Double) num;
+					Assert.assertNotNull(d);
+				} else if (num instanceof Float) {
+					Float f = (Float) num;
+					Assert.assertNotNull(f);
+				} else {
+					Assert.fail("Number not supported: " + num.toString());
+				}
+				break;
+			case HTML:
+				String html = (String) value;
+				Assert.assertNotNull(html);
+				break;
+			case ID:
+				// String id = (String) value;
+				// can be null Assert.assertNotNull(id);
+				break;
+			case URI:
+				URI uri = (URI) value;
+				Assert.assertNotNull(uri);
+				break;
+			default:
+				Assert.fail("PropertyType not supported: " + t);
+			}
+		}
+	}
+
+	@Test
+	public void readSingleProperty() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.DOCUMENT1_NAME;
+		Document document = (Document) this.session.getObjectByPath(path);
+		Assert.assertNotNull("document not found: " + path, document);
+
+		Property<String> p = document.getProperty(CmisProperties.OBJECT_ID
+				.value());
+		Assert.assertNotNull(p);
+		String v1 = p.getValue();
+		Assert.assertNotNull(v1);
+
+		String v2 = document.getPropertyValue(CmisProperties.OBJECT_ID.value());
+		Assert.assertNotNull(v2);
+		Assert.assertEquals(v1, v2);
+
+	}
+
+	@Test
+	public void readMultiValueProperty() {
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.DOCUMENT1_NAME;
+		Document document = (Document) this.session.getObjectByPath(path);
+		Assert.assertNotNull("document not found: " + path, document);
+
+		Property<String> p = document
+				.getProperty(FixtureData.PROPERTY_NAME_STRING_MULTI_VALUED
+						.toString());
+		if (p != null) {
+			Assert.assertTrue(p.isMultiValued());
+			List<String> v1 = p.getValues();
+			Assert.assertNotNull(v1);
+			Assert.assertFalse(v1.isEmpty());
+
+			List<String> v2 = document
+					.getPropertyMultivalue(FixtureData.PROPERTY_NAME_STRING_MULTI_VALUED
+							.toString());
+			Assert.assertNotNull(v2);
+			Assert.assertFalse(v2.isEmpty());
+			Assert.assertEquals(v1, v2);
+		}
+	}
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyRepositoryInfoIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyRepositoryInfoIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyRepositoryInfoIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyRepositoryInfoIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,260 @@
+/*
+ * 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.fit.runtime;
+
+import junit.framework.Assert;
+
+import org.apache.opencmis.client.api.repository.RepositoryCapabilities;
+import org.apache.opencmis.client.api.repository.RepositoryInfo;
+import org.apache.opencmis.commons.enums.CapabilityAcl;
+import org.apache.opencmis.commons.enums.CapabilityChanges;
+import org.apache.opencmis.commons.enums.CapabilityContentStreamUpdates;
+import org.apache.opencmis.commons.enums.CapabilityJoin;
+import org.apache.opencmis.commons.enums.CapabilityQuery;
+import org.apache.opencmis.commons.enums.CapabilityRendition;
+import org.junit.Test;
+
+/**
+ * Testing folder and files.
+ */
+public class ReadOnlyRepositoryInfoIT extends AbstractSessionTest {
+
+	@Test
+	public void changesIncomplete() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.changesIncomplete());
+	}
+
+	@Test
+	public void changesOnType() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.getChangesOnType());
+	}
+
+	@Test
+	public void cmisVersionSupported() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.getCmisVersionSupported());
+		this.log.info("getCmisVersionSupported = "
+				+ r.getCmisVersionSupported());
+	}
+
+	@Test
+	public void description() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.getDescription());
+		this.log.info("getDescription = " + r.getDescription());
+	}
+
+	@Test
+	public void id() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.getId());
+		this.log.info("getId = " + r.getId());
+	}
+
+	@Test
+	public void name() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.getName());
+		this.log.info("getName = " + r.getName());
+	}
+
+	@Test
+	public void principalIdAnonymous() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.getPrincipalIdAnonymous());
+		this.log.info("getPrincipalIdAnonymous = "
+				+ r.getPrincipalIdAnonymous());
+	}
+
+	@Test
+	public void principalIdAnyone() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.getPrincipalIdAnyone());
+		this.log.info("getPrincipalIdAnyone = " + r.getPrincipalIdAnyone());
+	}
+
+	@Test
+	public void productName() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.getProductName());
+		this.log.info("getProductName = " + r.getProductName());
+	}
+
+	@Test
+	public void thinClientUri() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		String uri = r.getThinClientUri();
+		this.log.info("getThinClientUri = " + uri);
+	}
+
+	@Test
+	public void vendorName() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+		Assert.assertNotNull(r.getVendorName());
+		this.log.info("getVendorName = " + r.getVendorName());
+	}
+
+	@Test
+	public void repositoryCapabilitiesAclSupport() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+
+		// capabilities
+		RepositoryCapabilities repcap = r.getCapabilities();
+		Assert.assertNotNull(repcap);
+
+		CapabilityAcl capacl = repcap.getAclSupport();
+		Assert.assertNotNull(capacl);
+		switch (capacl) {
+		case DISCOVER:
+		case MANAGE:
+		case NONE:
+			break;
+		default:
+			Assert.fail("enumeration not supported: " + capacl);
+		}
+		this.log.info("CapabilityAcl = " + capacl);
+	}
+
+	@Test
+	public void repositoryCapabilitiesChangesSupport() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+
+		// capabilities
+		RepositoryCapabilities repcap = r.getCapabilities();
+		Assert.assertNotNull(repcap);
+		CapabilityChanges capch = repcap.getChangesSupport();
+		Assert.assertNotNull(capch);
+		switch (capch) {
+		case ALL:
+		case OBJECTIDSONLY:
+		case PROPERTIES:
+		case NONE:
+			break;
+		default:
+			Assert.fail("enumeration not supported: " + capch);
+		}
+		this.log.info("CapabilityChanges = " + capch);
+	}
+
+	@Test
+	public void repositoryCapabilitiesContentStreamUpdateabilitySupport() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+
+		// capabilities
+		RepositoryCapabilities repcap = r.getCapabilities();
+		Assert.assertNotNull(repcap);
+		CapabilityContentStreamUpdates ccsu = repcap
+				.getContentStreamUpdatabilitySupport();
+		Assert.assertNotNull(ccsu);
+		switch (ccsu) {
+		case ANYTIME:
+		case NONE:
+		case PWCONLY:
+			break;
+		default:
+			Assert.fail("enumeration not supported: " + ccsu);
+		}
+		this.log.info("CapabilityContentStreamUpdates = " + ccsu);
+	}
+
+	@Test
+	public void repositoryCapabilitiesJointSupport() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+
+		// capabilities
+		RepositoryCapabilities repcap = r.getCapabilities();
+		Assert.assertNotNull(repcap);
+
+		CapabilityJoin capj = repcap.getJoinSupport();
+		Assert.assertNotNull(capj);
+
+		switch (capj) {
+		case INNERANDOUTER:
+		case INNERONLY:
+		case NONE:
+			break;
+		default:
+			Assert.fail("enumeration not supported: " + capj);
+		}
+		this.log.info("CapabilityJoin = " + capj);
+	}
+
+	@Test
+	public void repositoryCapabilitiesQuerySupport() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+
+		// capabilities
+		RepositoryCapabilities repcap = r.getCapabilities();
+		Assert.assertNotNull(repcap);
+
+		CapabilityQuery capq = repcap.getQuerySupport();
+		Assert.assertNotNull(capq);
+		switch (capq) {
+		case BOTHCOMBINED:
+		case BOTHSEPARATE:
+		case FULLTEXTONLY:
+		case METADATAONLY:
+		case NONE:
+			break;
+		default:
+			Assert.fail("enumeration not supported: " + capq);
+		}
+		this.log.info("CapabilityQuery = " + capq);
+	}
+
+	@Test
+	public void repositoryCapabilitiesRenditionSupport() {
+		RepositoryInfo r = this.session.getRepositoryInfo();
+		Assert.assertNotNull(r);
+
+		// capabilities
+		RepositoryCapabilities repcap = r.getCapabilities();
+		Assert.assertNotNull(repcap);
+
+		CapabilityRendition caprend = repcap.getRenditionsSupport();
+		Assert.assertNotNull(caprend);
+		switch (caprend) {
+		case NONE:
+		case READ:
+			break;
+		default:
+			Assert.fail("enumeration not supported: " + caprend);
+		}
+		this.log.info("CapabilityRendition = " + caprend);
+	}
+
+}
\ No newline at end of file

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlySessionIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlySessionIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlySessionIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlySessionIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,52 @@
+/*
+ * 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.fit.runtime;
+
+import junit.framework.Assert;
+
+import org.apache.opencmis.client.api.Folder;
+import org.junit.Test;
+
+/**
+ * Testing session
+ */
+public class ReadOnlySessionIT extends AbstractSessionTest {
+
+	@Test
+	public void testSession() {
+		Assert.assertNotNull(this.session.getDefaultContext());
+		Assert.assertNotNull(this.session.getLocale());
+		Assert.assertNotNull(this.session.getObjectFactory());
+		Assert.assertNotNull(this.session.getRepositoryInfo());
+	}
+
+	@Test
+	public void testSessionObjectAccess() {
+		Folder root = this.session.getRootFolder();
+		Assert.assertNotNull(root);
+		String id = root.getId();
+		Assert.assertNotNull(id);
+	}
+
+	@Test
+	public void testSessionClear() {
+		this.session.clear();
+	}
+
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyTypeIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyTypeIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyTypeIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/ReadOnlyTypeIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,142 @@
+/*
+ * 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.fit.runtime;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.opencmis.client.api.objecttype.DocumentType;
+import org.apache.opencmis.client.api.objecttype.FolderType;
+import org.apache.opencmis.client.api.objecttype.ObjectType;
+import org.apache.opencmis.client.api.objecttype.PolicyType;
+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 ReadOnlyTypeIT extends AbstractSessionTest {
+
+	@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.getId(), ot2.getId());
+			}
+		}
+	}
+
+	@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);
+		desc.isEmpty();
+	}
+
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/WriteObjectIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/WriteObjectIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/WriteObjectIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/WriteObjectIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,269 @@
+/*
+ * 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.fit.runtime;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.opencmis.client.api.ContentStream;
+import org.apache.opencmis.client.api.Document;
+import org.apache.opencmis.client.api.ObjectId;
+import org.apache.opencmis.client.api.Property;
+import org.apache.opencmis.client.api.objecttype.ObjectType;
+import org.apache.opencmis.commons.api.PropertyDefinition;
+import org.apache.opencmis.commons.enums.CmisProperties;
+import org.apache.opencmis.commons.enums.VersioningState;
+import org.apache.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.junit.Test;
+
+public class WriteObjectIT extends AbstractSessionTest {
+
+	@Test
+	public void createFolder() {
+		ObjectId parentId = this.session
+				.createObjectId(Fixture.getTestRootId());
+		String folderName = UUID.randomUUID().toString();
+		String typeId = FixtureData.FOLDER_TYPE_ID.value();
+
+		ObjectType ot = this.session.getTypeDefinition(typeId);
+		Collection<PropertyDefinition<?>> pdefs = ot.getPropertyDefintions()
+				.values();
+		List<Property<?>> properties = new ArrayList<Property<?>>();
+		Property<?> prop = null;
+
+		for (PropertyDefinition<?> pd : pdefs) {
+			try {
+				CmisProperties cmisp = CmisProperties.fromValue(pd.getId());
+				switch (cmisp) {
+				case NAME:
+					prop = this.session.getObjectFactory().createProperty(pd,
+							folderName);
+					properties.add(prop);
+					break;
+				case OBJECT_TYPE_ID:
+					prop = this.session.getObjectFactory().createProperty(pd,
+							typeId);
+					properties.add(prop);
+					break;
+				default:
+					break;
+				}
+			} catch (Exception e) {
+				// custom property definition
+			}
+
+		}
+
+		ObjectId id = this.session.createFolder(properties, parentId, null,
+				null, null);
+		assertNotNull(id);
+	}
+
+	@Test
+	public void createDocument() throws IOException {
+		ObjectId parentId = this.session
+				.createObjectId(Fixture.getTestRootId());
+		String folderName = UUID.randomUUID().toString();
+		String typeId = FixtureData.DOCUMENT_TYPE_ID.value();
+
+		ObjectType ot = this.session.getTypeDefinition(typeId);
+		Collection<PropertyDefinition<?>> pdefs = ot.getPropertyDefintions()
+				.values();
+		List<Property<?>> properties = new ArrayList<Property<?>>();
+		Property<?> prop = null;
+
+		for (PropertyDefinition<?> pd : pdefs) {
+			try {
+				CmisProperties cmisp = CmisProperties.fromValue(pd.getId());
+				switch (cmisp) {
+				case NAME:
+					prop = this.session.getObjectFactory().createProperty(pd,
+							folderName);
+					properties.add(prop);
+					break;
+				case OBJECT_TYPE_ID:
+					prop = this.session.getObjectFactory().createProperty(pd,
+							typeId);
+					properties.add(prop);
+					break;
+				default:
+					break;
+				}
+			} catch (Exception e) {
+				/*
+				 * custom property definition (note: document type should not
+				 * have further mandatory properties)
+				 */
+				this.log
+						.info(
+								"Custom property found but not supported in test case!",
+								e);
+			}
+		}
+
+		String filename = UUID.randomUUID().toString();
+		String mimetype = "text/html; charset=UTF-8";
+		String content1 = "Im Walde rauscht ein Wasserfall. Wenn's nicht mehr rauscht ist's Wasser all.";
+
+		byte[] buf1 = content1.getBytes("UTF-8");
+		ByteArrayInputStream in1 = new ByteArrayInputStream(buf1);
+		ContentStream contentStream = this.session.getObjectFactory()
+				.createContentStream(filename, buf1.length, mimetype, in1);
+		assertNotNull(contentStream);
+
+		ObjectId id = this.session.createDocument(properties, parentId,
+				contentStream, VersioningState.NONE, null, null, null);
+		assertNotNull(id);
+
+		// verify content 
+		Document doc = (Document) this.session.getObject(id);
+		assertNotNull(doc);
+		// Assert.assertEquals(buf1.length, doc.getContentStreamLength());
+		// Assert.assertEquals(mimetype, doc.getContentStreamMimeType());
+		// Assert.assertEquals(filename, doc.getContentStreamFileName());
+		String content2 = this.getContentAsString(doc.getContentStream());
+		assertEquals(content1, content2);
+	}
+
+	@Test
+	public void createDocumentFromSource() throws IOException {
+		try {
+			// verify content 
+			String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/"
+					+ FixtureData.DOCUMENT1_NAME;
+			Document srcDocument = (Document) this.session
+					.getObjectByPath(path);
+			assertNotNull("Document not found: " + path, srcDocument);
+			String srcContent = this.getContentAsString(srcDocument
+					.getContentStream());
+
+			ObjectId parentFolder = session.createObjectId(Fixture
+					.getTestRootId());
+			List<Property<?>> srcProperties = srcDocument.getProperties();
+			assertNotNull(srcProperties);
+			List<Property<?>> dstProperties = new ArrayList<Property<?>>();
+
+			for (Property<?> p : srcProperties) {
+				if (p.getId().equalsIgnoreCase(CmisProperties.NAME.value())) {
+					// change the name
+					String name = UUID.randomUUID().toString();
+					Property<String> pn = this.session.getObjectFactory()
+							.createProperty(p.getDefinition(), name);
+					dstProperties.add(pn);
+				} else {
+					dstProperties.add(p);
+				}
+			}
+
+			ObjectId dstDocumentId = this.session.createDocumentFromSource(
+					srcDocument, dstProperties, parentFolder,
+					VersioningState.NONE, null, null, null);
+			assertNotNull(dstDocumentId);
+			Document dstDocument = (Document) this.session
+					.getObject(dstDocumentId);
+			String dstContent = this.getContentAsString(dstDocument
+					.getContentStream());
+			assertEquals(srcContent, dstContent);
+
+		} catch (CmisNotSupportedException e) {
+			// not an error
+			this.log.info(e.getMessage());
+		}
+	}
+
+	@Test
+	public void deleteAndCreateContent() throws IOException {
+		// verify content
+
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.DOCUMENT1_NAME;
+		Document document = (Document) this.session.getObjectByPath(path);
+		assertNotNull("Document not found: " + path, document);
+
+		// check default content
+		ContentStream contentStream = document.getContentStream();
+		assertNotNull(contentStream);
+		String contentString = this.getContentAsString(contentStream);
+		assertNotNull(contentString);
+
+		// delete and set new content
+		// ObjectId id = (return id not supported by AtomPub)
+			document.deleteContentStream();
+		// assertNotNull(id);
+
+		String filename = UUID.randomUUID().toString();
+		String mimetype = "text/html; charset=UTF-8";
+		String content1 = "Im Walde rauscht ein Wasserfall. Wenn's nicht mehr rauscht ist's Wasser all.";
+
+		byte[] buf1 = content1.getBytes("UTF-8");
+		ByteArrayInputStream in1 = new ByteArrayInputStream(buf1);
+		contentStream = this.session.getObjectFactory().createContentStream(
+				filename, buf1.length, mimetype, in1);
+		assertNotNull(contentStream);
+
+		document.setContentStream(true, contentStream);
+
+		// check default content
+		ContentStream contentStream2 = document.getContentStream();
+		assertNotNull(contentStream2);
+		String contentString2 = this.getContentAsString(contentStream2);
+		assertNotNull(contentString2);
+
+		assertEquals(content1, contentString2);
+	}
+
+	@Test
+	public void updateProperties() {
+		// verify content
+		String path = "/" + Fixture.TEST_ROOT_FOLDER_NAME + "/"
+				+ FixtureData.DOCUMENT1_NAME;
+		Document document = (Document) this.session.getObjectByPath(path);
+		assertNotNull("Document not found: " + path, document);
+
+		document.setProperty(CmisProperties.NAME.value(), "Neuer Name");
+		document.updateProperties();
+		assertTrue(true);
+	}
+
+	private String getContentAsString(ContentStream stream) throws IOException {
+		assertNotNull(stream);
+		InputStream in2 = stream.getStream();
+		assertNotNull(in2);
+		StringBuffer sbuf = null;
+		sbuf = new StringBuffer(in2.available());
+		int count;
+		byte[] buf2 = new byte[100];
+		while ((count = in2.read(buf2)) != -1) {
+			for (int i = 0; i < count; i++) {
+				sbuf.append((char) buf2[i]);
+			}
+		}
+		in2.close();
+		return sbuf.toString();
+	}
+}

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

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteAtomPubIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteAtomPubIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteAtomPubIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteAtomPubIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,29 @@
+/*
+ * 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.fit.runtime.suite;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses( {} )
+public class SuiteAtomPubIT {
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteAtomPubIT.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteWebServiceIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteWebServiceIT.java?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteWebServiceIT.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteWebServiceIT.java Fri Mar 26 16:48:27 2010
@@ -0,0 +1,32 @@
+/*
+ * 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.fit.runtime.suite;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses( { })
+public class SuiteWebServiceIT {
+	static {
+		// TODO SKL not working 
+		// Fixture.enableWebServices();
+	}
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/runtime/suite/SuiteWebServiceIT.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/resources/inmemory.atom.properties
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/resources/inmemory.atom.properties?rev=927962&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/resources/inmemory.atom.properties (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/resources/inmemory.atom.properties Fri Mar 26 16:48:27 2010
@@ -0,0 +1,22 @@
+org.apache.opencmis.user=test
+org.apache.opencmis.password=test
+
+org.apache.opencmis.provider.binding.type=atompub
+
+org.apache.opencmis.provider.atompub.url=http://localhost:19080/opencmis/atom
+
+org.apache.opencmis.locale.iso639=de 
+org.apache.opencmis.locale.iso3166= 
+org.apache.opencmis.locale.variant= 
+
+org.apache.opencmis.session.type=persistent
+org.apache.opencmis.session.repository.id=test
+
+org.apache.opencmis.fit.runtime.document.type.id=cmis:document
+org.apache.opencmis.fit.runtime.folder.type.id=cmis:folder
+
+org.apache.opencmis.fit.runtime.document1.name=My_Document-0-0
+org.apache.opencmis.fit.runtime.document2.name=My_Document-0-1
+org.apache.opencmis.fit.runtime.folder1.name=My_Folder-0-0
+org.apache.opencmis.fit.runtime.folder2.name=My_Folder-0-1
+

Propchange: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/resources/inmemory.atom.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message