chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1509723 [3/3] - in /chemistry/opencmis/branches/inmemory-refactoring/src: main/java/org/apache/chemistry/opencmis/inmemory/ main/java/org/apache/chemistry/opencmis/inmemory/server/ main/java/org/apache/chemistry/opencmis/inmemory/storedobj...
Date Fri, 02 Aug 2013 14:16:06 GMT
Modified: chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java?rev=1509723&r1=1509722&r2=1509723&view=diff
==============================================================================
--- chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java (original)
+++ chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java Fri Aug  2 14:16:05 2013
@@ -23,9 +23,7 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import junit.framework.TestCase;
 
@@ -33,11 +31,14 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.Properties;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
 import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
@@ -49,8 +50,9 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
 import org.apache.chemistry.opencmis.server.support.TypeManager;
 import org.apache.chemistry.opencmis.server.support.TypeValidator;
 import org.junit.Test;
@@ -74,6 +76,8 @@ public class TypeValidationTest extends 
     private static final String STRING_PROP_TYPE_SUPER = "StringPropSuper";
     private static final String STRING_PROP_TYPE_SUB = "StringPropSub";
     private static final BindingsObjectFactory FACTORY = new BindingsObjectFactoryImpl();
+    static TypeDefinitionFactory typeFactory =  DocumentTypeCreationHelper.getTypeDefinitionFactory();
+
 
     private static List<PropertyData<?>> createPropertiesWithNameAndTypeId(String typeId) {
         List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
@@ -463,308 +467,343 @@ public class TypeValidationTest extends 
      * 
      * @return type definition of sample type
      */
-    private static InMemoryDocumentTypeDefinition buildMyType() {
+    private static DocumentTypeDefinition buildMyType() {
         // always add CMIS default types
 
-        InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(MY_DOC_TYPE,
-                "Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        // create a boolean property definition
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-        PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
-                "Sample Boolean Property", Updatability.READONLY);
-        ((PropertyBooleanDefinitionImpl) prop).setIsRequired(true);
-        propertyDefinitions.put(prop.getId(), prop);
-
-        prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
-                "Sample Boolean multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop.getId(), prop);
-
-        PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
-                "Sample DateTime Property", Updatability.READONLY);
-        propertyDefinitions.put(prop2.getId(), prop2);
-
-        prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
-                "Sample DateTime multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop2.getId(), prop2);
-
-        PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
-                "Sample Decimal Property", Updatability.READONLY);
-        propertyDefinitions.put(prop3.getId(), prop3);
-
-        prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalPropMV", "Sample Decimal multi-value Property",
-                Updatability.READONLY);
-        propertyDefinitions.put(prop3.getId(), prop3);
-
-        PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
-                "Sample Html Property", Updatability.READONLY);
-        propertyDefinitions.put(prop4.getId(), prop4);
-
-        prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlPropMV", "Sample Html multi-value Property",
-                Updatability.READONLY);
-        propertyDefinitions.put(prop4.getId(), prop4);
-
-        PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp", "Sample Id Property",
-                Updatability.READONLY);
-        propertyDefinitions.put(prop5.getId(), prop5);
-
-        prop5 = PropertyCreationHelper.createIdDefinition("IdPropMV", "Sample Id Html multi-value Property",
-                Updatability.READONLY);
-        propertyDefinitions.put(prop5.getId(), prop5);
-
-        PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
-                "Sample Int Property", Updatability.READONLY);
-        propertyDefinitions.put(prop6.getId(), prop6);
-
-        prop6 = PropertyCreationHelper.createIntegerDefinition("IntPropMV", "Sample Int multi-value Property",
-                Updatability.READONLY);
-        propertyDefinitions.put(prop6.getId(), prop6);
-
-        PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
-                "Sample String Property", Updatability.READONLY);
-        propertyDefinitions.put(prop7.getId(), prop7);
-
-        PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property",
-                Updatability.READONLY);
-        propertyDefinitions.put(prop8.getId(), prop8);
-
-        prop8 = PropertyCreationHelper.createUriDefinition("UriPropMV", "Sample Uri multi-value Property",
-                Updatability.READONLY);
-        propertyDefinitions.put(prop8.getId(), prop8);
-
-        PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
-                "Sample Pick List Property", Updatability.READONLY);
-
-        PropertyCreationHelper.addElemToPicklist(prop9, "red");
-        PropertyCreationHelper.addElemToPicklist(prop9, "green");
-        PropertyCreationHelper.addElemToPicklist(prop9, "blue");
-        PropertyCreationHelper.addElemToPicklist(prop9, "black");
-        PropertyCreationHelper.setDefaultValue(prop9, "blue");
-
-        cmisType.setPropertyDefinitions(propertyDefinitions);
-
-        return cmisType;
-    }
-
-    private static InMemoryDocumentTypeDefinition buildTypeWithStringProp() {
-        InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(STRING_DOC_TYPE,
-                "String Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        // create a String property definition
-
-        PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE,
-                "Sample String Property", Updatability.READONLY);
-        propDef.setMaxLength(BigInteger.valueOf(10));
-        propertyDefinitions.put(propDef.getId(), propDef);
-
-        cmisType.setPropertyDefinitions(propertyDefinitions);
-
-        return cmisType;
-    }
-
-    private static InMemoryDocumentTypeDefinition buildTypeWithIntegerProp() {
-        InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(INT_DOC_TYPE,
-                "Int Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        // create a String property definition
-
-        PropertyIntegerDefinitionImpl propDef = PropertyCreationHelper.createIntegerDefinition(INT_PROP_TYPE,
-                "Sample Integer Property", Updatability.READONLY);
-        propDef.setMinValue(BigInteger.valueOf(-1));
-        propDef.setMaxValue(BigInteger.valueOf(1));
-        propertyDefinitions.put(propDef.getId(), propDef);
-
-        cmisType.setPropertyDefinitions(propertyDefinitions);
-
-        return cmisType;
-    }
-
-    private static InMemoryDocumentTypeDefinition buildTypeWithDecimalProp() {
-        InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(DECIMAL_DOC_TYPE,
-                "Decimal Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        // create a String property definition
-
-        PropertyDecimalDefinitionImpl propDef = PropertyCreationHelper.createDecimalDefinition(DECIMAL_PROP_TYPE,
-                "Sample Decimal Property", Updatability.READONLY);
-        propDef.setMinValue(BigDecimal.valueOf(-1.5));
-        propDef.setMaxValue(BigDecimal.valueOf(1.5));
-        propertyDefinitions.put(propDef.getId(), propDef);
-
-        cmisType.setPropertyDefinitions(propertyDefinitions);
-
-        return cmisType;
-    }
-
-    public static InMemoryDocumentTypeDefinition buildTypeWithPickList(Cardinality cardinality) {
-        InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(PICK_LIST_DOC_TYPE,
-                "PickList Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        // create a String property definition
-
-        PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
-                "Sample PickList (choice) Property", Updatability.READONLY);
-        List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
-        ChoiceImpl<String> elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("red"));
-        elem.setDisplayName("Red");
-        choiceList.add(elem);
-        elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("green"));
-        elem.setDisplayName("Green");
-        choiceList.add(elem);
-        elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("blue"));
-        elem.setDisplayName("Blue");
-        choiceList.add(elem);
-        elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("black"));
-        elem.setDisplayName("Black");
-        choiceList.add(elem);
-        propDef.setChoices(choiceList);
-        propDef.setDefaultValue(Collections.singletonList("blue"));
-        propDef.setCardinality(cardinality);
-        propertyDefinitions.put(propDef.getId(), propDef);
-        cmisType.setPropertyDefinitions(propertyDefinitions);
-
-        return cmisType;
-    }
-
-    public static InMemoryDocumentTypeDefinition buildTypeWithMultiPickList() {
-        InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(PICK_LIST_DOC_TYPE,
-                "PickList Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        // create a String property definition
-
-        PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
-                "Sample PickList (choice) Property", Updatability.READONLY);
-        List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
-        ChoiceImpl<String> elem = new ChoiceImpl<String>();
-        List<String> valueList = new ArrayList<String>();
-        valueList.add("red");
-        valueList.add("green");
-        valueList.add("blue");
-        elem.setValue(valueList);
-        elem.setDisplayName("RGB");
-        choiceList.add(elem);
-
-        elem = new ChoiceImpl<String>();
-        valueList = new ArrayList<String>();
-        valueList.add("cyan");
-        valueList.add("magenta");
-        valueList.add("yellow");
-        valueList.add("black");
-        elem.setValue(valueList);
-        elem.setDisplayName("CMYK");
-        choiceList.add(elem);
-
-        propDef.setChoices(choiceList);
-        // propDef.setDefaultValue(...);
-        propDef.setCardinality(Cardinality.MULTI);
-        propertyDefinitions.put(propDef.getId(), propDef);
-        cmisType.setPropertyDefinitions(propertyDefinitions);
-
-        return cmisType;
-    }
-
-    public static InMemoryDocumentTypeDefinition buildTypeWithHierachicalPickList(Cardinality cardinality) {
-        InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(PICK_LIST_DOC_TYPE,
-                "PickList Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        // create a String property definition
-
-        // Create a two-level pick list with an outer property list state and an
-        // inner
-        // list of city
-        PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
-                "Sample PickList (choice) Property", Updatability.READONLY);
-        List<Choice<String>> choiceListOuter = new ArrayList<Choice<String>>();
-
-        ChoiceImpl<String> elemOuter = new ChoiceImpl<String>();
-        elemOuter.setDisplayName("Bavaria");
-        List<Choice<String>> choiceListInner = new ArrayList<Choice<String>>();
-        ChoiceImpl<String> elemInner = new ChoiceImpl<String>();
-        elemInner.setDisplayName("Munich");
-        elemInner.setValue(Collections.singletonList("munich"));
-        choiceListInner.add(elemInner);
-        elemInner = new ChoiceImpl<String>();
-        elemInner.setDisplayName("Ingolstadt");
-        elemInner.setValue(Collections.singletonList("ingolstadt"));
-        choiceListInner.add(elemInner);
-        elemInner = new ChoiceImpl<String>();
-        elemInner.setDisplayName("Passau");
-        elemInner.setValue(Collections.singletonList("passau"));
-        choiceListInner.add(elemInner);
-        elemOuter.setChoice(choiceListInner);
-        choiceListOuter.add(elemOuter);
-
-        elemOuter = new ChoiceImpl<String>();
-        elemOuter.setDisplayName("Baden Wurtemberg");
-        choiceListInner = new ArrayList<Choice<String>>();
-        elemInner = new ChoiceImpl<String>();
-        elemInner.setDisplayName("Stuttgart");
-        elemInner.setValue(Collections.singletonList("stuttgart"));
-        choiceListInner.add(elemInner);
-        elemInner = new ChoiceImpl<String>();
-        elemInner.setDisplayName("Karlsruhe");
-        elemInner.setValue(Collections.singletonList("karlsruhe"));
-        choiceListInner.add(elemInner);
-        elemInner = new ChoiceImpl<String>();
-        elemInner.setDisplayName("Walldorf");
-        elemInner.setValue(Collections.singletonList("walldorf"));
-        choiceListInner.add(elemInner);
-        elemOuter.setChoice(choiceListInner);
-        choiceListOuter.add(elemOuter);
-
-        propDef.setChoices(choiceListOuter);
-        propDef.setCardinality(cardinality);
-        propertyDefinitions.put(propDef.getId(), propDef);
-        cmisType.setPropertyDefinitions(propertyDefinitions);
+        try {
+            MutableDocumentTypeDefinition cmisType;        
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(MY_DOC_TYPE);
+            cmisType.setDisplayName("Document Type for Validation");
+            cmisType.setDescription("InMemory test type definition " + MY_DOC_TYPE);
+ 
+            // create a boolean property definition
+
+            PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
+                    "Sample Boolean Property", Updatability.READONLY);
+            ((PropertyBooleanDefinitionImpl) prop).setIsRequired(true);
+            cmisType.addPropertyDefinition(prop);
+
+            prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
+                    "Sample Boolean multi-value Property", Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop);
+
+            PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
+                    "Sample DateTime Property", Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop2);
+
+            prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
+                    "Sample DateTime multi-value Property", Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop2);
+
+            PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
+                    "Sample Decimal Property", Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop3);
+
+            prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalPropMV", "Sample Decimal multi-value Property",
+                    Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop3);
+
+            PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
+                    "Sample Html Property", Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop4);
+
+            prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlPropMV", "Sample Html multi-value Property",
+                    Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop4);
+
+            PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp", "Sample Id Property",
+                    Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop5);
+
+            prop5 = PropertyCreationHelper.createIdDefinition("IdPropMV", "Sample Id Html multi-value Property",
+                    Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop5);
+
+            PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
+                    "Sample Int Property", Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop6);
+
+            prop6 = PropertyCreationHelper.createIntegerDefinition("IntPropMV", "Sample Int multi-value Property",
+                    Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop6);
+
+            PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
+                    "Sample String Property", Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop7);
+
+            PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property",
+                    Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop8);
+
+            prop8 = PropertyCreationHelper.createUriDefinition("UriPropMV", "Sample Uri multi-value Property",
+                    Updatability.READONLY);
+            cmisType.addPropertyDefinition(prop8);
+
+            PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
+                    "Sample Pick List Property", Updatability.READONLY);
+
+            PropertyCreationHelper.addElemToPicklist(prop9, "red");
+            PropertyCreationHelper.addElemToPicklist(prop9, "green");
+            PropertyCreationHelper.addElemToPicklist(prop9, "blue");
+            PropertyCreationHelper.addElemToPicklist(prop9, "black");
+            PropertyCreationHelper.setDefaultValue(prop9, "blue");
+            cmisType.addPropertyDefinition(prop9);
+
+            return cmisType;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
+    }
+
+    private static DocumentTypeDefinition buildTypeWithStringProp() {
+        try {
+            MutableDocumentTypeDefinition cmisType;        
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(STRING_DOC_TYPE);
+            cmisType.setDisplayName("String Document Type for Validation");
+            cmisType.setDescription("InMemory test type definition " + STRING_DOC_TYPE);
+
+            // create a String property definition
+            PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE,
+                    "Sample String Property", Updatability.READONLY);
+            propDef.setMaxLength(BigInteger.valueOf(10));
+            cmisType.addPropertyDefinition(propDef);
+
+            return cmisType;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
+    }
+
+    private static DocumentTypeDefinition buildTypeWithIntegerProp() {
+        try {
+            MutableDocumentTypeDefinition cmisType;        
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(INT_DOC_TYPE);
+            cmisType.setDisplayName("Int Document Type for Validation");
+            cmisType.setDescription("InMemory test type definition " + INT_DOC_TYPE);
+
+            // create a String property definition
+
+            PropertyIntegerDefinitionImpl propDef = PropertyCreationHelper.createIntegerDefinition(INT_PROP_TYPE,
+                    "Sample Integer Property", Updatability.READONLY);
+            propDef.setMinValue(BigInteger.valueOf(-1));
+            propDef.setMaxValue(BigInteger.valueOf(1));
+            cmisType.addPropertyDefinition(propDef);
+
+            return cmisType;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
+    }
+
+    private static DocumentTypeDefinition buildTypeWithDecimalProp() {
+        try {
+            MutableDocumentTypeDefinition cmisType;        
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(DECIMAL_DOC_TYPE);
+            cmisType.setDisplayName("Decimal Type for Validation");
+            cmisType.setDescription("InMemory test type definition " + DECIMAL_DOC_TYPE);
+
+            // create a String property definition
+
+            PropertyDecimalDefinitionImpl propDef = PropertyCreationHelper.createDecimalDefinition(DECIMAL_PROP_TYPE,
+                    "Sample Decimal Property", Updatability.READONLY);
+            propDef.setMinValue(BigDecimal.valueOf(-1.5));
+            propDef.setMaxValue(BigDecimal.valueOf(1.5));
+            cmisType.addPropertyDefinition(propDef);
+
+            return cmisType;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
+    }
+
+    public static DocumentTypeDefinition buildTypeWithPickList(Cardinality cardinality) {
+        try {
+            MutableDocumentTypeDefinition cmisType;        
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(PICK_LIST_DOC_TYPE);
+            cmisType.setDisplayName("PickList Type for Validation");
+            cmisType.setDescription("InMemory test type definition " + PICK_LIST_DOC_TYPE);
+
+            // create a String property definition
+            PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
+                    "Sample PickList (choice) Property", Updatability.READONLY);
+            List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
+            ChoiceImpl<String> elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("red"));
+            elem.setDisplayName("Red");
+            choiceList.add(elem);
+            elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("green"));
+            elem.setDisplayName("Green");
+            choiceList.add(elem);
+            elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("blue"));
+            elem.setDisplayName("Blue");
+            choiceList.add(elem);
+            elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("black"));
+            elem.setDisplayName("Black");
+            choiceList.add(elem);
+            propDef.setChoices(choiceList);
+            propDef.setDefaultValue(Collections.singletonList("blue"));
+            propDef.setCardinality(cardinality);
+            cmisType.addPropertyDefinition(propDef);
+
+            return cmisType;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
+    }
+
+    public static DocumentTypeDefinition buildTypeWithMultiPickList() {
+        try {
+            MutableDocumentTypeDefinition cmisType;        
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(PICK_LIST_DOC_TYPE);
+            cmisType.setDisplayName("MDocument Type for Validation");
+            cmisType.setDescription("PickList test type definition " + PICK_LIST_DOC_TYPE);
+
+            // create a String property definition
+            PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
+                    "Sample PickList (choice) Property", Updatability.READONLY);
+            List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
+            ChoiceImpl<String> elem = new ChoiceImpl<String>();
+            List<String> valueList = new ArrayList<String>();
+            valueList.add("red");
+            valueList.add("green");
+            valueList.add("blue");
+            elem.setValue(valueList);
+            elem.setDisplayName("RGB");
+            choiceList.add(elem);
+
+            elem = new ChoiceImpl<String>();
+            valueList = new ArrayList<String>();
+            valueList.add("cyan");
+            valueList.add("magenta");
+            valueList.add("yellow");
+            valueList.add("black");
+            elem.setValue(valueList);
+            elem.setDisplayName("CMYK");
+            choiceList.add(elem);
+
+            propDef.setChoices(choiceList);
+            // propDef.setDefaultValue(...);
+            propDef.setCardinality(Cardinality.MULTI);
+            cmisType.addPropertyDefinition(propDef);
+
+            return cmisType;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
+    }
+
+    public static DocumentTypeDefinition buildTypeWithHierachicalPickList(Cardinality cardinality) {
+        try {
+            MutableDocumentTypeDefinition cmisType;        
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(PICK_LIST_DOC_TYPE);
+            cmisType.setDisplayName("PickList Type for Validation");
+            cmisType.setDescription("InMemory test type definition " + PICK_LIST_DOC_TYPE);
+
+            // create a String property definition
+
+            // Create a two-level pick list with an outer property list state and an
+            // inner
+            // list of city
+            PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
+                    "Sample PickList (choice) Property", Updatability.READONLY);
+            List<Choice<String>> choiceListOuter = new ArrayList<Choice<String>>();
+
+            ChoiceImpl<String> elemOuter = new ChoiceImpl<String>();
+            elemOuter.setDisplayName("Bavaria");
+            List<Choice<String>> choiceListInner = new ArrayList<Choice<String>>();
+            ChoiceImpl<String> elemInner = new ChoiceImpl<String>();
+            elemInner.setDisplayName("Munich");
+            elemInner.setValue(Collections.singletonList("munich"));
+            choiceListInner.add(elemInner);
+            elemInner = new ChoiceImpl<String>();
+            elemInner.setDisplayName("Ingolstadt");
+            elemInner.setValue(Collections.singletonList("ingolstadt"));
+            choiceListInner.add(elemInner);
+            elemInner = new ChoiceImpl<String>();
+            elemInner.setDisplayName("Passau");
+            elemInner.setValue(Collections.singletonList("passau"));
+            choiceListInner.add(elemInner);
+            elemOuter.setChoice(choiceListInner);
+            choiceListOuter.add(elemOuter);
+
+            elemOuter = new ChoiceImpl<String>();
+            elemOuter.setDisplayName("Baden Wurtemberg");
+            choiceListInner = new ArrayList<Choice<String>>();
+            elemInner = new ChoiceImpl<String>();
+            elemInner.setDisplayName("Stuttgart");
+            elemInner.setValue(Collections.singletonList("stuttgart"));
+            choiceListInner.add(elemInner);
+            elemInner = new ChoiceImpl<String>();
+            elemInner.setDisplayName("Karlsruhe");
+            elemInner.setValue(Collections.singletonList("karlsruhe"));
+            choiceListInner.add(elemInner);
+            elemInner = new ChoiceImpl<String>();
+            elemInner.setDisplayName("Walldorf");
+            elemInner.setValue(Collections.singletonList("walldorf"));
+            choiceListInner.add(elemInner);
+            elemOuter.setChoice(choiceListInner);
+            choiceListOuter.add(elemOuter);
+
+            propDef.setChoices(choiceListOuter);
+            propDef.setCardinality(cardinality);
+            cmisType.addPropertyDefinition(propDef);
 
-        return cmisType;
+            return cmisType;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
     }
 
     private static TypeManager buildInheritedTypes() {
+        try {
 
-        TypeManagerImpl tm = new TypeManagerImpl();
-        tm.initTypeSystem(null, true); // create CMIS default types
+            TypeManagerImpl tm = new TypeManagerImpl();
+            tm.initTypeSystem(null, true); // create CMIS default types
 
-        // create super type
-        InMemoryDocumentTypeDefinition cmisSuperType = new InMemoryDocumentTypeDefinition(DOC_TYPE_SUPER,
-                "Document Type With a child", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        // create a String property definition
-        PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE_SUPER,
-                "Sample String Property SuperType", Updatability.READONLY);
-        propDef.setMaxLength(BigInteger.valueOf(10));
-        propertyDefinitions.put(propDef.getId(), propDef);
-        cmisSuperType.setPropertyDefinitions(propertyDefinitions);
-
-        // create sub type
-        InMemoryDocumentTypeDefinition cmisSubType = new InMemoryDocumentTypeDefinition(DOC_TYPE_SUB,
-                "Document Type With a parent", cmisSuperType);
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        // create a String property definition
-        propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE_SUB, "Sample String Property Subtype",
-                Updatability.READONLY);
-        propDef.setMaxLength(BigInteger.valueOf(20));
-        propertyDefinitions.put(propDef.getId(), propDef);
-        cmisSubType.setPropertyDefinitions(propertyDefinitions);
+            // create super type
+            MutableDocumentTypeDefinition cmisSuperType;        
+            cmisSuperType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisSuperType.setId(DOC_TYPE_SUPER);
+            cmisSuperType.setDisplayName("Document Type With a child");
+            cmisSuperType.setDescription("InMemory test type definition " + DOC_TYPE_SUPER);
+
+            // create a String property definition
+            PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE_SUPER,
+                    "Sample String Property SuperType", Updatability.READONLY);
+            propDef.setMaxLength(BigInteger.valueOf(10));
+            cmisSuperType.addPropertyDefinition(propDef);
+
+            tm.addTypeDefinition(cmisSuperType, false);
+
+            // create sub type
+            MutableDocumentTypeDefinition cmisSubType;        
+            cmisSubType = typeFactory.createChildDocumentTypeDefinition(cmisSuperType, null);
+            cmisSubType.setId(DOC_TYPE_SUB);
+            cmisSubType.setDisplayName("Document Type With a parent");
+            cmisSubType.setDescription("InMemory test type definition " + DOC_TYPE_SUB);
+
+            // create a String property definition
+            propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE_SUB, "Sample String Property Subtype",
+                    Updatability.READONLY);
+            propDef.setMaxLength(BigInteger.valueOf(20));
+            cmisSubType.addPropertyDefinition(propDef);
 
-        tm.addTypeDefinition(cmisSuperType);
-        tm.addTypeDefinition(cmisSubType);
+            tm.addTypeDefinition(cmisSubType, false);
 
-        return tm;
+            return tm;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
     }
 
 }

Modified: chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java?rev=1509723&r1=1509722&r2=1509723&view=diff
==============================================================================
--- chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java (original)
+++ chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java Fri Aug  2 14:16:05 2013
@@ -25,15 +25,19 @@ package org.apache.chemistry.opencmis.in
  */
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
@@ -42,10 +46,9 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemorySecondaryTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
 
 public class UnitTestTypeSystemCreator implements TypeCreator {
     public static final List<TypeDefinition> singletonTypes = buildTypesList();
@@ -104,246 +107,307 @@ public class UnitTestTypeSystemCreator i
      * @return typesMap map filled with created types
      */
     private static List<TypeDefinition> buildTypesList() {
-        // always add CMIS default types
+        TypeDefinitionFactory typeFactory =  DocumentTypeCreationHelper.getTypeDefinitionFactory();
         List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
 
-        InMemoryDocumentTypeDefinition cmisType1 = new InMemoryDocumentTypeDefinition("MyDocType1",
-                "My Type 1 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-        typesList.add(cmisType1);
-
-        InMemoryDocumentTypeDefinition cmisType2 = new InMemoryDocumentTypeDefinition("MyDocType2",
-                "My Type 2 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-        typesList.add(cmisType2);
-
-        InMemoryDocumentTypeDefinition cmisType11 = new InMemoryDocumentTypeDefinition("MyDocType1.1",
-                "My Type 3 Level 2", cmisType1);
-        typesList.add(cmisType11);
-
-        InMemoryDocumentTypeDefinition cmisType111 = new InMemoryDocumentTypeDefinition("MyDocType1.1.1",
-                "My Type 4 Level 3", cmisType11);
-        typesList.add(cmisType111);
-
-        InMemoryDocumentTypeDefinition cmisType112 = new InMemoryDocumentTypeDefinition("MyDocType1.1.2",
-                "My Type 5 Level 3", cmisType11);
-        typesList.add(cmisType112);
-
-        InMemoryDocumentTypeDefinition cmisType12 = new InMemoryDocumentTypeDefinition("MyDocType1.2",
-                "My Type 6 Level 2", cmisType1);
-        typesList.add(cmisType12);
-
-        InMemoryDocumentTypeDefinition cmisType21 = new InMemoryDocumentTypeDefinition("MyDocType2.1",
-                "My Type 7 Level 2", cmisType2);
-        typesList.add(cmisType21);
-
-        InMemoryDocumentTypeDefinition cmisType22 = new InMemoryDocumentTypeDefinition("MyDocType2.2",
-                "My Type 8 Level 2", cmisType2);
-        typesList.add(cmisType22);
-        InMemoryDocumentTypeDefinition cmisType23 = new InMemoryDocumentTypeDefinition("MyDocType2.3",
-                "My Type 9 Level 2", cmisType2);
-        typesList.add(cmisType23);
-        InMemoryDocumentTypeDefinition cmisType24 = new InMemoryDocumentTypeDefinition("MyDocType2.4",
-                "My Type 10 Level 2", cmisType2);
-        typesList.add(cmisType24);
-        InMemoryDocumentTypeDefinition cmisType25 = new InMemoryDocumentTypeDefinition("MyDocType2.5",
-                "My Type 11 Level 2", cmisType2);
-        typesList.add(cmisType25);
-
-        InMemoryDocumentTypeDefinition cmisType26 = new InMemoryDocumentTypeDefinition("MyDocType2.6",
-                "My Type 12 Level 2", cmisType2);
-        typesList.add(cmisType26);
-        InMemoryDocumentTypeDefinition cmisType27 = new InMemoryDocumentTypeDefinition("MyDocType2.7",
-                "My Type 13 Level 2", cmisType2);
-        typesList.add(cmisType27);
-        InMemoryDocumentTypeDefinition cmisType28 = new InMemoryDocumentTypeDefinition("MyDocType2.8",
-                "My Type 14 Level 2", cmisType2);
-        typesList.add(cmisType28);
-        InMemoryDocumentTypeDefinition cmisType29 = new InMemoryDocumentTypeDefinition("MyDocType2.9",
-                "My Type 15 Level 2", cmisType2);
-        typesList.add(cmisType29);
-
-        // create a complex type with properties
-        InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(COMPLEX_TYPE,
-                "Complex type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        // create a boolean property definition
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-        PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition(PROP_ID_BOOLEAN,
-                "Sample Boolean Property", Updatability.READONLY);
-        propertyDefinitions.put(prop.getId(), prop);
-
-        prop = PropertyCreationHelper.createBooleanMultiDefinition(PROP_ID_BOOLEAN_MULTI_VALUE,
-                "Sample Boolean multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop.getId(), prop);
-
-        PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition(PROP_ID_DATETIME,
-                "Sample DateTime Property", Updatability.READONLY);
-        propertyDefinitions.put(prop2.getId(), prop2);
-
-        prop2 = PropertyCreationHelper.createDateTimeMultiDefinition(PROP_ID_DATETIME_MULTI_VALUE,
-                "Sample DateTime multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop2.getId(), prop2);
-
-        PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition(PROP_ID_DECIMAL,
-                "Sample Decimal Property", Updatability.READONLY);
-        propertyDefinitions.put(prop3.getId(), prop3);
-
-        prop3 = PropertyCreationHelper.createDecimalMultiDefinition(PROP_ID_DECIMAL_MULTI_VALUE, "Sample Decimal multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop3.getId(), prop3);
-
-        PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition(PROP_ID_HTML,
-                "Sample Html Property", Updatability.READONLY);
-        propertyDefinitions.put(prop4.getId(), prop4);
-
-        prop4 = PropertyCreationHelper.createHtmlMultiDefinition(PROP_ID_HTML_MULTI_VALUE, "Sample Html multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop4.getId(), prop4);
-
-        PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition(PROP_ID_ID, "Sample Id Property", Updatability.READONLY);
-        propertyDefinitions.put(prop5.getId(), prop5);
-
-        prop5 = PropertyCreationHelper.createIdMultiDefinition(PROP_ID_ID_MULTI_VALUE, "Sample Id Html multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop5.getId(), prop5);
-
-        PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition(PROP_ID_INT,
-                "Sample Int Property", Updatability.READONLY);
-        propertyDefinitions.put(prop6.getId(), prop6);
-
-        prop6 = PropertyCreationHelper.createIntegerMultiDefinition(PROP_ID_INT_MULTI_VALUE, "Sample Int multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop6.getId(), prop6);
-
-        PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition(PROP_ID_STRING,
-                "Sample String Property", Updatability.READONLY);
-        propertyDefinitions.put(prop7.getId(), prop7);
-
-        prop7 = PropertyCreationHelper.createStringMultiDefinition(PROP_ID_STRING_MULTI_VALUE,
-        "Sample String multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop7.getId(), prop7);
-
-        PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition(PROP_ID_URI, "Sample Uri Property", Updatability.READONLY);
-        propertyDefinitions.put(prop8.getId(), prop8);
-
-        prop8 = PropertyCreationHelper.createUriMultiDefinition(PROP_ID_URI_MULTI_VALUE, "Sample Uri multi-value Property", Updatability.READONLY);
-        propertyDefinitions.put(prop8.getId(), prop8);
-
-        PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
-                "Sample Pick List Property", Updatability.READONLY);
-        List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
-        ChoiceImpl<String> elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("red"));
-        choiceList.add(elem);
-        elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("green"));
-        choiceList.add(elem);
-        elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("blue"));
-        choiceList.add(elem);
-        elem = new ChoiceImpl<String>();
-        elem.setValue(Collections.singletonList("black"));
-        choiceList.add(elem);
-        prop9.setChoices(choiceList);
-        prop9.setDefaultValue(Collections.singletonList("blue"));
-        propertyDefinitions.put(prop9.getId(), prop9);
-
-        /*
-         * try short form: / PropertyCreationHelper.addElemToPicklist(prop9,
-         * "red"); PropertyCreationHelper.addElemToPicklist(prop9, "green");
-         * PropertyCreationHelper.addElemToPicklist(prop9, "blue");
-         * PropertyCreationHelper.addElemToPicklist(prop9, "black");
-         * PropertyCreationHelper.setDefaultValue(prop9, "blue"); /
-         */
-
-        cmisComplexType.addCustomPropertyDefinitions(propertyDefinitions);
-
-        // add type to types collection
-        typesList.add(cmisComplexType);
-
-        // create a type hierarchy with inherited properties
-        InMemoryDocumentTypeDefinition cmisDocTypeTopLevel = new InMemoryDocumentTypeDefinition(TOPLEVEL_TYPE,
-                "Document type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        InMemoryDocumentTypeDefinition cmisDocTypeLevel1 = new InMemoryDocumentTypeDefinition(LEVEL1_TYPE,
-                "Document type with inherited properties, Level 2", cmisDocTypeTopLevel);
-
-        InMemoryDocumentTypeDefinition cmisDocTypeLevel2 = new InMemoryDocumentTypeDefinition(LEVEL2_TYPE,
-                "Document type with inherited properties, Level 3", cmisDocTypeLevel1);
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
-                "Sample String Property", Updatability.READONLY);
-        propertyDefinitions.put(propTop.getId(), propTop);
-        cmisDocTypeTopLevel.addCustomPropertyDefinitions(propertyDefinitions);
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
-                "String Property Level 1", Updatability.READONLY);
-        propertyDefinitions.put(propLevel1.getId(), propLevel1);
-        cmisDocTypeLevel1.addCustomPropertyDefinitions(propertyDefinitions);
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
-                "String Property Level 2", Updatability.READONLY);
-        propertyDefinitions.put(propLevel2.getId(), propLevel2);
-        cmisDocTypeLevel2.addCustomPropertyDefinitions(propertyDefinitions);
-
-        // create a versioned type with properties
-        InMemoryDocumentTypeDefinition cmisVersionedType = new InMemoryDocumentTypeDefinition(VERSIONED_TYPE,
-                "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        // create a single String property definition
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-        PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(VERSION_PROPERTY_ID,
-                "Sample String Property", Updatability.READONLY);
-        propertyDefinitions.put(prop1.getId(), prop1);
-
-        cmisVersionedType.addCustomPropertyDefinitions(propertyDefinitions);
-        cmisVersionedType.setIsVersionable(true); // make it a versionable type;
-
-        // create a folder type
-        // create a complex type with properties
-        InMemoryFolderTypeDefinition cmisFolderType = new InMemoryFolderTypeDefinition(FOLDER_TYPE,
-                "Folder type with properties", InMemoryFolderTypeDefinition.getRootFolderType());
-
-        // create a two property definitions for folder
-
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-        prop6 = PropertyCreationHelper.createIntegerDefinition(PROP_ID_INT, "Sample Folder Int Property", Updatability.READONLY);
-        propertyDefinitions.put(prop6.getId(), prop6);
-
-        prop7 = PropertyCreationHelper.createStringDefinition(PROP_ID_STRING,
-            "Sample Folder String Property", Updatability.READONLY);
-        propertyDefinitions.put(prop7.getId(), prop7);
-        cmisFolderType.addCustomPropertyDefinitions(propertyDefinitions);
-
-        // CMIS 1.1 create a secondary type
-        InMemorySecondaryTypeDefinition cmisSecondaryType = new InMemorySecondaryTypeDefinition(SECONDARY_TYPE, 
-                "MySecondaryType");
-        // create a single String property definition
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-        PropertyStringDefinitionImpl propStr = PropertyCreationHelper.createStringDefinition(SECONDARY_STRING_PROP,
-                "Secondary String Property", Updatability.READWRITE);
-        propertyDefinitions.put(propStr.getId(), propStr);
-        PropertyIntegerDefinitionImpl propInt = PropertyCreationHelper.createIntegerDefinition(SECONDARY_INTEGER_PROP,
-                "Secondary Integer Property", Updatability.READWRITE);
-        propInt.setIsRequired(true);
-        propertyDefinitions.put(propInt.getId(), propInt);
-        cmisSecondaryType.addCustomPropertyDefinitions(propertyDefinitions);
-
-        InMemorySecondaryTypeDefinition cmisSecondaryType2 = new InMemorySecondaryTypeDefinition(SECONDARY_TYPE_2, 
-                "MySecondaryType-2");
-
-        // add type to types collectio
-        typesList.add(cmisDocTypeTopLevel);
-        typesList.add(cmisDocTypeLevel1);
-        typesList.add(cmisDocTypeLevel2);
-        typesList.add(cmisVersionedType);
-        typesList.add(cmisFolderType);
-        typesList.add(cmisSecondaryType);
-        typesList.add(cmisSecondaryType2);
-        return typesList;
+        try {
+            MutableDocumentTypeDefinition cmisType1;        
+            cmisType1 = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType1.setId(LEVEL1_TYPE);
+            cmisType1.setDisplayName("Document type with inherited properties, Level 2");
+            cmisType1.setDescription("Builtin InMemory type definition " + LEVEL1_TYPE);
+
+            cmisType1 = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType1.setId("MyDocType1");
+            cmisType1.setDisplayName("My Type 1 Level 1");
+            cmisType1.setDescription("Builtin InMemory type definition MyDocType1");
+            typesList.add(cmisType1);
+
+            MutableDocumentTypeDefinition cmisType2;        
+            cmisType2 = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType2.setId("MyDocType2");
+            cmisType2.setDisplayName("My Type 2 Level 1");
+            cmisType2.setDescription("Builtin InMemory type definition MyDocType2");
+            typesList.add(cmisType2);
+
+            MutableDocumentTypeDefinition cmisType11;        
+            cmisType11 = typeFactory.createChildDocumentTypeDefinition(cmisType1, null);
+            cmisType11.setId("MyDocType1.1");
+            cmisType11.setDisplayName("My Type 3 Level 2");
+            cmisType11.setDescription("Builtin InMemory type definition MyDocType1.1");
+            typesList.add(cmisType11);
+
+            MutableDocumentTypeDefinition cmisType111;        
+            cmisType111 = typeFactory.createChildDocumentTypeDefinition(cmisType11, null);
+            cmisType111.setId("MyDocType1.1.1");
+            cmisType111.setDisplayName("My Type 4 Level 3");
+            cmisType111.setDescription("Builtin InMemory type definition MyDocType1.1.1");
+            typesList.add(cmisType111);
+
+            MutableDocumentTypeDefinition cmisType112;        
+            cmisType112 = typeFactory.createChildDocumentTypeDefinition(cmisType11, null);
+            cmisType112.setId("MyDocType1.1.2");
+            cmisType112.setDisplayName("My Type 5 Level 3");
+            cmisType112.setDescription("Builtin InMemory type definition MyDocType1.1.2");
+            typesList.add(cmisType112);
+
+            MutableDocumentTypeDefinition cmisType12;        
+            cmisType12 = typeFactory.createChildDocumentTypeDefinition(cmisType1, null);
+            cmisType12.setId("MyDocType1.2");
+            cmisType12.setDisplayName("My Type 6 Level 2");
+            cmisType12.setDescription("Builtin InMemory type definition MyDocType1.2");
+            typesList.add(cmisType12);
+
+            MutableDocumentTypeDefinition cmisType21;        
+            cmisType21 = typeFactory.createChildDocumentTypeDefinition(cmisType2, null);
+            cmisType21.setId("MyDocType2.1");
+            cmisType21.setDisplayName("My Type 7 Level 2");
+            cmisType21.setDescription("Builtin InMemory type definition MyDocType2.1");
+            typesList.add(cmisType21);
+
+            MutableDocumentTypeDefinition cmisType22;        
+            cmisType22 = typeFactory.createChildDocumentTypeDefinition(cmisType2, null);
+            cmisType22.setId("MyDocType2.2");
+            cmisType22.setDisplayName("My Type 8 Level 2");
+            cmisType22.setDescription("Builtin InMemory type definition MyDocType2.2");
+            typesList.add(cmisType22);
+
+            MutableDocumentTypeDefinition cmisType23;        
+            cmisType23 = typeFactory.createChildDocumentTypeDefinition(cmisType2, null);
+            cmisType23.setId("MyDocType2.3");
+            cmisType23.setDisplayName("My Type 9 Level 2");
+            cmisType23.setDescription("Builtin InMemory type definition MyDocType2.3");
+            typesList.add(cmisType23);
+
+            MutableDocumentTypeDefinition cmisType24;        
+            cmisType24 = typeFactory.createChildDocumentTypeDefinition(cmisType2, null);
+            cmisType24.setId("MyDocType2.4");
+            cmisType24.setDisplayName("My Type 10 Level 2");
+            cmisType24.setDescription("Builtin InMemory type definition MyDocType2.4");
+            typesList.add(cmisType24);
+
+            MutableDocumentTypeDefinition cmisType25;        
+            cmisType25 = typeFactory.createChildDocumentTypeDefinition(cmisType2, null);
+            cmisType25.setId("MyDocType2.5");
+            cmisType25.setDisplayName("My Type 11 Level 2");
+            cmisType25.setDescription("Builtin InMemory type definition MyDocType2.5");
+            typesList.add(cmisType25);
+
+            MutableDocumentTypeDefinition cmisType26;        
+            cmisType26 = typeFactory.createChildDocumentTypeDefinition(cmisType2, null);
+            cmisType26.setId("MyDocType2.6");
+            cmisType26.setDisplayName("My Type 12 Level 2");
+            cmisType26.setDescription("Builtin InMemory type definition MyDocType2.6");
+            typesList.add(cmisType26);
+
+            MutableDocumentTypeDefinition cmisType27;        
+            cmisType27 = typeFactory.createChildDocumentTypeDefinition(cmisType2, null);
+            cmisType27.setId("MyDocType2.7");
+            cmisType27.setDisplayName("My Type 13 Level 2");
+            cmisType27.setDescription("Builtin InMemory type definition MyDocType2.7");
+            typesList.add(cmisType27);
+
+            MutableDocumentTypeDefinition cmisType28;        
+            cmisType28 = typeFactory.createChildDocumentTypeDefinition(cmisType2, null);
+            cmisType28.setId("MyDocType2.8");
+            cmisType28.setDisplayName("My Type 14 Level 2");
+            cmisType28.setDescription("Builtin InMemory type definition MyDocType2.8");
+            typesList.add(cmisType28);
+
+            MutableDocumentTypeDefinition cmisType29;        
+            cmisType29 = typeFactory.createChildDocumentTypeDefinition(cmisType2, null);
+            cmisType29.setId("MyDocType2.9");
+            cmisType29.setDisplayName("My Type 15 Level 2");
+            cmisType29.setDescription("Builtin InMemory type definition MyDocType2.9");
+            typesList.add(cmisType29);
+
+            // create a complex type with properties
+            MutableDocumentTypeDefinition cmisComplexType;        
+            cmisComplexType = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            cmisComplexType.setId(COMPLEX_TYPE);
+            cmisComplexType.setDisplayName("Complex type with properties, Level 1");
+            cmisComplexType.setDescription("Builtin InMemory type definition ComplexType");
+
+            // create a boolean property definition
+
+            PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition(PROP_ID_BOOLEAN,
+                    "Sample Boolean Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop);
+
+            prop = PropertyCreationHelper.createBooleanMultiDefinition(PROP_ID_BOOLEAN_MULTI_VALUE,
+                    "Sample Boolean multi-value Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop);
+
+            PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition(PROP_ID_DATETIME,
+                    "Sample DateTime Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop2);
+
+            prop2 = PropertyCreationHelper.createDateTimeMultiDefinition(PROP_ID_DATETIME_MULTI_VALUE,
+                    "Sample DateTime multi-value Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop2);
+
+            PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition(PROP_ID_DECIMAL,
+                    "Sample Decimal Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop3);
+
+            prop3 = PropertyCreationHelper.createDecimalMultiDefinition(PROP_ID_DECIMAL_MULTI_VALUE, "Sample Decimal multi-value Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop3);
+
+            PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition(PROP_ID_HTML,
+                    "Sample Html Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop4);
+
+            prop4 = PropertyCreationHelper.createHtmlMultiDefinition(PROP_ID_HTML_MULTI_VALUE, "Sample Html multi-value Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop4);
+
+            PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition(PROP_ID_ID, "Sample Id Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop5);
+
+            prop5 = PropertyCreationHelper.createIdMultiDefinition(PROP_ID_ID_MULTI_VALUE, "Sample Id Html multi-value Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop5);
+
+            PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition(PROP_ID_INT,
+                    "Sample Int Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop6);
+
+            prop6 = PropertyCreationHelper.createIntegerMultiDefinition(PROP_ID_INT_MULTI_VALUE, "Sample Int multi-value Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop6);
+
+            PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition(PROP_ID_STRING,
+                    "Sample String Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop7);
+
+            prop7 = PropertyCreationHelper.createStringMultiDefinition(PROP_ID_STRING_MULTI_VALUE,
+                    "Sample String multi-value Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop7);
+
+            PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition(PROP_ID_URI, "Sample Uri Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop8);
+
+            prop8 = PropertyCreationHelper.createUriMultiDefinition(PROP_ID_URI_MULTI_VALUE, "Sample Uri multi-value Property", Updatability.READONLY);
+            cmisComplexType.addPropertyDefinition(prop8);
+
+            PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
+                    "Sample Pick List Property", Updatability.READONLY);
+            List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
+            ChoiceImpl<String> elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("red"));
+            choiceList.add(elem);
+            elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("green"));
+            choiceList.add(elem);
+            elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("blue"));
+            choiceList.add(elem);
+            elem = new ChoiceImpl<String>();
+            elem.setValue(Collections.singletonList("black"));
+            choiceList.add(elem);
+            prop9.setChoices(choiceList);
+            prop9.setDefaultValue(Collections.singletonList("blue"));
+            cmisComplexType.addPropertyDefinition(prop9);
+
+            // add type to types collection
+            typesList.add(cmisComplexType);
+
+            // create a type hierarchy with inherited properties
+            MutableDocumentTypeDefinition cmisDocTypeTopLevel;        
+            cmisDocTypeTopLevel = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+            cmisDocTypeTopLevel.setId(TOPLEVEL_TYPE);
+            cmisDocTypeTopLevel.setDisplayName("Document type with properties, Level 1");
+            cmisDocTypeTopLevel.setDescription("Builtin InMemory type definition " + TOPLEVEL_TYPE);
+
+            MutableDocumentTypeDefinition cmisDocTypeLevel1;        
+            cmisDocTypeLevel1 = typeFactory.createChildDocumentTypeDefinition(cmisDocTypeTopLevel, null);
+            cmisDocTypeLevel1.setId(LEVEL1_TYPE);
+            cmisDocTypeLevel1.setDisplayName("Document type with inherited properties, Level 2");
+            cmisDocTypeLevel1 .setDescription("Builtin InMemory type definition " + LEVEL1_TYPE);
+
+            MutableDocumentTypeDefinition cmisDocTypeLevel2;        
+            cmisDocTypeLevel2 = typeFactory.createChildDocumentTypeDefinition(cmisDocTypeLevel1, null);
+            cmisDocTypeLevel2.setId(LEVEL2_TYPE);
+            cmisDocTypeLevel2.setDisplayName("Document type with inherited properties, Level 3");
+            cmisDocTypeLevel2.setDescription("Builtin InMemory type definition " + LEVEL2_TYPE);
+
+            PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
+                    "Sample String Property", Updatability.READWRITE);
+            cmisDocTypeTopLevel.addPropertyDefinition(propTop);
+
+            PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
+                    "String Property Level 1", Updatability.READWRITE);
+            cmisDocTypeLevel1.addPropertyDefinition(propLevel1);
+
+            PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
+                    "String Property Level 2", Updatability.READWRITE);
+            cmisDocTypeLevel2.addPropertyDefinition(propLevel2);
+
+            // create a versioned type with properties
+            MutableDocumentTypeDefinition cmisVersionedType;        
+            cmisVersionedType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisVersionedType.setId(VERSIONED_TYPE);
+            cmisVersionedType.setDisplayName("Versioned Type");
+            cmisVersionedType.setDescription("Builtin InMemory type definition " + VERSIONED_TYPE);
+            cmisVersionedType.setIsVersionable(true); // make it a versionable type;
+
+            // create a single String property definition
+            PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(VERSION_PROPERTY_ID,
+                    "Sample String Property", Updatability.WHENCHECKEDOUT);
+            cmisVersionedType.addPropertyDefinition(prop1);
+
+            // add type to types collection
+
+            // create a folder type
+            // create a complex type with properties
+            MutableFolderTypeDefinition cmisFolderType;        
+            cmisFolderType = typeFactory.createFolderTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisFolderType().getId());
+            cmisFolderType.setId(FOLDER_TYPE);
+            cmisFolderType.setDisplayName("Folder type with properties");
+            cmisFolderType.setDescription("InMemory test type definition " + FOLDER_TYPE);
+
+            // create a two property definitions for folder
+            prop6 = PropertyCreationHelper.createIntegerDefinition(PROP_ID_INT, "Sample Folder Int Property", Updatability.READONLY);
+            cmisFolderType.addPropertyDefinition(prop6);
+
+            prop7 = PropertyCreationHelper.createStringDefinition(PROP_ID_STRING,
+                    "Sample Folder String Property", Updatability.READONLY);
+            cmisFolderType.addPropertyDefinition(prop7);
+
+            // CMIS 1.1 create a secondary type
+            MutableSecondaryTypeDefinition cmisSecondaryType;        
+            cmisSecondaryType = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisSecondaryType().getId());
+            cmisSecondaryType.setId(SECONDARY_TYPE);
+            cmisSecondaryType.setDisplayName("MySecondaryType");
+            cmisSecondaryType.setDescription("Builtin InMemory type definition " + SECONDARY_TYPE);
+            DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisSecondaryType);
+            cmisSecondaryType.setIsFileable(false);
+            
+            // create a single String property definition
+            PropertyStringDefinitionImpl propS1 = PropertyCreationHelper.createStringDefinition(SECONDARY_STRING_PROP,
+                    "Secondary String Property", Updatability.READWRITE);
+            cmisSecondaryType.addPropertyDefinition(propS1);
+            PropertyIntegerDefinitionImpl propS2 = PropertyCreationHelper.createIntegerDefinition(SECONDARY_INTEGER_PROP,
+                    "Secondary Integer Property", Updatability.READWRITE);
+            propS2.setIsRequired(true);
+            cmisSecondaryType.addPropertyDefinition(propS2);
+ 
+            MutableSecondaryTypeDefinition cmisSecondaryType2;        
+            cmisSecondaryType2 = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisSecondaryType().getId());
+            cmisSecondaryType2.setId(SECONDARY_TYPE_2);
+            cmisSecondaryType2.setDisplayName("MySecondaryType-2");
+            cmisSecondaryType2.setDescription("Builtin InMemory type definition " + SECONDARY_TYPE_2);
+            DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisSecondaryType2);
+
+            // add type to types collectio
+            typesList.add(cmisDocTypeTopLevel);
+            typesList.add(cmisDocTypeLevel1);
+            typesList.add(cmisDocTypeLevel2);
+            typesList.add(cmisVersionedType);
+            typesList.add(cmisFolderType);
+            typesList.add(cmisSecondaryType);
+            typesList.add(cmisSecondaryType2);
+            return typesList;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
     }
 
 }

Modified: chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/VersionTestTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/VersionTestTypeSystemCreator.java?rev=1509723&r1=1509722&r2=1509723&view=diff
==============================================================================
--- chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/VersionTestTypeSystemCreator.java (original)
+++ chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/VersionTestTypeSystemCreator.java Fri Aug  2 14:16:05 2013
@@ -18,17 +18,17 @@
  */
 package org.apache.chemistry.opencmis.inmemory;
 
-import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
 
 public class VersionTestTypeSystemCreator implements TypeCreator {
     public static final String VERSION_TEST_DOCUMENT_TYPE_ID = "MyVersionedType";
@@ -63,28 +63,32 @@ public class VersionTestTypeSystemCreato
      * @return typesMap map filled with created types
      */
     private static List<TypeDefinition> buildTypesList() {
+        TypeDefinitionFactory typeFactory =  DocumentTypeCreationHelper.getTypeDefinitionFactory();
         // always add CMIS default types
         List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
 
-        // create a complex type with properties
-        InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(
-                VERSION_TEST_DOCUMENT_TYPE_ID, "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        // create a boolean property definition
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
-        PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(PROPERTY_ID,
-                "Sample String Property", Updatability.WHENCHECKEDOUT);
-        propertyDefinitions.put(prop1.getId(), prop1);
-
-        cmisComplexType.addCustomPropertyDefinitions(propertyDefinitions);
-        cmisComplexType.setIsVersionable(true); // make it a versionable type;
-
-        // add type to types collection
-        typesList.add(cmisComplexType);
-
-        return typesList;
+        try {
+            // create a complex type with properties
+            MutableDocumentTypeDefinition cmisComplexType;        
+            cmisComplexType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisComplexType.setId(VERSION_TEST_DOCUMENT_TYPE_ID);
+            cmisComplexType.setDisplayName("VersionedType");
+            cmisComplexType.setDescription("InMemory test type definition " + VERSION_TEST_DOCUMENT_TYPE_ID);
+            cmisComplexType.setIsVersionable(true); // make it a versionable type;
+
+            // create a boolean property definition
+
+            PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(PROPERTY_ID,
+                    "Sample String Property", Updatability.WHENCHECKEDOUT);
+            cmisComplexType.addPropertyDefinition(prop1);
+
+            // add type to types collection
+            typesList.add(cmisComplexType);
+
+            return typesList;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating types.", e);
+        }
     }
 
 }

Modified: chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java?rev=1509723&r1=1509722&r2=1509723&view=diff
==============================================================================
--- chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java (original)
+++ chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java Fri Aug  2 14:16:05 2013
@@ -27,7 +27,6 @@ import static org.junit.Assert.fail;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -41,25 +40,19 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.PropertyId;
 import org.apache.chemistry.opencmis.commons.data.PropertyString;
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
-import org.apache.chemistry.opencmis.commons.enums.Updatability;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.spi.Holder;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class VersioningTest extends AbstractServiceTest {
     private static final Logger log = LoggerFactory.getLogger(ObjectServiceTest.class);
@@ -514,8 +507,10 @@ public class VersioningTest extends Abst
         PropertyBoolean pdb = (PropertyBoolean) props.get(PropertyIds.IS_LATEST_VERSION);
         assertNotNull(pdb);
         boolean bVal = pdb.getFirstValue();
-        assertTrue(bVal); 
-
+        if (versioningState != VersioningState.CHECKEDOUT)
+            assertTrue(bVal);
+        else
+            assertFalse(bVal);
         pdb = (PropertyBoolean) props.get(PropertyIds.IS_MAJOR_VERSION);
         assertNotNull(pdb);
         bVal = pdb.getFirstValue();

Modified: chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java?rev=1509723&r1=1509722&r2=1509723&view=diff
==============================================================================
--- chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java (original)
+++ chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java Fri Aug  2 14:16:05 2013
@@ -21,21 +21,21 @@ package org.apache.chemistry.opencmis.in
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.antlr.runtime.RecognitionException;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyBooleanDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
 import org.apache.chemistry.opencmis.server.support.TypeManager;
 import org.apache.chemistry.opencmis.server.support.query.CmisQueryWalker;
 import org.apache.chemistry.opencmis.server.support.query.PredicateWalkerBase;
@@ -88,68 +88,74 @@ public abstract class AbstractQueryTest 
     // Helper to create some types for testing
 
     protected  List<TypeDefinition> createTypes() {
-
+        TypeDefinitionFactory typeFactory =  DocumentTypeCreationHelper.getTypeDefinitionFactory();
         List<TypeDefinition> typeDefs = new ArrayList<TypeDefinition>();
 
-        // First test type
-        InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(MY_DOC_TYPE,
-                "Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
-        Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+        try {
+            // First test type
+            MutableDocumentTypeDefinition cmisType;        
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(MY_DOC_TYPE);
+            cmisType.setDisplayName("Document Type for Validation");
 
-        PropertyBooleanDefinition prop1 = PropertyCreationHelper.createBooleanDefinition(BOOL_PROP,
-                "Sample Boolean Property", Updatability.READWRITE);
-        ((PropertyBooleanDefinitionImpl) prop1).setIsRequired(true);
-        propertyDefinitions.put(prop1.getId(), prop1);
+            PropertyBooleanDefinition prop1 = PropertyCreationHelper.createBooleanDefinition(BOOL_PROP,
+                    "Sample Boolean Property", Updatability.READWRITE);
+            ((PropertyBooleanDefinitionImpl) prop1).setIsRequired(true);
 
-        PropertyStringDefinition prop2 = PropertyCreationHelper.createStringDefinition(STRING_PROP,
-                "Sample String Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop2.getId(), prop2);
+            PropertyStringDefinition prop2 = PropertyCreationHelper.createStringDefinition(STRING_PROP,
+                    "Sample String Property", Updatability.READWRITE);
 
-        PropertyIntegerDefinitionImpl prop3 = PropertyCreationHelper.createIntegerDefinition(INT_PROP,
-                "Sample Integer Property", Updatability.READWRITE);
-        propertyDefinitions.put(prop2.getId(), prop2);
+            PropertyIntegerDefinitionImpl prop3 = PropertyCreationHelper.createIntegerDefinition(INT_PROP,
+                    "Sample Integer Property", Updatability.READWRITE);
 
-        cmisType.setPropertyDefinitions(propertyDefinitions);
+            cmisType.addPropertyDefinition(prop1);
+            cmisType.addPropertyDefinition(prop2);
+            cmisType.addPropertyDefinition(prop3);
 
-        typeDefs.add(cmisType);
-        myType = cmisType;
+            typeDefs.add(cmisType);
+            myType = cmisType;
 
-        // add another type definition with exactly the same properties
-        cmisType = new InMemoryDocumentTypeDefinition(MY_DOC_TYPE_COPY,
-                "Document Type Duplicated", InMemoryDocumentTypeDefinition.getRootDocumentType());
-        cmisType.setPropertyDefinitions(propertyDefinitions); // add same properties
-        typeDefs.add(cmisType);
-        myTypeCopy = cmisType;
+            // add another type definition with exactly the same properties
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(MY_DOC_TYPE_COPY);
+            cmisType.setDisplayName("Document Type for Duplicated");
 
+            // add same properties
+            cmisType.addPropertyDefinition(prop1);
+            cmisType.addPropertyDefinition(prop2);
+            cmisType.addPropertyDefinition(prop3);
+            typeDefs.add(cmisType);
+            myTypeCopy = cmisType;
 
-        // Second test type
 
-        cmisType = new InMemoryDocumentTypeDefinition(BOOK_TYPE,
-                "Book Document Type", InMemoryDocumentTypeDefinition.getRootDocumentType());
+            // Second test type
 
-        propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+            cmisType = typeFactory.createChildDocumentTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), null);
+            cmisType.setId(BOOK_TYPE);
+            cmisType.setDisplayName("Book Document Type");
 
-        prop2 = PropertyCreationHelper.createStringDefinition(TITLE_PROP, "Title of Book", Updatability.READWRITE);
-        propertyDefinitions.put(prop2.getId(), prop2);
 
-        prop2 = PropertyCreationHelper.createStringDefinition(AUTHOR_PROP, "Author of Book", Updatability.READWRITE);
-        propertyDefinitions.put(prop2.getId(), prop2);
+            prop2 = PropertyCreationHelper.createStringDefinition(TITLE_PROP, "Title of Book", Updatability.READWRITE);
+            cmisType.addPropertyDefinition(prop2);
 
-        prop3 = PropertyCreationHelper.createIntegerDefinition(ISBN_PROP,
-                "ISBN of Book", Updatability.READWRITE);
-        propertyDefinitions.put(prop3.getId(), prop3);
+            prop2 = PropertyCreationHelper.createStringDefinition(AUTHOR_PROP, "Author of Book", Updatability.READWRITE);
+            cmisType.addPropertyDefinition(prop2);
 
-        PropertyDateTimeDefinitionImpl prop4 = PropertyCreationHelper.createDateTimeDefinition(PUB_DATE_PROP,
-                "Publishing Date of Book", Updatability.READWRITE);
-        propertyDefinitions.put(prop4.getId(), prop4);
+            prop3 = PropertyCreationHelper.createIntegerDefinition(ISBN_PROP,
+                    "ISBN of Book", Updatability.READWRITE);
+            cmisType.addPropertyDefinition(prop3);
 
-        cmisType.setPropertyDefinitions(propertyDefinitions);
+            PropertyDateTimeDefinitionImpl prop4 = PropertyCreationHelper.createDateTimeDefinition(PUB_DATE_PROP,
+                    "Publishing Date of Book", Updatability.READWRITE);
+            cmisType.addPropertyDefinition(prop4);
 
-        typeDefs.add(cmisType);
-        bookType = cmisType;
+            typeDefs.add(cmisType);
+            bookType = cmisType;
 
-        return typeDefs;
+            return typeDefs;
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+        }
     }
 
 }

Modified: chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java?rev=1509723&r1=1509722&r2=1509723&view=diff
==============================================================================
--- chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java (original)
+++ chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java Fri Aug  2 14:16:05 2013
@@ -419,7 +419,7 @@ public class ProcessQueryTest extends Ab
         // create some types for testing
         List<TypeDefinition> typeDefs = super.createTypes();
         for (TypeDefinition typeDef : typeDefs) {
-            tm.addTypeDefinition(typeDef);
+            tm.addTypeDefinition(typeDef, true);
         }
 
         // initialize query object with type manager

Modified: chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java?rev=1509723&r1=1509722&r2=1509723&view=diff
==============================================================================
--- chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java (original)
+++ chemistry/opencmis/branches/inmemory-refactoring/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java Fri Aug  2 14:16:05 2013
@@ -68,7 +68,7 @@ public class QueryTypesTest extends Abst
         // create some types for testing
         List<TypeDefinition> typeDefs = super.createTypes();
         for (TypeDefinition typeDef : typeDefs) {
-            tm.addTypeDefinition(typeDef);
+            tm.addTypeDefinition(typeDef, true);
         }
 
         // initialize query object with type manager
@@ -538,7 +538,7 @@ public class QueryTypesTest extends Abst
         // create some types for testing
         List<TypeDefinition> typeDefs = UnitTestTypeSystemCreator.getTypesList(); 
         for (TypeDefinition typeDef : typeDefs) {
-            tm.addTypeDefinition(typeDef);
+            tm.addTypeDefinition(typeDef, true);
         }
         super.setUp(tm, pw);
 



Mime
View raw message