You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by sk...@apache.org on 2010/03/12 18:35:15 UTC
svn commit: r922363 - in
/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime:
Fixture.java ReadOnlySessionTest.java TestDataSetup.java
TestSessionParameter.java
Author: sklevenz
Date: Fri Mar 12 17:35:15 2010
New Revision: 922363
URL: http://svn.apache.org/viewvc?rev=922363&view=rev
Log:
client runtime implementation
- unit test re-factoring after API changes
- setup of test data structure
- unit test improvement
https://issues.apache.org/jira/browse/CMIS-124
Added:
incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestDataSetup.java (with props)
incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestSessionParameter.java (with props)
Modified:
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/ReadOnlySessionTest.java
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=922363&r1=922362&r2=922363&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 Fri Mar 12 17:35:15 2010
@@ -33,9 +33,16 @@ import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.client.api.Folder;
import org.apache.opencmis.client.api.Session;
import org.apache.opencmis.client.api.SessionFactory;
+import org.apache.opencmis.client.provider.factory.CmisProviderFactory;
+import org.apache.opencmis.commons.SessionParameter;
+import org.apache.opencmis.commons.enums.UnfileObjects;
import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.opencmis.commons.provider.CmisProvider;
+import org.apache.opencmis.util.repository.ObjectGenerator;
+import org.junit.Assert;
/**
* Definition of unit environment for running test cases. Default implementation
@@ -89,16 +96,9 @@ public class Fixture {
public static final String PROPERTY_NAME_STRING_MULTI_VALUED = "MultiValuedStringProperty";
/*
- * session parameter
+ * test data setup
*/
- private static final String X_FOLDER_TYPE_ID = "org.apache.opencmis.fixture.folder.type.id";
- private static final String X_DOCUMENT_TYPE_ID = "org.apache.opencmis.fixture.document.type.id";
-
- /*
- * environment
- */
- private static final String CONFIG_PATH = "org.apache.opencmis.client.runtime.suite.config.path";
- private static final String SESSION_FACTORY = "org.apache.opencmis.client.runtime.suite.session.factory";
+ private static TestDataSetup testData = new TestDataSetup();
static {
Fixture.TEST_ROOT_FOLDER_NAME = "test_" + UUID.randomUUID().toString();
@@ -108,7 +108,7 @@ public class Fixture {
* @return session parameter
*/
public static Map<String, String> getParamter() {
- return paramter;
+ return parameter;
}
/**
@@ -117,16 +117,16 @@ public class Fixture {
* @param paramter
*/
public static void setParamter(Map<String, String> paramter) {
- Fixture.paramter = paramter;
+ Fixture.parameter = paramter;
/* overload fixture values */
String value;
- value = Fixture.paramter.get(Fixture.X_DOCUMENT_TYPE_ID);
+ value = Fixture.parameter.get(TestSessionParameter.DOCUMENT_TYPE_ID);
Fixture.DOCUMENT_TYPE_ID = (value != null ? value
: Fixture.DOCUMENT_TYPE_ID);
- value = Fixture.paramter.get(Fixture.X_FOLDER_TYPE_ID);
+ value = Fixture.parameter.get(TestSessionParameter.FOLDER_TYPE_ID);
Fixture.FOLDER_TYPE_ID = (value != null ? value
: Fixture.FOLDER_TYPE_ID);
}
@@ -134,7 +134,7 @@ public class Fixture {
/**
* session parameter.
*/
- private static Map<String, String> paramter = null;
+ private static Map<String, String> parameter = null;
/**
* Overwriting default session factory.
@@ -164,7 +164,7 @@ public class Fixture {
public static void init() {
/* get optional path from system properties */
- String pathname = System.getProperty(Fixture.CONFIG_PATH);
+ String pathname = System.getProperty(TestSessionParameter.CONFIG_PATH);
pathname = (pathname != null) ? pathname.trim() : null;
Properties properties = null;
Map<String, String> sessionParameter = null;
@@ -196,7 +196,8 @@ public class Fixture {
Fixture.setParamter(sessionParameter);
/* load factory class */
- factoryClassName = sessionParameter.get(Fixture.SESSION_FACTORY);
+ factoryClassName = sessionParameter
+ .get(TestSessionParameter.SESSION_FACTORY);
if (factoryClassName != null
&& !"".equalsIgnoreCase(factoryClassName)) {
Class<?> clazz = Class.forName(factoryClassName);
@@ -216,20 +217,11 @@ public class Fixture {
}
public static void setUpTestData(Session session) {
-// if (session instanceof Testable) {
-// Map<String, String> p = new Hashtable<String, String>();
-// p.put(Testable.FOLDER_TYPE_ID_PARAMETER, Fixture.FOLDER_TYPE_ID);
-// p
-// .put(Testable.DOCUMENT_TYPE_ID_PARAMETER,
-// Fixture.DOCUMENT_TYPE_ID);
-// ((Testable) session).generateTestData(p);
-// }
+ Fixture.testData.setup();
}
public static void teardownTestData(Session session) {
-// if (session instanceof Testable) {
-// ((Testable) session).cleanUpTestData();
-// }
+ Fixture.testData.teardown();
}
private static boolean isLogged = false;
@@ -246,7 +238,7 @@ public class Fixture {
Fixture.log
.info("---------------------------------------------------------------");
Fixture.log.info("config path (prop): "
- + System.getProperty(Fixture.CONFIG_PATH));
+ + System.getProperty(TestSessionParameter.CONFIG_PATH));
Fixture.log.info("session factory: "
+ Fixture.getSessionFactory().getClass());
Fixture.log.info("session parameter: " + Fixture.getParamter());
Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlySessionTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlySessionTest.java?rev=922363&r1=922362&r2=922363&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlySessionTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/ReadOnlySessionTest.java Fri Mar 12 17:35:15 2010
@@ -21,7 +21,6 @@ package org.apache.opencmis.client.runti
import junit.framework.Assert;
import org.apache.opencmis.client.api.Folder;
-import org.apache.opencmis.client.api.ObjectId;
import org.junit.Test;
/**
Added: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestDataSetup.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestDataSetup.java?rev=922363&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestDataSetup.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestDataSetup.java Fri Mar 12 17:35:15 2010
@@ -0,0 +1,115 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+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.CmisProperties;
+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.PropertyIdData;
+import org.apache.opencmis.commons.provider.PropertyStringData;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+import org.apache.opencmis.util.repository.ObjectGenerator;
+import org.junit.Assert;
+
+public class TestDataSetup {
+
+ private CmisProvider provider = null;
+ private String rootFolderId = null; // root
+ private String testRootFolderId = null; // test root
+ private String repositoryId = null;
+
+ public void teardown() {
+ if (this.testRootFolderId != null) {
+ 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);
+
+ ObjectGenerator og = new ObjectGenerator(provider.getObjectFactory(),
+ provider.getNavigationService(), provider.getObjectService(),
+ this.repositoryId);
+
+ // root folder
+ if (Fixture.getParamter().containsKey(
+ TestSessionParameter.TEST_ROOT_FOLDER_ID)) {
+ // test root folder
+ this.rootFolderId = Fixture.getParamter().get(
+ TestSessionParameter.TEST_ROOT_FOLDER_ID);
+ Assert.assertNotNull(this.rootFolderId);
+ } else {
+ RepositoryInfoData rid = this.provider.getRepositoryService()
+ .getRepositoryInfo(repositoryId, null);
+ Assert.assertNotNull(rid);
+ this.rootFolderId = rid.getRootFolderId();
+ Assert.assertNotNull(this.rootFolderId);
+ }
+
+ // object types
+ String documentTypeId = Fixture.getParamter().get(
+ TestSessionParameter.DOCUMENT_TYPE_ID);
+ Assert.assertNotNull(documentTypeId);
+ String folderTypeId = Fixture.getParamter().get(
+ TestSessionParameter.FOLDER_TYPE_ID);
+ ;
+ 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()));
+ 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);
+
+ 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);
+
+ }
+}
Propchange: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestDataSetup.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: 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/TestSessionParameter.java?rev=922363&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestSessionParameter.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/test/java/org/apache/opencmis/client/runtime/TestSessionParameter.java Fri Mar 12 17:35:15 2010
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+public interface TestSessionParameter {
+
+ /*
+ * 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
+ */
+ 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/TestSessionParameter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain