chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r912517 [3/3] - in /incubator/chemistry/trunk/opencmis: opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/ opencmis-server/opencmis-server-inmemory/src/main/java/org/apache/opencmis/inmemory/clientprovider/...
Date Mon, 22 Feb 2010 08:58:41 GMT
Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/AbstractServiceTst.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/AbstractServiceTst.java?rev=912517&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/AbstractServiceTst.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/AbstractServiceTst.java Mon Feb 22 08:58:39 2010
@@ -0,0 +1,333 @@
+package org.apache.opencmis.inmemory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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.api.ExtensionsData;
+import org.apache.opencmis.commons.enums.IncludeRelationships;
+import org.apache.opencmis.commons.enums.VersioningState;
+import org.apache.opencmis.commons.impl.dataobjects.ProviderObjectFactoryImpl;
+import org.apache.opencmis.commons.provider.AccessControlList;
+import org.apache.opencmis.commons.provider.CmisProvider;
+import org.apache.opencmis.commons.provider.ContentStreamData;
+import org.apache.opencmis.commons.provider.NavigationService;
+import org.apache.opencmis.commons.provider.ObjectData;
+import org.apache.opencmis.commons.provider.ObjectParentData;
+import org.apache.opencmis.commons.provider.ObjectService;
+import org.apache.opencmis.commons.provider.PropertiesData;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.ProviderObjectFactory;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+import org.apache.opencmis.commons.provider.RepositoryService;
+import org.apache.opencmis.inmemory.RepositoryServiceTest.UnitTestRepositoryInfo;
+import org.apache.opencmis.inmemory.server.RuntimeContext;
+import org.apache.opencmis.inmemory.storedobj.impl.ContentStreamDataImpl;
+
+public class AbstractServiceTst  extends TestCase {
+  private static Log LOG = LogFactory.getLog(AbstractServiceTst.class);
+  protected static final String REPOSITORY_ID = "UnitTestRepository";
+  protected ProviderObjectFactory fFactory = new ProviderObjectFactoryImpl();
+  protected String fRootFolderId;
+  protected String fRepositoryId;
+  protected ObjectService fObjSvc;
+  protected NavigationService fNavSvc;
+  protected RepositoryService fRepSvc;
+  private boolean fUseClientProviderInterface;
+  
+  public AbstractServiceTst() {
+    // The in-memory server unit tests can either be run directly against the
+    // service implementation or against a client provider interface. The client
+    // provider interfaces offers some benefits like type system caching etc
+    // The default is using the direct implementation. Subclasses may override
+    // this behavior
+    fUseClientProviderInterface = false;
+  }
+  
+  protected void setUp(String typeCreatorClassName) throws Exception {
+    LOG.debug("Initializing InMemory Test with type creator class: " + typeCreatorClassName);
+    Map<String, String> parameters = new HashMap<String, String>();
+    parameters.put(SessionParameter.BINDING_SPI_CLASS, CmisProviderFactory.BINDING_SPI_INMEMORY);
+    // attach TypeSystem to the session
+
+    // attach repository info to the session:
+    parameters.put(ConfigConstants.TYPE_CREATOR_CLASS, typeCreatorClassName);
+    parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
+
+    // attach repository info to the session:
+    parameters
+        .put(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS, UnitTestRepositoryInfo.class.getName());
+    
+    // give subclasses a chance to provide additional parameters for special tests
+    addParameters(parameters);
+    
+    if (fUseClientProviderInterface)
+      initializeUsingClientProvider(parameters);
+    else
+      initializeDirect(parameters);
+    
+    assertNotNull(fRepSvc);
+    assertNotNull(fObjSvc);
+    assertNotNull(fNavSvc);
+    
+    RepositoryInfoData rep = fRepSvc.getRepositoryInfo(REPOSITORY_ID, null);
+    fRootFolderId = rep.getRootFolderId();
+    fRepositoryId = rep.getRepositoryId();
+    
+    assertNotNull(fRepositoryId);
+    assertNotNull(fRootFolderId);
+    
+    // Attach the CallContext to a thread local context that can be accessed from everywhere
+    RuntimeContext.getRuntimeConfig().attachCfg(new DummyCallContext());
+  }
+  
+  // Override this method in subclasses if you want to provide additional configuration
+  // parameters. Default implementation is empty
+  protected void addParameters(Map<String, String> parameters) {    
+  }
+
+  protected void setUp() throws Exception {
+    setUp(UnitTestTypeSystemCreator.class.getName());
+  }
+  
+  protected void tearDown() throws Exception {
+  }
+  
+  public void testDummy() {
+    // dummy test to make tools happy that complain if there are no tests available in a test class
+  }
+
+  protected String createFolder(String folderName, String parentFolderId, String typeId) {
+    PropertiesData props = createFolderProperties(folderName, typeId);
+    String id = null;
+    try {
+      id = fObjSvc.createFolder(fRepositoryId, props, parentFolderId, null, null, null, null);
+      if (null == id)
+        fail("createFolder failed.");
+    } catch (Exception e) {
+      fail("createFolder() failed with exception: " + e);
+    }
+    return id;
+  }
+ 
+  protected String createDocument(String name, String folderId, String typeId, boolean withContent) {
+      ContentStreamData contentStream = null;
+    VersioningState versioningState = VersioningState.NONE;
+    List<String> policies = null;
+    AccessControlList addACEs = null;
+    AccessControlList removeACEs = null;
+    ExtensionsData extension = null;
+
+    PropertiesData props = createDocumentProperties(name, typeId);
+
+    if (withContent)
+      contentStream = createContent();
+
+    String id = null;
+    try {
+      id = fObjSvc.createDocument(fRepositoryId, props, folderId, contentStream, versioningState,
+          policies, addACEs, removeACEs, extension);
+      if (null == id)
+        fail("createDocument failed.");
+    } catch (Exception e) {
+      fail("createDocument() failed with exception: " + e);
+    }
+    return id;
+  }
+  
+  protected PropertiesData createDocumentProperties(String name, String typeId) {
+    List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_NAME, name));
+    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID, typeId));
+    PropertiesData props = fFactory.createPropertiesData(properties);
+    return props;
+  }
+  
+  protected PropertiesData createFolderProperties(String folderName, String typeId) {
+    List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_NAME, folderName));
+    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID, typeId));
+    PropertiesData props = fFactory.createPropertiesData(properties);
+    return props;
+  }
+
+  protected ContentStreamData createContent() {
+    ContentStreamDataImpl content = new ContentStreamDataImpl();
+    content.setFileName("data.txt");
+    content.setMimeType("text/plain");
+    int len = 32 * 1024;
+    byte[] b = {0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+                0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a,     
+                0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+                0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a
+                }; // 32 Bytes
+    ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
+    try {
+      for (int i=0; i<1024; i++)
+        ba.write(b);
+      content.setContent(new ByteArrayInputStream(ba.toByteArray()));
+    } catch (IOException e) {
+        throw new RuntimeException("Failed to fill content stream with data", e) ;
+    }
+    return content;
+  }
+  
+  protected ContentStreamData createContent(char ch) {
+    ContentStreamDataImpl content = new ContentStreamDataImpl();
+    content.setFileName("data.txt");
+    content.setMimeType("text/plain");
+    int len = 32 * 1024;
+    byte[] b = new byte[32];
+    for (int i=0; i<32; i++)
+      b[i] = (byte) Character.getNumericValue(ch);
+    ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
+    try {
+      for (int i=0; i<1024; i++)
+        ba.write(b);
+      content.setContent(new ByteArrayInputStream(ba.toByteArray()));
+    } catch (IOException e) {
+        throw new RuntimeException("Failed to fill content stream with data", e) ;
+    }
+    return content;
+  }
+  protected void verifyContentResult(ContentStreamData sd) {
+    assertEquals("text/plain", sd.getMimeType());
+    assertEquals("data.txt", sd.getFilename());
+    assertEquals(32 * 1024, sd.getLength().longValue());
+    byte[] ba = new byte[32];
+    InputStream is = sd.getStream();
+    int counter = 0;
+    try {
+      while (is.read(ba) == ba.length) {
+        ++counter;      
+        assertEquals(0x61, ba[0]);
+        assertEquals(0x6e, ba[29]);
+        assertEquals(0x0c, ba[30]);
+        assertEquals(0x0a, ba[31]);
+      }
+    }
+    catch (IOException e) {
+      fail("reading from content stream failed");
+    }
+    assertEquals(1024, counter);
+  }
+
+  protected String getByPath(String id, String path) {
+    ObjectData res = null;
+    try {
+      res = fObjSvc.getObjectByPath(fRepositoryId, path, "*", false, IncludeRelationships.NONE,
+          null, false, false, null);
+      assertNotNull(res);
+      assertEquals(id, res.getId());
+    } catch (Exception e) {
+      fail("getObject() failed with exception: " + e);
+    }    
+    return res.getId();
+  }
+  
+  @SuppressWarnings("unchecked")
+  protected String getPathOfFolder(String id) {    
+    String path=null;
+    try {
+      String filter = PropertyIds.CMIS_PATH;
+      PropertiesData res = fObjSvc.getProperties(fRepositoryId, id, filter, null);
+      assertNotNull(res);
+      PropertyData<String> pd = (PropertyData<String>) res.getProperties().get(PropertyIds.CMIS_PATH);
+      assertNotNull(pd);
+      path = pd.getFirstValue();
+      assertNotNull(path);
+    } catch (Exception e) {
+      fail("getProperties() failed with exception: " + e);
+    }    
+    return path;
+  }
+
+  @SuppressWarnings("unchecked")
+  protected String getPathOfDocument(String id) {    
+    String path=null;
+    String filter = "*"; 
+    List<ObjectParentData> parentData = fNavSvc.getObjectParents(fRepositoryId, id, filter, false, IncludeRelationships.NONE, null, true, null);
+    String name = parentData.get(0).getRelativePathSegment();
+    PropertyData<String> pd = (PropertyData<String>) parentData.get(0).getObject().getProperties().getProperties().get(PropertyIds.CMIS_PATH);
+    assertNotNull(pd);
+    path = pd.getFirstValue() + "/" + name;
+    return path;
+  }
+
+  protected ObjectData getDocumentObjectData(String id) {
+    ObjectData res = null;
+    try {
+      String returnedId=null;
+      res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE,
+          null, false, false, null);
+      assertNotNull(res);
+      returnedId = res.getId();
+      testReturnedProperties(returnedId, res.getProperties().getProperties());
+      assertEquals(id, returnedId);    
+    } catch (Exception e) {
+      fail("getObject() failed with exception: " + e);
+    }    
+    return res;
+  }
+
+  protected String getDocument(String id) {
+    ObjectData res = getDocumentObjectData(id);
+    assertNotNull(res);
+    return res.getId();
+  }
+
+  protected void testReturnedProperties(String objectId, Map<String, PropertyData<?>> props) {
+    for (PropertyData<?> pd : props.values()) {
+      LOG.debug("return property id: " + pd.getId() + ", value: " + pd.getValues());
+    }
+    
+    PropertyData<?> pd = props.get(PropertyIds.CMIS_OBJECT_ID);
+    assertNotNull(pd);
+    assertEquals(objectId, pd.getFirstValue());
+  }
+
+
+  /**
+   * Instantiates the services by using directly the service implementations. 
+   * @param parameters
+   *    configuration parameters for client provider interface and in-memory provider
+   */
+  private void initializeDirect(Map<String, String> parameters) {
+    CmisInMemoryProvider inMemSpi;
+    inMemSpi = new CmisInMemoryProvider(parameters);
+    fRepSvc = inMemSpi.getRepositoryService();
+    fObjSvc = inMemSpi.getObjectService();
+    fNavSvc = inMemSpi.getNavigationService();    
+  }
+  
+  /**
+   * Instantiates the services by using the client provider interface.
+   * @param parameters
+   *    configuration parameters for client provider interface and in-memory provider
+   */
+  private void initializeUsingClientProvider(Map<String, String> parameters) {
+    CmisProvider provider;
+
+    // get factory and create provider
+    CmisProviderFactory factory = CmisProviderFactory.newInstance();
+    provider = factory.createCmisProvider(parameters);
+    assertNotNull(provider);
+    fFactory = provider.getObjectFactory();
+    fRepSvc = provider.getRepositoryService();
+    fObjSvc = provider.getObjectService();
+    fNavSvc = provider.getNavigationService();
+  }
+  
+}

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/NavigationServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/NavigationServiceTest.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/NavigationServiceTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/NavigationServiceTest.java Mon Feb 22 08:58:39 2010
@@ -20,38 +20,19 @@
 
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-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.IncludeRelationships;
 import org.apache.opencmis.commons.exceptions.CmisInvalidArgumentException;
-import org.apache.opencmis.commons.provider.CmisProvider;
-import org.apache.opencmis.commons.provider.NavigationService;
 import org.apache.opencmis.commons.provider.ObjectData;
 import org.apache.opencmis.commons.provider.ObjectInFolderContainer;
 import org.apache.opencmis.commons.provider.ObjectInFolderData;
 import org.apache.opencmis.commons.provider.ObjectInFolderList;
-import org.apache.opencmis.commons.provider.ObjectService;
 import org.apache.opencmis.commons.provider.PropertiesData;
 import org.apache.opencmis.commons.provider.PropertyData;
-import org.apache.opencmis.commons.provider.ProviderObjectFactory;
-import org.apache.opencmis.commons.provider.RepositoryInfoData;
-import org.apache.opencmis.commons.provider.RepositoryService;
-import org.apache.opencmis.inmemory.ConfigConstants;
-import org.apache.opencmis.inmemory.ConfigMap;
-import org.apache.opencmis.inmemory.MapConfigReader;
-import org.apache.opencmis.inmemory.RepositoryServiceTest.UnitTestRepositoryInfo;
-import org.apache.opencmis.inmemory.clientprovider.CmisInMemorySpi;
-import org.apache.opencmis.inmemory.server.RuntimeContext;
-import org.apache.opencmis.inmemory.storedobj.impl.SessionConfigReader;
 import org.apache.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
 import org.apache.opencmis.util.repository.ObjectGenerator;
 
@@ -59,51 +40,27 @@
 /**
  * @author Jens
  */
-public class NavigationServiceTest extends TestCase {
+public class NavigationServiceTest extends AbstractServiceTst {
   private static Log log = LogFactory.getLog(NavigationServiceTest.class);
-  private static final String REPOSITORY_ID = "UnitTestRepository";
-  private ProviderObjectFactory fFactory;
-  private CmisProvider fProvider;
   private static final int NUM_ROOT_FOLDERS = 10;
   private String fLevel1FolderId;
-  String fRootFolderId;
-  private String fRepositoryId;
 
   protected void setUp() throws Exception {
-
-    Map<String, String> parameters = new HashMap<String, String>();
-    parameters.put(SessionParameter.BINDING_SPI_CLASS, CmisProviderFactory.BINDING_SPI_INMEMORY);
-    // attach repository info to the session:
-    parameters
-        .put(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS, UnitTestRepositoryInfo.class.getName());
-    parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
-    
-    // get factory and create provider
-    CmisProviderFactory factory = CmisProviderFactory.newInstance();
-    fProvider = factory.createCmisProvider(parameters);
-    assertNotNull(fProvider);
-    fFactory = fProvider.getObjectFactory();
-    RepositoryService repSvc = fProvider.getRepositoryService();
-    RepositoryInfoData rep = repSvc.getRepositoryInfo(REPOSITORY_ID, null);
-    fRootFolderId = rep.getRootFolderId();
-    fRepositoryId = rep.getRepositoryId();
-    // Attach the CallContext to a thread local context that can be accessed from everywhere
-    ConfigMap cfgReader = new MapConfigReader(parameters);  
-    RuntimeContext.getRuntimeConfig().attachCfg(cfgReader);
+    super.setUp();
   }
 
   protected void tearDown() throws Exception {
+    super.tearDown();
   }
 
   public void testGetChildren() {
     log.info("starting testGetChildren() ...");
     createLevel1Folders();
-    NavigationService navSvc = fProvider.getNavigationService();
 
     log.info("test getting all objects with getChildren");
     BigInteger maxItems = BigInteger.valueOf(NUM_ROOT_FOLDERS *2);
     BigInteger skipCount = BigInteger.valueOf(0);
-    ObjectInFolderList result = navSvc.getChildren(fRepositoryId, fRootFolderId, "*", null, false,
+    ObjectInFolderList result = fNavSvc.getChildren(fRepositoryId, fRootFolderId, "*", null, false,
         IncludeRelationships.NONE, null, true, maxItems, skipCount, null);
     List<ObjectInFolderData> folders = result.getObjects();
     log.info(" found " + folders.size() + " folders in getChildren()");
@@ -116,7 +73,7 @@
     log.info("test paging with getChildren");
     maxItems = BigInteger.valueOf(3);
     skipCount = BigInteger.valueOf(3);    
-    result = navSvc.getChildren(fRepositoryId, fRootFolderId, "*", null, false,
+    result = fNavSvc.getChildren(fRepositoryId, fRootFolderId, "*", null, false,
         IncludeRelationships.NONE, null, true, maxItems, skipCount, null);
     folders = result.getObjects();
     log.info(" found " + folders.size() + " folders in getChildren()");
@@ -132,8 +89,6 @@
   public void testGetFolderTree() {
     log.info("starting testGetFolderTree() ...");    
     createFolderHierachy(3, 5);
-    //createLevel1Folders();
-    NavigationService navSvc = fProvider.getNavigationService();
 
     log.info("test getting all objects with getFolderTree");
     BigInteger depth = BigInteger.valueOf(-1);
@@ -143,7 +98,7 @@
     Boolean includeAllowableActions = false;
     String objectId = fRootFolderId;
     
-    List<ObjectInFolderContainer> tree = navSvc.getFolderTree(fRepositoryId, objectId,
+    List<ObjectInFolderContainer> tree = fNavSvc.getFolderTree(fRepositoryId, objectId,
         depth, propertyFilter, includeAllowableActions, IncludeRelationships.NONE, renditionFilter,
         includePathSegments, null);    
     
@@ -174,10 +129,9 @@
     final int numLevels = 3;
     final int childrenPerLevel = 3;
     int objCount = createFolderHierachy(numLevels, childrenPerLevel);
-    NavigationService navSvc = fProvider.getNavigationService();
 
     log.info("test getting all objects with getDescendants");
-    List<ObjectInFolderContainer> result = navSvc.getDescendants(fRepositoryId, fRootFolderId, BigInteger.valueOf(-1),
+    List<ObjectInFolderContainer> result = fNavSvc.getDescendants(fRepositoryId, fRootFolderId, BigInteger.valueOf(-1),
         "*", Boolean.TRUE, IncludeRelationships.NONE, null, Boolean.TRUE, null);
     
     for (ObjectInFolderContainer obj: result) {
@@ -188,7 +142,7 @@
     assertEquals(objCount, sizeOfDescs);
 
     log.info("test getting one level with getDescendants");
-    result = navSvc.getDescendants(fRepositoryId, fRootFolderId, BigInteger.valueOf(1),
+    result = fNavSvc.getDescendants(fRepositoryId, fRootFolderId, BigInteger.valueOf(1),
         "*", Boolean.TRUE, IncludeRelationships.NONE, null, Boolean.TRUE, null);
     
     for (ObjectInFolderContainer obj: result) {
@@ -199,7 +153,7 @@
     assertEquals(childrenPerLevel, sizeOfDescs);
     
     log.info("test getting two levels with getDescendants");
-    result = navSvc.getDescendants(fRepositoryId, fRootFolderId, BigInteger.valueOf(2),
+    result = fNavSvc.getDescendants(fRepositoryId, fRootFolderId, BigInteger.valueOf(2),
         "*", Boolean.TRUE, IncludeRelationships.NONE, null, Boolean.TRUE, null);
     
     for (ObjectInFolderContainer obj: result) {
@@ -215,16 +169,15 @@
   public void testGetFolderParent() {
     log.info("starting testGetFolderParent() ...");
     createLevel1Folders();
-    NavigationService navSvc = fProvider.getNavigationService();
     String folderId = fLevel1FolderId;
     
-    ObjectData result = navSvc.getFolderParent(fRepositoryId, folderId, null, null);
+    ObjectData result = fNavSvc.getFolderParent(fRepositoryId, folderId, null, null);
     log.info(" found parent for id \'" + folderId + "\' is \'" + result.getId() + "\'");
     assertEquals(fRootFolderId, result.getId()); // should be root folder 
     
     folderId = fRootFolderId;
     try {
-      result = navSvc.getFolderParent(fRepositoryId, folderId, null, null);
+      result = fNavSvc.getFolderParent(fRepositoryId, folderId, null, null);
       log.info(" found parent for id " + folderId + " is " + result.getId());
       fail("Should not be possible to get parent for root folder");
     } catch (Exception e) {
@@ -246,24 +199,21 @@
   }
   
   private void createLevel1Folders() {
-    ObjectService objSvc = fProvider.getObjectService();
     for (int i = 0; i < NUM_ROOT_FOLDERS; i++) {
       List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
       properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_NAME, "Folder " + i));
       properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID,
           InMemoryFolderTypeDefinition.getRootFolderType().getId()));
       PropertiesData props = fFactory.createPropertiesData(properties);      
-      String id = objSvc.createFolder(fRepositoryId, props, fRootFolderId, null, null, null, null);
+      String id = fObjSvc.createFolder(fRepositoryId, props, fRootFolderId, null, null, null, null);
       if (i==3) // store one
         fLevel1FolderId = id;
     }
   }
   
   private int createFolderHierachy(int levels, int childrenPerLevel) {
-    NavigationService navSvc = fProvider.getNavigationService();
-    ObjectService objSvc = fProvider.getObjectService();
 
-    ObjectGenerator gen = new ObjectGenerator(fFactory, navSvc, objSvc, fRepositoryId);
+    ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
     gen.createFolderHierachy(levels, childrenPerLevel, fRootFolderId);
     int objCount = gen.getObjectsInTotal();
     return objCount;

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/ObjectServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/ObjectServiceTest.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/ObjectServiceTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/ObjectServiceTest.java Mon Feb 22 08:58:39 2010
@@ -18,10 +18,6 @@
  */
 package org.apache.opencmis.inmemory;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -29,13 +25,9 @@
 import java.util.List;
 import java.util.Map;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-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.api.ExtensionsData;
 import org.apache.opencmis.commons.api.PropertyDefinition;
 import org.apache.opencmis.commons.api.TypeDefinition;
@@ -46,30 +38,17 @@
 import org.apache.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.opencmis.commons.exceptions.CmisUpdateConflictException;
-import org.apache.opencmis.commons.impl.dataobjects.ContentStreamDataImpl;
 import org.apache.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
 import org.apache.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
 import org.apache.opencmis.commons.provider.AccessControlList;
 import org.apache.opencmis.commons.provider.AllowableActionsData;
-import org.apache.opencmis.commons.provider.CmisProvider;
 import org.apache.opencmis.commons.provider.ContentStreamData;
 import org.apache.opencmis.commons.provider.Holder;
-import org.apache.opencmis.commons.provider.NavigationService;
 import org.apache.opencmis.commons.provider.ObjectData;
 import org.apache.opencmis.commons.provider.ObjectInFolderList;
 import org.apache.opencmis.commons.provider.ObjectParentData;
-import org.apache.opencmis.commons.provider.ObjectService;
 import org.apache.opencmis.commons.provider.PropertiesData;
 import org.apache.opencmis.commons.provider.PropertyData;
-import org.apache.opencmis.commons.provider.ProviderObjectFactory;
-import org.apache.opencmis.commons.provider.RepositoryInfoData;
-import org.apache.opencmis.commons.provider.RepositoryService;
-import org.apache.opencmis.inmemory.ConfigConstants;
-import org.apache.opencmis.inmemory.ConfigMap;
-import org.apache.opencmis.inmemory.MapConfigReader;
-import org.apache.opencmis.inmemory.TypeCreator;
-import org.apache.opencmis.inmemory.RepositoryServiceTest.UnitTestRepositoryInfo;
-import org.apache.opencmis.inmemory.server.RuntimeContext;
 import org.apache.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
 import org.apache.opencmis.inmemory.types.PropertyCreationHelper;
@@ -79,15 +58,9 @@
  * @author Jens
  */
 
-public class ObjectServiceTest extends TestCase {
+public class ObjectServiceTest extends AbstractServiceTst {
 
   private static Log log = LogFactory.getLog(ObjectServiceTest.class);
-  private static final String REPOSITORY_ID = "UnitTestRepository";
-  private ProviderObjectFactory fFactory;
-  private CmisProvider fProvider;
-  ObjectService fObjSvc;
-  String fRepositoryId;
-  String fRootFolderId;
   private static final String TEST_FOLDER_TYPE_ID = "MyFolderType";
   private static final String TEST_DOCUMENT_TYPE_ID = "MyDocumentType";
   private static final String TEST_FOLDER_STRING_PROP_ID = "MyFolderStringProp";
@@ -98,76 +71,24 @@
   private static final String TEST_DOCUMENT_MY_INT_PROP_ID  = "MyCustomDocumentIntProp";
   private static final String TEST_DOCUMENT_MY_SUB_STRING_PROP_ID  = "MyInheritedStringProp";
   private static final String TEST_DOCUMENT_MY_SUB_INT_PROP_ID  = "MyInheritedIntProp";
+
+  private static final String DOCUMENT_TYPE_ID =  InMemoryDocumentTypeDefinition.getRootDocumentType().getId();
+  private static final String DOCUMENT_ID =  "Document_1";
+  private static final String FOLDER_TYPE_ID =  InMemoryFolderTypeDefinition.getRootFolderType().getId();
+  private static final String FOLDER_ID =  "Folder_1";
+  private static final String MY_CUSTOM_NAME = "My Custom Document";
+  
   ObjectCreator fCreator;
   
   protected void setUp() throws Exception {
-
-    Map<String, String> parameters = new HashMap<String, String>();
-    parameters.put(SessionParameter.BINDING_SPI_CLASS, CmisProviderFactory.BINDING_SPI_INMEMORY);
-    // attach repository info to the session:
-    parameters
-        .put(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS, UnitTestRepositoryInfo.class.getName());
-
-    parameters.put(ConfigConstants.TYPE_CREATOR_CLASS, ObjectTestTypeSystemCreator.class.getName());
-    parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
-    parameters.put(ConfigConstants.USERNAME, "TestUser");
-    
-    // get factory and create provider
-    CmisProviderFactory factory = CmisProviderFactory.newInstance();
-    fProvider = factory.createCmisProvider(parameters);
-    assertNotNull(fProvider);
-    fFactory = fProvider.getObjectFactory();
-    RepositoryService repSvc = fProvider.getRepositoryService();
-    RepositoryInfoData rep = repSvc.getRepositoryInfo(REPOSITORY_ID, null);
-    fObjSvc = fProvider.getObjectService();
-    fRepositoryId = rep.getRepositoryId();
-    fRootFolderId = rep.getRootFolderId();
+    super.setUp(ObjectTestTypeSystemCreator.class.getName());
     fCreator = new ObjectCreator(fFactory, fObjSvc, fRepositoryId);
-
-    // Attach the CallContext to a thread local context that can be accessed from everywhere
-    ConfigMap cfgReader = new MapConfigReader(parameters);  
-    RuntimeContext.getRuntimeConfig().attachCfg(cfgReader);
   }
 
   protected void tearDown() throws Exception {
+    super.tearDown();
   }
 
-  private String createDocument(String folderId, boolean withContent) {
-    VersioningState versioningState = VersioningState.NONE;
-    String id = null;
-    id = fCreator.createDocument(DOCUMENT_ID, DOCUMENT_TYPE_ID, folderId, versioningState, null);
-
-    return id;
-  }
-  
-  private String createFolder() {
-    PropertiesData props = createFolderProperties();
-    String id = null;
-    try {
-      id = fObjSvc.createFolder(fRepositoryId, props, fRootFolderId, null, null, null, null);
-      if (null == id)
-        fail("createFolder failed.");
-    } catch (Exception e) {
-      fail("createFolder() failed with exception: " + e);
-    }
-    return id;
-  }
-
-  private String getDocument(String id) {
-    String returnedId=null;
-    try {
-      ObjectData res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE,
-          null, false, false, null);
-      assertNotNull(res);
-      testReturnedProperties(res.getProperties().getProperties());
-      returnedId = res.getId();
-      assertEquals(id, returnedId);    
-    } catch (Exception e) {
-      fail("getObject() failed with exception: " + e);
-    }    
-    return returnedId;
-  }
-  
   public void testCreateDocument() {
     log.info("starting testCreateObject() ...");
     String id = createDocument(fRootFolderId, false);
@@ -185,10 +106,59 @@
       log.info("  createDocument succeeded with created id: " + id);
 
     log.info("  getting object");
-    getDocument(id);    
+    retrieveDocument(id);    
     log.info("... testGetObject() finished.");
   }
   
+  public void testGetObjectByPath() {
+    log.info("starting testGetObjectByPath() ...");
+    log.info("  creating object");
+    
+    // create a tree for testing paths
+    String f1 = createFolder("folder1", fRootFolderId, FOLDER_TYPE_ID);
+    String f2 = createFolder("folder2", fRootFolderId, FOLDER_TYPE_ID);
+    String f3 = createFolder("folder3", fRootFolderId, FOLDER_TYPE_ID);
+    String f11 = createFolder("folder1.1", f1, FOLDER_TYPE_ID);
+    String f12 = createFolder("folder1.2", f1, FOLDER_TYPE_ID);
+    String f13 = createFolder("folder1.3", f1, FOLDER_TYPE_ID);
+    String f31 = createFolder("folder3.1", f3, FOLDER_TYPE_ID);
+    String f32 = createFolder("folder3.2", f3, FOLDER_TYPE_ID);
+    String f33 = createFolder("folder3.3", f3, FOLDER_TYPE_ID);
+    String f121 = createFolder("folder1.2.1", f12, FOLDER_TYPE_ID);
+    String f122 = createFolder("folder1.2.2", f12, FOLDER_TYPE_ID);
+    String f123 = createFolder("folder1.2.3", f12, FOLDER_TYPE_ID);
+    String f331 = createFolder("folder3.3.1", f33, FOLDER_TYPE_ID);
+    String f332 = createFolder("folder3.3.2", f33, FOLDER_TYPE_ID);
+    String f333 = createFolder("folder3.3.3", f33, FOLDER_TYPE_ID);
+    String doc12 = createDocument("Document1.2.Doc", f12, false);
+    String doc33 = createDocument("Document3.3.Doc", f33, false);
+    String doc331 = createDocument("Document3.3.1.Doc", f331, false);
+    String doc333 = createDocument("Document3.3.3.Doc", f333, false);
+    
+    log.info("  getting object by path");
+    getByPath(f1, "/folder1");
+    getByPath(f2, "/folder2");
+    getByPath(f3, "/folder3");
+    getByPath(f11, "/folder1/folder1.1");
+    getByPath(f12, "/folder1/folder1.2");
+    getByPath(f13, "/folder1/folder1.3");
+    getByPath(f31, "/folder3/folder3.1");
+    getByPath(f32, "/folder3/folder3.2");
+    getByPath(f33, "/folder3/folder3.3");
+    getByPath(f121, "/folder1/folder1.2/folder1.2.1");
+    getByPath(f122, "/folder1/folder1.2/folder1.2.2");
+    getByPath(f123, "/folder1/folder1.2/folder1.2.3");
+    getByPath(f331, "/folder3/folder3.3/folder3.3.1");
+    getByPath(f332, "/folder3/folder3.3/folder3.3.2");
+    getByPath(f333, "/folder3/folder3.3/folder3.3.3");
+    getByPath(doc12, "/folder1/folder1.2/Document1.2.Doc");
+    getByPath(doc33, "/folder3/folder3.3/Document3.3.Doc");
+    getByPath(doc331, "/folder3/folder3.3/folder3.3.1/Document3.3.1.Doc");
+    getByPath(doc333, "/folder3/folder3.3/folder3.3.3/Document3.3.3.Doc");
+
+    log.info("... testGetObjectByPath() finished.");
+  }   
+
   public void testCreateDocumentWithContent() {
     log.info("starting testCreateDocumentWithContent() ...");
     String id = createDocument(fRootFolderId, true);
@@ -303,10 +273,8 @@
   
   public void testBuildFolderAndDocuments() {
     // Create a hierarchy of folders and fill it with some documents
-    NavigationService navSvc = fProvider.getNavigationService();
-    ObjectService objSvc = fProvider.getObjectService();
 
-    ObjectGenerator gen = new ObjectGenerator(fFactory, navSvc, objSvc, fRepositoryId);
+    ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
     int levels = 2;  // create a hierarchy with two levels
     int childrenPerLevel = 2; // create two folders on each level
 
@@ -350,7 +318,7 @@
       log.info("  createDocument succeeded with created id: " + id);
 
     log.info("  getting object");
-    getDocument(id);    
+    retrieveDocument(id);    
     log.info("  deleting object");
     try {
       fObjSvc.deleteObject(fRepositoryId, id, true, null);
@@ -399,7 +367,7 @@
     log.info("Testing to delete a folder with a contained document");
     String folderId;
     folderId = createFolder();
-    id = createDocument(id, false);
+    id = createDocument(folderId, false);
     
     try {
       fObjSvc.deleteObject(fRepositoryId, folderId, true, null);
@@ -443,9 +411,7 @@
   
   public void testDeleteTree() {
     log.info("starting testDeleteTree() ...");
-    NavigationService navSvc = fProvider.getNavigationService();
-    ObjectService objSvc = fProvider.getObjectService();
-    ObjectGenerator gen = new ObjectGenerator(fFactory, navSvc, objSvc, fRepositoryId);
+    ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
     String rootFolderId = createFolder();
     // Set the type id for all created documents:
     gen.setDocumentTypeId(InMemoryDocumentTypeDefinition.getRootDocumentType().getId());    
@@ -704,12 +670,17 @@
     assertNotNull(actions.get(AllowableActionsData.ACTION_CAN_APPLY_ACL));
   }
   
+  private String retrieveDocument(String id) {
+    ObjectData res = getDocumentObjectData(id);
+    String returnedId = res.getId();
+    testReturnedProperties(returnedId, DOCUMENT_ID, DOCUMENT_TYPE_ID, res.getProperties().getProperties());
+    return returnedId;
+  }
+  
   private void moveObjectTest(boolean isFolder) {
     final String propertyFilter=PropertyIds.CMIS_OBJECT_ID+","+PropertyIds.CMIS_NAME; //+","+PropertyIds.CMIS_OBJECT_TYPE_ID+","+PropertyIds.CMIS_BASE_TYPE_ID;
     String rootFolderId = createFolder();
-    NavigationService navSvc = fProvider.getNavigationService();
-    ObjectService objSvc = fProvider.getObjectService();
-    ObjectGenerator gen = new ObjectGenerator(fFactory, navSvc, objSvc, fRepositoryId);
+    ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
     // Set the type id for all created documents:
     gen.setDocumentTypeId(InMemoryDocumentTypeDefinition.getRootDocumentType().getId());    
     // Set the type id for all created folders:
@@ -727,14 +698,14 @@
     log.info("Id after moveObject: " + holder.getValue());
     gen.dumpFolder(fRootFolderId, propertyFilter);
 
-    List<ObjectParentData> result = navSvc.getObjectParents(fRepositoryId, holder.getValue(), null, Boolean.FALSE, IncludeRelationships.NONE, null, Boolean.FALSE,  null);
+    List<ObjectParentData> result = fNavSvc.getObjectParents(fRepositoryId, holder.getValue(), null, Boolean.FALSE, IncludeRelationships.NONE, null, Boolean.FALSE,  null);
     // check that new parent is set correctly
     String newParentId =result.get(0).getObject().getId();
     assertEquals(rootFolderId, newParentId);
     
     if (isFolder) {
       log.info("testing moveFolder to a subfolder");
-      ObjectInFolderList ch = navSvc.getChildren(fRepositoryId, holder.getValue(), propertyFilter, null,
+      ObjectInFolderList ch = fNavSvc.getChildren(fRepositoryId, holder.getValue(), propertyFilter, null,
           false, IncludeRelationships.NONE, null, false, null, null, null);
       String subFolderId = ch.getObjects().get(0).getObject().getId();
       try {
@@ -746,20 +717,18 @@
     }
   }
   
-  private static final String DOCUMENT_TYPE_ID =  InMemoryDocumentTypeDefinition.getRootDocumentType().getId();
-  private static final String DOCUMENT_ID =  "Document_1";
-  private static final String FOLDER_TYPE_ID =  InMemoryFolderTypeDefinition.getRootFolderType().getId();
-  private static final String FOLDER_ID =  "Folder_1";
-  private static final String MY_CUSTOM_NAME = "My Custom Document";
-  
-  private PropertiesData createDocumentProperties() {
-    List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
-    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_NAME, DOCUMENT_ID));
-    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID, DOCUMENT_TYPE_ID));
-    PropertiesData props = fFactory.createPropertiesData(properties);
-    return props;
+  private String createFolder() {
+    return createFolder(FOLDER_ID, fRootFolderId, FOLDER_TYPE_ID);
+  }
+
+  private String createDocument(String folderId, boolean withContent) {
+    return createDocument(DOCUMENT_ID, folderId, withContent);
   }
   
+  private String createDocument(String name, String folderId, boolean withContent) {
+    return createDocument(name, folderId, DOCUMENT_TYPE_ID, withContent);
+  }
+
   private PropertiesData createDocumentPropertiesForDocumentFromSource(String name) {
     // We only provide a name but not a type id, as spec says to copy missing attributes 
     // from the existing one
@@ -769,32 +738,15 @@
     return props;
   }
 
-  private PropertiesData createDocumentProperties(String name) {
-    List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
-    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_NAME, name));
-    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID, DOCUMENT_TYPE_ID));
-    PropertiesData props = fFactory.createPropertiesData(properties);
-    return props;
-  }
   
-  private PropertiesData createFolderProperties() {
-    List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
-    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_NAME, FOLDER_ID));
-    properties.add(fFactory.createPropertyIdData(PropertyIds.CMIS_OBJECT_TYPE_ID, FOLDER_TYPE_ID));
-    PropertiesData props = fFactory.createPropertiesData(properties);
-    return props;
-  }
-
-  private void testReturnedProperties(Map<String, PropertyData<?>> props) {
-    for (PropertyData<?> pd : props.values()) {
-      log.info("return property id: " + pd.getId() + ", value: " + pd.getValues());
-    }
+  private void testReturnedProperties(String objectId, String objectName, String typeId, Map<String, PropertyData<?>> props) {
+    super.testReturnedProperties(objectId, props);
     
     PropertyData<?> pd = props.get(PropertyIds.CMIS_NAME);
     assertNotNull(pd);
-    assertEquals(DOCUMENT_ID, pd.getFirstValue());
+    assertEquals(objectName, pd.getFirstValue());
     pd = props.get(PropertyIds.CMIS_OBJECT_TYPE_ID);
-    assertEquals(DOCUMENT_TYPE_ID, pd.getFirstValue());
+    assertEquals(typeId, pd.getFirstValue());
   }
  
   private String createDocumentWithCustomType(String folderId, boolean withContent) {
@@ -804,7 +756,6 @@
     AccessControlList addACEs = null;
     AccessControlList removeACEs = null;
     ExtensionsData extension = null;
-    ObjectService objSvc = fProvider.getObjectService();
 
     // create the properties:
     List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
@@ -821,7 +772,7 @@
     
     // create the document 
     String id = null;
-    id = objSvc.createDocument(fRepositoryId, props, folderId, contentStream, versioningState,
+    id = fObjSvc.createDocument(fRepositoryId, props, folderId, contentStream, versioningState,
         policies, addACEs, removeACEs, extension);
     if (null == id)
       throw new RuntimeException("createDocument failed.");
@@ -835,7 +786,6 @@
     AccessControlList addACEs = null;
     AccessControlList removeACEs = null;
     ExtensionsData extension = null;
-    ObjectService objSvc = fProvider.getObjectService();
 
     // create the properties:
     List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
@@ -854,55 +804,12 @@
     
     // create the document 
     String id = null;
-    id = objSvc.createDocument(fRepositoryId, props, folderId, contentStream, versioningState,
+    id = fObjSvc.createDocument(fRepositoryId, props, folderId, contentStream, versioningState,
         policies, addACEs, removeACEs, extension);
     if (null == id)
       throw new RuntimeException("createDocument failed.");
     return id;
   }
-
-  ContentStreamData createContent() {
-    ContentStreamDataImpl content = new ContentStreamDataImpl();
-    content.setFilename("data.txt");
-    content.setMimeType("text/plain");
-    int len = 32 * 1024;
-    byte[] b = {0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
-                0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a,     
-                0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
-                0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a
-                }; // 32 Bytes
-    ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
-    try {
-      for (int i=0; i<1024; i++)
-        ba.write(b);
-    } catch (IOException e) {
-        throw new RuntimeException("Failed to fill content stream with data", e) ;
-    }
-    content.setStream(new ByteArrayInputStream(ba.toByteArray()));
-    return content;
-  }
-
-  private void verifyContentResult(ContentStreamData sd) {
-    assertEquals("text/plain", sd.getMimeType());
-    assertEquals("data.txt", sd.getFilename());
-    assertEquals(32 * 1024, sd.getLength().longValue());
-    byte[] ba = new byte[32];
-    InputStream is = sd.getStream();
-    int counter = 0;
-    try {
-      while (is.read(ba) == ba.length) {
-        ++counter;      
-        assertEquals(0x61, ba[0]);
-        assertEquals(0x6e, ba[29]);
-        assertEquals(0x0c, ba[30]);
-        assertEquals(0x0a, ba[31]);
-      }
-    }
-    catch (IOException e) {
-      junit.framework.Assert.fail("reading from content stream failed");
-    }
-    assertEquals(1024, counter);
-  }
   
   
   // Helper class to create some type for testing the ObjectService

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/RepositoryServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/RepositoryServiceTest.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/RepositoryServiceTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/RepositoryServiceTest.java Mon Feb 22 08:58:39 2010
@@ -26,17 +26,13 @@
 import java.util.List;
 import java.util.Map;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-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.api.Choice;
 import org.apache.opencmis.commons.api.PropertyDefinition;
-import org.apache.opencmis.commons.api.TypeDefinitionContainer;
 import org.apache.opencmis.commons.api.TypeDefinition;
+import org.apache.opencmis.commons.api.TypeDefinitionContainer;
 import org.apache.opencmis.commons.api.TypeDefinitionList;
 import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
 import org.apache.opencmis.commons.enums.CapabilityAcl;
@@ -45,8 +41,8 @@
 import org.apache.opencmis.commons.enums.CapabilityJoin;
 import org.apache.opencmis.commons.enums.CapabilityQuery;
 import org.apache.opencmis.commons.enums.CapabilityRendition;
-import org.apache.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.opencmis.commons.impl.dataobjects.ChoiceImpl;
 import org.apache.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
 import org.apache.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
@@ -57,22 +53,16 @@
 import org.apache.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
 import org.apache.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesDataImpl;
 import org.apache.opencmis.commons.impl.dataobjects.RepositoryInfoDataImpl;
-import org.apache.opencmis.commons.provider.CmisProvider;
 import org.apache.opencmis.commons.provider.RepositoryInfoData;
-import org.apache.opencmis.inmemory.ConfigConstants;
-import org.apache.opencmis.inmemory.ConfigMap;
-import org.apache.opencmis.inmemory.MapConfigReader;
-import org.apache.opencmis.inmemory.RepositoryInfoCreator;
-import org.apache.opencmis.inmemory.server.RuntimeContext;
 import org.apache.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.opencmis.inmemory.types.PropertyCreationHelper;
 /**
  * @author Jens
  */
-public class RepositoryServiceTest extends TestCase {
+public class RepositoryServiceTest extends AbstractServiceTst {
 
-  private CmisProvider fProvider;
+//  private CmisProvider fProvider;
 
   private static Log log = LogFactory.getLog(RepositoryServiceTest.class);
   private static final String REPOSITORY_ID = "UnitTestRepository";
@@ -118,35 +108,18 @@
   }
   
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @see junit.framework.TestCase#setUp()
-   */
   protected void setUp() throws Exception {
-    // gather parameters
-    Map<String, String> parameters = new HashMap<String, String>();
-    parameters.put(SessionParameter.BINDING_SPI_CLASS, CmisProviderFactory.BINDING_SPI_INMEMORY);
-
-    // attach repository info to the session:
-    parameters.put(ConfigConstants.REPOSITORY_INFO_CREATOR_CLASS, UnitTestRepositoryInfo.class.getName());
-    // attach TypeSystem to the session
-    parameters.put(ConfigConstants.TYPE_CREATOR_CLASS, RepositoryTestTypeSystemCreator.class.getName());
-    parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
-
-    // get factory and create provider
-    CmisProviderFactory factory = CmisProviderFactory.newInstance();
-    fProvider = factory.createCmisProvider(parameters);
-    assertNotNull(fProvider);
-    
-    // Attach the CallContext to a thread local context that can be accessed from everywhere
-    ConfigMap cfgReader = new MapConfigReader(parameters);  
-    RuntimeContext.getRuntimeConfig().attachCfg(cfgReader);
+    super.setUp(RepositoryTestTypeSystemCreator.class.getName());
+  }
+
+  protected void tearDown() throws Exception {
+    super.tearDown();
   }
 
+
   public void testRepositoryInfo() throws Exception {
     log.info("starting testRepositoryInfo() ...");
-    List<RepositoryInfoData> repositories = fProvider.getRepositoryService().getRepositoryInfos(
+    List<RepositoryInfoData> repositories = fRepSvc.getRepositoryInfos(
         null);
     assertNotNull(repositories);
     assertFalse(repositories.isEmpty());
@@ -154,7 +127,7 @@
     log.info("geRepositoryInfo(), found " + repositories.size() + " repository/repositories).");
 
     for (RepositoryInfoData repository : repositories) {
-      RepositoryInfoData repository2 = fProvider.getRepositoryService().getRepositoryInfo(
+      RepositoryInfoData repository2 = fRepSvc.getRepositoryInfo(
           repository.getRepositoryId(), null);
       assertNotNull(repository2);
       assertEquals(repository.getRepositoryId(), repository2.getRepositoryId());
@@ -170,7 +143,7 @@
     String repositoryId = getRepositoryId();
     String typeId = "MyDocType1";
     TypeDefinition ref = RepositoryTestTypeSystemCreator.getTypeById(typeId);
-    TypeDefinition type = fProvider.getRepositoryService().getTypeDefinition(repositoryId,
+    TypeDefinition type = fRepSvc.getTypeDefinition(repositoryId,
         typeId, null);
     assertEquals(ref.getId(), type.getId());
     assertEquals(ref.getDescription(), type.getDescription());
@@ -187,7 +160,7 @@
     String repositoryId = getRepositoryId();
 
     // get types
-    List<TypeDefinitionContainer> types = fProvider.getRepositoryService().getTypeDescendants(
+    List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(
         repositoryId, null/* all types */, BigInteger.valueOf(-1), Boolean.TRUE, null);
     assertNotNull(types);
     log.info("Repository " + repositoryId + " contains " + types.size() + " type(s).");
@@ -220,7 +193,7 @@
 
     // get types
     int depth = 2;
-    List<TypeDefinitionContainer> types = fProvider.getRepositoryService().getTypeDescendants(
+    List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(
         repositoryId, null/* all types */, BigInteger.valueOf(depth), Boolean.TRUE, null);
     assertNotNull(types);
     log.info("Found in repository " + repositoryId + " " + types.size() + " type(s) with depth "
@@ -263,7 +236,7 @@
     // get types
     int depth = 2;
     String typeId = "MyDocType1";
-    List<TypeDefinitionContainer> types = fProvider.getRepositoryService().getTypeDescendants(
+    List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(
         repositoryId, typeId, BigInteger.valueOf(depth), Boolean.TRUE, null);
     assertNotNull(types);
     log.info("Found in repository " + repositoryId + " for type " + typeId + ", " + types.size()
@@ -297,7 +270,7 @@
     String typeId = BaseObjectTypeIds.CMIS_DOCUMENT.value();
 
     // get types
-    List<TypeDefinitionContainer> types = fProvider.getRepositoryService().getTypeDescendants(
+    List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(
         repositoryId, typeId, BigInteger.valueOf(-1), false, null);
     assertNotNull(types);
     log.info("Repository " + repositoryId + " contains " + types.size() + " type(s).");
@@ -328,7 +301,7 @@
     // get all children
     BigInteger maxItems = BigInteger.valueOf(1000);
     BigInteger skipCount = BigInteger.valueOf(0);
-    TypeDefinitionList children = fProvider.getRepositoryService().getTypeChildren(repositoryId,
+    TypeDefinitionList children = fRepSvc.getTypeChildren(repositoryId,
         typeId, true, maxItems, skipCount, null);
 
     for (TypeDefinition type : children.getList()) {
@@ -342,7 +315,7 @@
     // get a chunk
     maxItems = BigInteger.valueOf(5);
     skipCount = BigInteger.valueOf(3);
-    children = fProvider.getRepositoryService().getTypeChildren(repositoryId, typeId, true,
+    children = fRepSvc.getTypeChildren(repositoryId, typeId, true,
         maxItems, skipCount, null);
 
     for (TypeDefinition type : children.getList()) {
@@ -367,7 +340,7 @@
     String wrongTypeId = "UnknownType";
 
     try {
-      RepositoryInfoData repInf = fProvider.getRepositoryService().getRepositoryInfo(
+      RepositoryInfoData repInf = fRepSvc.getRepositoryInfo(
           wrongRepositoryId, null);
       log.debug("getRepositoryInfo(): " + repInf);
       fail("getRepositoryInfo() with illegal repository id should throw InvalidArgumentException.");
@@ -377,7 +350,7 @@
     }
 
     try {
-      List<TypeDefinitionContainer> types = fProvider.getRepositoryService().getTypeDescendants(
+      List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(
           repositoryId, "CMISDocument", BigInteger.valueOf(0), Boolean.TRUE, null);
       log.debug("getTypeDescendants(): " + types);
       fail("getTypeDescendants() with depth 0 should throw InvalidArgumentException.");
@@ -387,7 +360,7 @@
     }
 
     try {
-      List<TypeDefinitionContainer> types = fProvider.getRepositoryService().getTypeDescendants(
+      List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(
           repositoryId, wrongTypeId, BigInteger.valueOf(depth), Boolean.TRUE, null);
       log.debug("getTypeDescendants(): " + types);
       fail("getTypeDescendants() with unknown type should throw exception.");
@@ -397,7 +370,7 @@
     }
 
     try {
-      TypeDefinition type = fProvider.getRepositoryService().getTypeDefinition(
+      TypeDefinition type = fRepSvc.getTypeDefinition(
           wrongRepositoryId, "CMISDocument", null);
       log.debug("getTypeDefinition(): " + type);
       fail("getTypeDefinition() with unknown repository id should throw exception.");
@@ -407,7 +380,7 @@
     }
 
     try {
-      TypeDefinition type = fProvider.getRepositoryService().getTypeDefinition(repositoryId,
+      TypeDefinition type = fRepSvc.getTypeDefinition(repositoryId,
           wrongTypeId, null);
       log.debug("getTypeDefinition(): " + type);
       fail("getTypeDefinition() with unknown type should throw exception.");
@@ -417,7 +390,7 @@
     }
 
     try {
-      TypeDefinitionList types = fProvider.getRepositoryService().getTypeChildren(
+      TypeDefinitionList types = fRepSvc.getTypeChildren(
           wrongRepositoryId, "CMISDocument", Boolean.TRUE, BigInteger.valueOf(100),
           BigInteger.ZERO, null);
       log.debug("getTypeChildren(): " + types);
@@ -428,7 +401,7 @@
     }
 
     try {
-      TypeDefinitionList types = fProvider.getRepositoryService().getTypeChildren(repositoryId,
+      TypeDefinitionList types = fRepSvc.getTypeChildren(repositoryId,
           wrongTypeId, Boolean.TRUE, BigInteger.valueOf(100), BigInteger.ZERO, null);
       log.debug("getTypeChildren(): " + types);
       fail("getTypeDescendants() with unknown type should throw exception.");
@@ -448,7 +421,7 @@
     String typeId = RepositoryTestTypeSystemCreator.TOPLEVEL_TYPE;
 
     // get top level type
-    TypeDefinition typeContainer = fProvider.getRepositoryService().getTypeDefinition(
+    TypeDefinition typeContainer = fRepSvc.getTypeDefinition(
         repositoryId, typeId, null);
     assertNotNull(typeContainer);
     Map<String, PropertyDefinition<?>> propDefMap = typeContainer.getPropertyDefinitions();
@@ -460,7 +433,7 @@
     
     // get level 1 type
     typeId = RepositoryTestTypeSystemCreator.LEVEL1_TYPE;
-    typeContainer = fProvider.getRepositoryService().getTypeDefinition(
+    typeContainer = fRepSvc.getTypeDefinition(
         repositoryId, typeId, null);
     assertNotNull(typeContainer);
     propDefMap = typeContainer.getPropertyDefinitions();
@@ -473,7 +446,7 @@
     
     // get level 2 type
     typeId = RepositoryTestTypeSystemCreator.LEVEL2_TYPE;
-    typeContainer = fProvider.getRepositoryService().getTypeDefinition(
+    typeContainer = fRepSvc.getTypeDefinition(
         repositoryId, typeId, null);
     assertNotNull(typeContainer);
     propDefMap = typeContainer.getPropertyDefinitions();
@@ -489,7 +462,7 @@
   }
 
   private String getRepositoryId() {
-    List<RepositoryInfoData> repositories = fProvider.getRepositoryService().getRepositoryInfos(
+    List<RepositoryInfoData> repositories = fRepSvc.getRepositoryInfos(
         null);
     RepositoryInfoData repository = repositories.get(0);
     assertNotNull(repository);

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/TypeValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/TypeValidationTest.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/TypeValidationTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/TypeValidationTest.java Mon Feb 22 08:58:39 2010
@@ -47,8 +47,6 @@
 import org.apache.opencmis.commons.provider.PropertiesData;
 import org.apache.opencmis.commons.provider.PropertyData;
 import org.apache.opencmis.commons.provider.ProviderObjectFactory;
-import org.apache.opencmis.inmemory.TypeManager;
-import org.apache.opencmis.inmemory.TypeValidator;
 import org.apache.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.opencmis.inmemory.types.PropertyCreationHelper;
 

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/UnitTestTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/UnitTestTypeSystemCreator.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/UnitTestTypeSystemCreator.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/UnitTestTypeSystemCreator.java Mon Feb 22 08:58:39 2010
@@ -41,7 +41,6 @@
 import org.apache.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
 import org.apache.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
 import org.apache.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
-import org.apache.opencmis.inmemory.TypeCreator;
 import org.apache.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
 import org.apache.opencmis.inmemory.types.PropertyCreationHelper;
 

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/VersioningTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/VersioningTest.java?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/VersioningTest.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-inmemory/src/test/java/org/apache/opencmis/inmemory/VersioningTest.java Mon Feb 22 08:58:39 2010
@@ -30,8 +30,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.junit.After;
-import org.junit.Before;
 import org.apache.opencmis.client.provider.factory.CmisProviderFactory;
 import org.apache.opencmis.commons.PropertyIds;
 import org.apache.opencmis.commons.SessionParameter;
@@ -63,10 +61,12 @@
 import org.apache.opencmis.inmemory.RepositoryServiceTest.UnitTestRepositoryInfo;
 import org.apache.opencmis.inmemory.server.RuntimeContext;
 import org.apache.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
-import org.apache.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
 import org.apache.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.opencmis.server.spi.CallContext;
+import org.junit.After;
+import org.junit.Before;
 
-public class VersioningTest extends TestCase {
+public class VersioningTest extends AbstractServiceTst {
   private static Log log = LogFactory.getLog(ObjectServiceTest.class);
   private static final String REPOSITORY_ID = "UnitTestRepository";
   private static final String PROP_VALUE = "Mickey Mouse";
@@ -117,12 +117,11 @@
   }
 
   private void setRuntimeContext(String user) {
-    Map<String, String> parameters = new HashMap<String, String>();
-    parameters.put(ConfigConstants.USERNAME, user);
+    DummyCallContext ctx = new DummyCallContext();
+    ctx.put(CallContext.USERNAME, user);
 
     // Attach the CallContext to a thread local context that can be accessed from everywhere
-    ConfigMap cfgReader = new MapConfigReader(parameters);  
-    RuntimeContext.getRuntimeConfig().attachCfg(cfgReader); 
+    RuntimeContext.getRuntimeConfig().attachCfg(ctx); 
   }
     
   public void testCreateVersionedDocumentMinor() {
@@ -441,6 +440,13 @@
     assertEquals(2, checkedOutDocuments.getObjects().size());
   }
   
+  public void testModifyOldVersions() {
+    String versionSeriesId = createVersionSeriesWithThreeVersions();
+    List<ObjectData> allVersions = fVerSvc.getAllVersions(fRepositoryId, versionSeriesId, "*", false, null);
+    assertEquals(3, allVersions.size());
+
+  }
+  
   private String[] createLevel1Folders() {
     ObjectService objSvc = fProvider.getObjectService();
     final int num = 2;
@@ -551,7 +557,7 @@
     
   }
 
-  private String getDocument(String id) {
+  public String getDocument(String id) {
     String returnedId=null;
     try {
       ObjectData res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE,
@@ -591,6 +597,62 @@
     return id;
   }
     
+  private String createVersionSeriesWithThreeVersions() {
+    String verIdV1 = createDocument(PROP_NAME, fRootFolderId, VersioningState.MAJOR);
+    getDocument(verIdV1);
+    
+    ObjectData version = fObjSvc.getObject(fRepositoryId, verIdV1, "*", false, IncludeRelationships.NONE, null, false, false, null);
+    String verSeriesId = getVersionSeriesId(verIdV1, version.getProperties().getProperties());
+
+    // create second version with different content
+    Holder<String>idHolder = new Holder<String>(verIdV1);    
+    Holder<Boolean>contentCopied = new Holder<Boolean>(false);    
+    fVerSvc.checkOut(fRepositoryId, idHolder, null, contentCopied);
+
+    ContentStreamData content2 = createContent('a');
+    PropertiesData newProps = fCreator.getUpdatePropertyList(VersionTestTypeSystemCreator.PROPERTY_ID, "PropertyFromVersion2");    
+    idHolder = new Holder<String>(verIdV1);    
+    // Test check-in and pass content and properties
+    String checkinComment = "Checkin from Unit Test-2.";
+    fVerSvc.checkIn(fRepositoryId, idHolder, true, newProps, content2, checkinComment, null, null, null,
+        null);
+    String verIdV2 = idHolder.getValue();
+
+    // create third version with different content
+    contentCopied = new Holder<Boolean>(false);    
+    fVerSvc.checkOut(fRepositoryId, idHolder, null, contentCopied);
+    ContentStreamData content3 = super.createContent('a');
+    newProps = fCreator.getUpdatePropertyList(VersionTestTypeSystemCreator.PROPERTY_ID, "PropertyFromVersion3");    
+     // Test check-in and pass content and properties
+    checkinComment = "Checkin from Unit Test-3.";
+    fVerSvc.checkIn(fRepositoryId, idHolder, true, newProps, content3, checkinComment, null, null, null,
+        null);
+    String verIdV3 = idHolder.getValue();
+    
+    // Try to update version2 which should fail (on a versioned document only a document that
+    // is checked out can be modified.
+    try {      
+      fCreator.updateProperty(verIdV2, VersionTestTypeSystemCreator.PROPERTY_ID, "ChangeWithoutCheckout");
+      fail("updateProperty for an older version should fail.");
+    } catch (Exception e) {
+      assertTrue(e instanceof CmisUpdateConflictException);
+    }
+    // try to set content on an older version
+    ContentStreamData content4 = super.createContent('x');
+    idHolder = new Holder<String>(verIdV2);
+    try {      
+      fObjSvc.setContentStream(fRepositoryId, idHolder, true, null, content4, null);
+      fail("setContentStream for an older version should fail.");
+    } catch (Exception e) {
+      assertTrue(e instanceof CmisUpdateConflictException);
+    }
+
+   
+
+    return verSeriesId;
+  }
+  
+  
   public static class VersionTestTypeSystemCreator implements TypeCreator {
     static public String VERSION_TEST_DOCUMENT_TYPE_ID = "MyVersionedType";
     static public String PROPERTY_ID = "StringProp";

Modified: incubator/chemistry/trunk/opencmis/src/site/apt/server-inmemory.apt
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/src/site/apt/server-inmemory.apt?rev=912517&r1=912516&r2=912517&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/src/site/apt/server-inmemory.apt (original)
+++ incubator/chemistry/trunk/opencmis/src/site/apt/server-inmemory.apt Mon Feb 22 08:58:39 2010
@@ -1,13 +1,48 @@
   -----
-  OpenCMIS InMemory Repository
+  OpenCMIS In-Memory Repository
   -----
 
-OpenCMIS InMemory Repository
+OpenCMIS In-Memory Repository
+
+  The OpenCMIS In-Memory is an implementation of a CMIS repository that holds content and
+  all metadata in memory. After each restart therefore any data stored in the repository is
+  lost. This implementation has two main purposes:
+  
+  [[1]] Provide a fast backend for testing purposes without any additional dependencies or
+        configuration.
+  
+  [[2]] Provide a sample implementation for the server interface of OpenCMIS.
 
-  <<This repository is not indented for productive use!>>
 
+* Status
 
-* Build and Deploy the Test Repository
+  The code is unstable and under development. Expect any interface to change at any time.
+  The following features are implemented:
+  
+   * Type System and Repository Service
+   
+   * Navigation 
+   
+   * Object Service
+   
+   * Versioning
+   
+  Not supported are currently:
+   
+   * Query
+   
+   * Relationships
+   
+   * ACLs
+   
+   * Policies
+   
+   * Renditions
+   
+   * Unfiling
+   
+     
+* Build and Deploy the Repository
 
   [[1]] {{{./how-to-build.html}Build OpenCMIS}}.
 
@@ -17,3 +52,59 @@
 
   
 * Configure the Repository
+
+  The in-memory server has a couple of parameters that can be set in the repository.properties file
+  ( <<</WEB-INF/classes/repository.properties>>> ). 
+  The CMIS specification does currently not allow to put a repository in a usable state in a 
+  bootstrap process. There is no administrative functionality available to create repositories 
+  or types. The in-memory repository implementation therefore provides a couple of settings that 
+  put the server in a usable state after startup. So, an initial repository is created and an initial 
+  set of type definitions is loaded. The id of the created repository can be configured. The types 
+  to be made available must be provided in a Java class as code. By default there is one such class 
+  in file <<<org.apache.opencmis.inmemory.types.DefaultTypeSystemCreator.java>>> available. You can take 
+  this as an example if you want to provide your own custom types. Such a class must implement the
+  <<<org.apache.opencmis.inmemory.TypeCreator>>> interface which consists of a single method that returns
+  a list of <<<TypeDefinition>>> objects. This method will be called once during startup.
+  
+  Some clients just support read-only access. The in-memory repository supports such clients
+  by providing the possibility to fill a repository on start-up with data (folders and documents).
+  The folder and document types to be used can be configured and also the number of documents
+  and folders that are created. Those configuration parameters start with the prefix
+  <<<RepositoryFiller.>>>
+  
+
++-----------------------------------------------------------------------------------------------------------------
+
+# In Memory Settings
+ # The class that enables the in-memory repository as server implementation
+class=org.apache.opencmis.inmemory.server.ServiceFactory
+
+ # A repository that is created on start-up
+InMemoryServer.RepositoryId=A1
+
+ # The class that used to initialize the type system (creates all types that are available)
+InMemoryServer.TypesCreatorClass=org.apache.opencmis.inmemory.types.DefaultTypeSystemCreator
+
+# settings to initialize a repository with data on start-up
+  # enable or disable
+RepositoryFiller.Enable=true
+  # Type id of documents that are created
+RepositoryFiller.DocumentTypeId=ComplexType
+  # Type id of folders that are created
+RepositoryFiller.FolderTypeId=cmis:folder
+  # Number of documents created per folder
+RepositoryFiller.DocsPerFolder=3
+  # Number of folders created per folder
+RepositoryFiller.FolderPerFolder=2
+  # number of folder levels created (depth of hierarchy)
+RepositoryFiller.Depth=3
+  # Size of content for documents (0=do not create content), default=0
+RepositoryFiller.ContentSizeInKB=32
+  # properties to set for a document
+RepositoryFiller.DocumentProperty.0=StringProp
+#RepositoryFiller.DocumentProperty.1=StringPropMV
+  # properties to set for a folder
+#RepositoryFiller.FolderProperty.0=StringFolderProp
+
++-----------------------------------------------------------------------------------------------------------------
+



Mime
View raw message