You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by cl...@apache.org on 2008/09/28 21:21:43 UTC

svn commit: r699884 - in /jackrabbit/trunk/jackrabbit-ocm/src: main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ main/java/org/apache/jackrabbit/ocm/manager/impl/ main/java/org/apache/jackrabbit/ocm/mapper/impl/ main/java/org/apache...

Author: clombart
Date: Sun Sep 28 12:21:42 2008
New Revision: 699884

URL: http://svn.apache.org/viewvc?rev=699884&view=rev
Log:
Patch for JCR-1762 (Improvement to MultiValueCollectionConverterImpl to Map collections with element class Object.class) provided by Boni Gopalan.

Added:
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationMultiValueWithObjectCollectionConverterImplTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterMultiValueWithObjectCollectionConverterImplTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/MultiValueWithObjectCollection.java
Modified:
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/MultiValueCollectionConverterImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/test-config/jcrmapping-atomic.xml

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/MultiValueCollectionConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/MultiValueCollectionConverterImpl.java?rev=699884&r1=699883&r2=699884&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/MultiValueCollectionConverterImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/MultiValueCollectionConverterImpl.java Sun Sep 28 12:21:42 2008
@@ -32,6 +32,7 @@
 import org.apache.jackrabbit.ocm.exception.JcrMappingException;
 import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
 import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.UndefinedTypeConverterImpl;
 import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection;
 import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjectsUtil;
 import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjects;
@@ -47,6 +48,7 @@
  *
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
+ * @author <a href='mailto:boni.g@bioimagene.com'>Boni Gopalan</a>
  */
 public class MultiValueCollectionConverterImpl extends AbstractCollectionConverterImpl {
 
@@ -84,6 +86,12 @@
                 Object fieldValue = collectionIterator.next();
                 AtomicTypeConverter atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters
                     .get(fieldValue.getClass());
+                //If there is no proper conversion strategy defined for a specific bean type
+                //then system will make a best effort conversion strategy using UndefinedTypeConverter.
+                //@author:Boni Gopalan
+                if (atomicTypeConverter == null){
+                	atomicTypeConverter = new UndefinedTypeConverterImpl();
+                }
                 values[i] = atomicTypeConverter.getValue(valueFactory, fieldValue);
             }
 
@@ -125,6 +133,13 @@
             Object fieldValue = collectionIterator.next();
             AtomicTypeConverter atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters
                 .get(fieldValue.getClass());
+            //If there is no proper conversion strategy defined for a specific bean type
+            //then system will make a best effort conversion strategy using UndefinedTypeConverter.
+            //@author:Boni Gopalan
+            if (atomicTypeConverter == null){
+            	atomicTypeConverter = new UndefinedTypeConverterImpl();
+            }
+            
             values[i] = atomicTypeConverter.getValue(valueFactory, fieldValue);
         }
 
@@ -162,7 +177,12 @@
             for (int i = 0; i < values.length; i++) {
                 AtomicTypeConverter atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters
                     .get(elementClass);
-
+                //If there is no proper conversion strategy defined for a specific bean type
+                //then system will make a best effort conversion strategy using UndefinedTypeConverter.
+                //@author:Boni Gopalan
+                if (atomicTypeConverter == null){
+                	atomicTypeConverter = new UndefinedTypeConverterImpl();
+                }
                 ((ManageableCollection) objects).addObject(atomicTypeConverter.getObject(values[i]));
             }
 

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java?rev=699884&r1=699883&r2=699884&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java Sun Sep 28 12:21:42 2008
@@ -515,6 +515,8 @@
 
         try {
             ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(clazz);
+            if (classDescriptor == null)
+            	return false;
             return true;
         } catch (IncorrectPersistentClassException e) {
             return false;

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java?rev=699884&r1=699883&r2=699884&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java Sun Sep 28 12:21:42 2008
@@ -31,6 +31,7 @@
 import org.apache.jackrabbit.ocm.exception.IncorrectPersistentClassException;
 import org.apache.jackrabbit.ocm.exception.InitMapperException;
 import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.AtomicTypeConverterProviderImpl;
 import org.apache.jackrabbit.ocm.mapper.DescriptorReader;
 import org.apache.jackrabbit.ocm.mapper.Mapper;
 import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
@@ -42,6 +43,7 @@
  * Abstract class for {@link org.apache.jackrabbit.ocm.mapper.Mapper}
  *
  * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
+ * @author : <a href="mailto:boni.g@bioimagene.com">Boni Gopalan</a>
  *
  * TODO : Add more reference tests. For exemple, the mapper has to check if the class used for the elements
  *        of a collectiondescriptor exists. For performance reasone, we can defined some optional validations.

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java?rev=699884&r1=699883&r2=699884&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java Sun Sep 28 12:21:42 2008
@@ -41,6 +41,7 @@
  * Helper class that reads the xml mapping file and load all class descriptors into memory (object graph)
  *
  * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
+ * @author : <a href="mailto:boni.g@bioimagene.com">Boni Gopalan</a>
  *
  */
 public class AnnotationDescriptorReader implements DescriptorReader
@@ -307,6 +308,9 @@
             {
 			   setElementClassName(collectionDescriptor,ancestorType);
             }
+            else{
+            	collectionDescriptor.setElementClassName(Object.class.getName());
+            }
 		}
 	}
 

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java?rev=699884&r1=699883&r2=699884&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java Sun Sep 28 12:21:42 2008
@@ -39,6 +39,7 @@
 import org.apache.jackrabbit.ocm.testmodel.HierarchyNode;
 import org.apache.jackrabbit.ocm.testmodel.Lockable;
 import org.apache.jackrabbit.ocm.testmodel.MultiValue;
+import org.apache.jackrabbit.ocm.testmodel.MultiValueWithObjectCollection;
 import org.apache.jackrabbit.ocm.testmodel.Page;
 import org.apache.jackrabbit.ocm.testmodel.Paragraph;
 import org.apache.jackrabbit.ocm.testmodel.PropertyTest;
@@ -75,7 +76,7 @@
  * repository.
  *
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
- *
+ * @author : <a href="mailto:boni.g@bioimagene.com">Boni Gopalan</a>
  *
  */
 public abstract class AnnotationTestBase extends AbstractTestBase
@@ -116,6 +117,7 @@
 		classes.add(Main.class);
 		classes.add(Element.class);
 		classes.add(MultiValue.class);
+		classes.add(MultiValueWithObjectCollection.class);
 		classes.add(Discriminator.class);
 
 		classes.add(Residual.class);

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java?rev=699884&r1=699883&r2=699884&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java Sun Sep 28 12:21:42 2008
@@ -202,8 +202,12 @@
     {
     	ObjectContentManager ocm = getObjectContentManager();
     	assertTrue("Class A is not persistent ", ocm.isPersistent(A.class));
-    	assertFalse("Class String is  persistent - hum ? ", ocm.isPersistent(String.class));
+    	assertFalse("Class SomeRandomUnMappedType is  persistent - hum ? ", ocm.isPersistent(SomeRandomUnMappedType.class));
+    	
     }
 
 
+}
+class SomeRandomUnMappedType{
+	
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java?rev=699884&r1=699883&r2=699884&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java Sun Sep 28 12:21:42 2008
@@ -201,8 +201,9 @@
     {
     	ObjectContentManager ocm = getObjectContentManager();
     	assertTrue("Class A is not persistent ", ocm.isPersistent(A.class));
-    	assertFalse("Class String is  persistent - hum ? ", ocm.isPersistent(String.class));
+    	assertFalse("Class SomeRandomUnMappedDigesterType is  persistent - hum ? ", ocm.isPersistent(SomeRandomUnMappedDigesterType.class));
     }
-
-
+}
+class SomeRandomUnMappedDigesterType{
+	
 }
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationMultiValueWithObjectCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationMultiValueWithObjectCollectionConverterImplTest.java?rev=699884&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationMultiValueWithObjectCollectionConverterImplTest.java (added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationMultiValueWithObjectCollectionConverterImplTest.java Sun Sep 28 12:21:42 2008
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.collectionconverter;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.ocm.AnnotationTestBase;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.testmodel.MultiValueWithObjectCollection;
+
+/**
+ * Test NTCollectionConverterImpl
+ *
+ * @author : <a href="mailto:boni.g@bioimagene.com">Boni Gopalan</a>
+ */
+public class AnnotationMultiValueWithObjectCollectionConverterImplTest extends
+		AnnotationTestBase {
+	private final static Log log = LogFactory
+			.getLog(AnnotationMultiValueWithObjectCollectionConverterImplTest.class);
+
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public AnnotationMultiValueWithObjectCollectionConverterImplTest(
+			String testName) throws Exception {
+		super(testName);
+	}
+
+	public static Test suite() {
+		// All methods starting with "test" will be executed in the test suite.
+		return new RepositoryLifecycleTestSetup(
+				new TestSuite(
+						AnnotationMultiValueWithObjectCollectionConverterImplTest.class));
+	}
+
+	public void testMultiValue() {
+		checkMultiValue(new String[] { "Value1", "Value2", "Value3", "Value4",
+				"Value5" }, "/test-string", String.class);
+		checkMultiValue(new Long[] { 1L, 2L, 3L, 4L, 5L }, "/test-long",
+				Long.class);
+	}
+
+	public void checkMultiValue(Object[] testData, String nodeName, Class klazz) {
+		try {
+			ObjectContentManager ocm = getObjectContentManager();
+
+			// --------------------------------------------------------------------------------
+			// Create and store an object graph in the repository
+			// --------------------------------------------------------------------------------
+
+			MultiValueWithObjectCollection multiValue = new MultiValueWithObjectCollection();
+			multiValue.setPath(nodeName);
+
+			ArrayList values = new ArrayList();
+			values.add(testData[0]);
+			values.add(testData[1]);
+			multiValue.setMultiValues(values);
+
+			ocm.insert(multiValue);
+			ocm.save();
+
+			// --------------------------------------------------------------------------------
+			// Get the object
+			// --------------------------------------------------------------------------------
+			multiValue = (MultiValueWithObjectCollection) ocm
+					.getObject(nodeName);
+			assertNotNull("Object is null", multiValue);
+			assertNull("nullMultiValues field is not null", multiValue
+					.getNullMultiValues());
+			assertTrue("Incorrect number of values", multiValue
+					.getMultiValues().size() == 2);
+			Iterator anIterator = multiValue.getMultiValues().iterator();
+			assertEquals(testData[0], klazz.cast(anIterator.next()));
+			assertEquals(testData[1], klazz.cast(anIterator.next()));
+
+			// --------------------------------------------------------------------------------
+			// Update the object
+			// --------------------------------------------------------------------------------
+			ArrayList values1 = new ArrayList();
+			values1.add(testData[2]);
+			values1.add(testData[3]);
+			values1.add(testData[4]);
+			multiValue.setMultiValues(values1);
+
+			ocm.update(multiValue);
+			ocm.save();
+
+			// --------------------------------------------------------------------------------
+			// Get the object
+			// --------------------------------------------------------------------------------
+
+			multiValue = (MultiValueWithObjectCollection) ocm
+					.getObject(nodeName);
+			assertNotNull("Object is null", multiValue);
+			assertNull("nullMultiValues field is not null", multiValue
+					.getNullMultiValues());
+			assertTrue("Incorrect number of values", multiValue
+					.getMultiValues().size() == 3);
+			assertEquals(testData[2], klazz.cast(multiValue.getMultiValues()
+					.iterator().next()));
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			fail("Exception occurs during the unit test : " + e);
+		}
+	}
+
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterMultiValueWithObjectCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterMultiValueWithObjectCollectionConverterImplTest.java?rev=699884&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterMultiValueWithObjectCollectionConverterImplTest.java (added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterMultiValueWithObjectCollectionConverterImplTest.java Sun Sep 28 12:21:42 2008
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.collectionconverter;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.testmodel.MultiValueWithObjectCollection;
+
+/**
+ * Test NTCollectionConverterImpl
+ *
+ * @author : <a href="mailto:boni.g@bioimagene.com">Boni Gopalan</a>
+ */
+public class DigesterMultiValueWithObjectCollectionConverterImplTest extends DigesterTestBase
+{
+    private final static Log log = LogFactory.getLog(DigesterMultiValueWithObjectCollectionConverterImplTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public DigesterMultiValueWithObjectCollectionConverterImplTest(String testName)  throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new RepositoryLifecycleTestSetup(new TestSuite(DigesterMultiValueWithObjectCollectionConverterImplTest.class));
+    }
+
+    public void testMultiValue(){
+    	checkMultiValue(new String [] {"Value1", "Value2", "Value3", "Value4", "Value5"}, "/test-string", String.class);
+    	checkMultiValue(new Long [] {1L, 2L, 3L, 4L, 5L}, "/test-long", Long.class);
+    }
+
+    public void checkMultiValue(Object [] testData, String nodeName, Class klazz )
+    {
+        try
+        {
+        	ObjectContentManager ocm = getObjectContentManager();
+
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+
+            MultiValueWithObjectCollection multiValue = new MultiValueWithObjectCollection();
+            multiValue.setPath(nodeName);
+
+            ArrayList values = new ArrayList();
+            values.add(testData[0]);
+            values.add(testData[1]);
+            multiValue.setMultiValues(values);
+
+            ocm.insert(multiValue);
+            ocm.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
+            multiValue = (MultiValueWithObjectCollection) ocm.getObject( nodeName);
+            assertNotNull("Object is null", multiValue);
+            assertNull("nullMultiValues field is not null", multiValue.getNullMultiValues());
+            assertTrue("Incorrect number of values", multiValue.getMultiValues().size() == 2);
+            Iterator anIterator = multiValue.getMultiValues().iterator();
+            assertEquals(testData[0], klazz.cast(anIterator.next()));
+            assertEquals(testData[1], klazz.cast(anIterator.next()));
+
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            ArrayList values1 = new ArrayList();
+            values1.add(testData[2]);
+            values1.add(testData[3]);
+            values1.add(testData[4]);
+            multiValue.setMultiValues(values1);
+
+            ocm.update(multiValue);
+            ocm.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
+
+            multiValue = (MultiValueWithObjectCollection) ocm.getObject(nodeName);
+            assertNotNull("Object is null", multiValue);
+            assertNull("nullMultiValues field is not null", multiValue.getNullMultiValues());
+            assertTrue("Incorrect number of values", multiValue.getMultiValues().size() == 3);
+            assertEquals(testData[2], klazz.cast(multiValue.getMultiValues().iterator().next()));
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+
+    }
+
+
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/MultiValueWithObjectCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/MultiValueWithObjectCollection.java?rev=699884&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/MultiValueWithObjectCollection.java (added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/MultiValueWithObjectCollection.java Sun Sep 28 12:21:42 2008
@@ -0,0 +1,86 @@
+package org.apache.jackrabbit.ocm.testmodel;
+
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.MultiValueCollectionConverterImpl;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+@Node
+public class MultiValueWithObjectCollection {
+	/**
+	 *
+	 * Simple object used to test multivalue properties
+	 *
+	 * @author <a href="mailto:boni.g@bioimagene.com"> Boni Gopalan </a>
+	 * @version $Id: Exp $
+	 */
+		@Field(path=true) private String path;
+		
+		@Field private String name;
+		
+		@Collection(elementClassName=Object.class,  collectionConverter=MultiValueCollectionConverterImpl.class)
+		private java.util.Collection multiValues;
+
+		@Collection(elementClassName=Object.class,  collectionConverter=MultiValueCollectionConverterImpl.class)
+		private java.util.Collection nullMultiValues;
+
+		
+		
+		public String getPath() {
+			return path;
+		}
+
+		public void setPath(String path) {
+			this.path = path;
+		}
+
+		/**
+		 * @return Returns the name.
+		 */
+		public String getName()
+		{
+			return name;
+		}
+
+		/**
+		 * @param name The name to set.
+		 */
+		public void setName(String name)
+		{
+			this.name = name;
+		}
+
+		/**
+		 * @return Returns the multiValues.
+		 */
+		public java.util.Collection getMultiValues()
+		{
+			return multiValues;
+		}
+
+		/**
+		 * @param multiValues
+		 *            The multiValues to set.
+		 */
+		public void setMultiValues(java.util.Collection multiValues)
+		{
+			this.multiValues = multiValues;
+		}
+
+		/**
+		 * @return Returns the nullMultiValues.
+		 */
+		public java.util.Collection getNullMultiValues()
+		{
+			return nullMultiValues;
+		}
+
+		/**
+		 * @param nullMultiValues
+		 *            The nullMultiValues to set.
+		 */
+		public void setNullMultiValues(java.util.Collection nullMultiValues)
+		{
+			this.nullMultiValues = nullMultiValues;
+		}
+
+}

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/test-config/jcrmapping-atomic.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/test-config/jcrmapping-atomic.xml?rev=699884&r1=699883&r2=699884&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/test-config/jcrmapping-atomic.xml (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/test-config/jcrmapping-atomic.xml Sun Sep 28 12:21:42 2008
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-  -->
-
-<jackrabbit-ocm>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+
+<jackrabbit-ocm>
     <class-descriptor
 		className="org.apache.jackrabbit.ocm.testmodel.Atomic" jcrType="nt:unstructured" discriminator="true" >
 		<field-descriptor fieldName="path" path="true" />
@@ -53,6 +53,22 @@
 		                       
 
 	</class-descriptor> 
-	
-</jackrabbit-ocm>
+
+    <class-descriptor
+		className="org.apache.jackrabbit.ocm.testmodel.MultiValueWithObjectCollection" jcrType="nt:unstructured" discriminator="true" >
+		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="name" jcrName="name" />
+		<collection-descriptor fieldName="multiValues" jcrName="multiValue" proxy="false" 
+		                       elementClassName="java.lang.Object" 
+		                       collectionConverter="org.apache.jackrabbit.ocm.manager.collectionconverter.impl.MultiValueCollectionConverterImpl" />
+
+		<collection-descriptor fieldName="nullMultiValues" jcrName="nullMultiValue" proxy="false" 
+		                       elementClassName="java.lang.Object" 
+		                       collectionConverter="org.apache.jackrabbit.ocm.manager.collectionconverter.impl.MultiValueCollectionConverterImpl" />
+		                       
+
+	</class-descriptor> 
+
+	
+</jackrabbit-ocm>