jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r547884 - in /jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src: main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/ test/java/org/apache/jackrabbit/ocm/persistence/beanconverter/ test/java/org/apache/jac...
Date Sat, 16 Jun 2007 08:07:50 GMT
Author: clombart
Date: Sat Jun 16 01:07:49 2007
New Revision: 547884

URL: http://svn.apache.org/viewvc?view=rev&rev=547884
Log:
bug fix for issues JCR-882 & JCR-921

Modified:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/beanconverter/BeanDescriptorTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ArrayListTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/DefaultCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/HashMapTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/NTCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualNodesCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualPropertiesCollectionConverterImplTest.java

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java?view=diff&rev=547884&r1=547883&r2=547884
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
Sat Jun 16 01:07:49 2007
@@ -45,8 +45,8 @@
  * It is usefull when the node type "nt:unstructured" is applied to the collection elements.
By this way, it is possible
  * to distinguish the collection elements from the other main object fields.
  *
- * If the collection element class contains an id (see the FieldDescriptor definition), this
id value is used to build the collection element node.
- * Otherwise, the element node name is a simple indexed constant.
+ * If the collection element class contains an id (see the ID FieldDescriptor definition),
this id value is used to build the collection element node.
+ * Otherwise, the element node name is a simple constant.
  *
  * Example - without an id attribute:
  *   /test (Main object containing the collection field )

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/NTCollectionConverterImpl.java?view=diff&rev=547884&r1=547883&r2=547884
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
Sat Jun 16 01:07:49 2007
@@ -197,10 +197,15 @@
                                                    Class collectionFieldClass) throws RepositoryException
{
 	    ClassDescriptor elementClassDescriptor = mapper.getClassDescriptorByClass( ReflectionUtils.forName(collectionDescriptor.getElementClassName()));

         ManageableCollection collection = ManageableCollectionUtil.getManageableCollection(collectionFieldClass);
-        Class elementClass = ReflectionUtils.forName(collectionDescriptor.getElementClassName());
-        Iterator children = this.getCollectionNodes(session, parentNode,
-                elementClassDescriptor.getJcrNodeType()).iterator();
-
+        //Class elementClass = ReflectionUtils.forName(collectionDescriptor.getElementClassName());
+        Collection nodes = this.getCollectionNodes(session, parentNode, elementClassDescriptor.getJcrNodeType());
+        
+        if (nodes == null)
+        {
+        	return null;
+        }
+        
+        Iterator children = nodes.iterator();
         while (children.hasNext()) {
             Node itemNode = (Node) children.next();
             log.debug("Collection node found : " + itemNode.getPath());
@@ -253,7 +258,14 @@
 
         }
 
-        return collectionNodes;
+        if (collectionNodes.size() == 0)
+        {
+        	return null; 
+        }
+        else
+        {
+            return collectionNodes;
+        }
     }
 
     private void deleteCollectionItems(Session session, Node parentNode, String itemNodeType)

@@ -264,7 +276,10 @@
            ValueFormatException, 
            RepositoryException
     {
-        Iterator nodeIterator = this.getCollectionNodes(session, parentNode, itemNodeType).iterator();
+        Collection nodes = this.getCollectionNodes(session, parentNode, itemNodeType);
+        if (nodes == null) return;
+        	
+        Iterator nodeIterator = nodes.iterator();
         while (nodeIterator.hasNext()) {
             Node node = (Node) nodeIterator.next();
             node.remove();

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/beanconverter/BeanDescriptorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/beanconverter/BeanDescriptorTest.java?view=diff&rev=547884&r1=547883&r2=547884
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/beanconverter/BeanDescriptorTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/beanconverter/BeanDescriptorTest.java
Sat Jun 16 01:07:49 2007
@@ -29,6 +29,7 @@
 import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.TestBase;
 import org.apache.jackrabbit.ocm.persistence.PersistenceManager;
+import org.apache.jackrabbit.ocm.testmodel.A;
 import org.apache.jackrabbit.ocm.testmodel.B;
 import org.apache.jackrabbit.ocm.testmodel.D;
 import org.apache.jackrabbit.ocm.testmodel.DFull;
@@ -80,9 +81,65 @@
             getSession().getItem("/someD").remove();
             getSession().save();
         }
+        
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");
+            getPersistenceManager().save();
+        }           
 
     }
     
+    public void testBasic() throws Exception 
+    {
+    	
+    	try 
+    	{
+    		// ------------------------------------------------------------------------
+    		// Create a main object (a) with a null attribute (A.b)
+    		// ------------------------------------------------------------------------    		
+			A a = new A();
+			a.setPath("/test");
+			a.setA1("a1");
+			persistenceManager.insert(a);
+			persistenceManager.save();
+			
+    		// ------------------------------------------------------------------------
+    		// Retrieve 
+    		// ------------------------------------------------------------------------
+			a = (A) persistenceManager.getObject("/test");
+			assertNotNull("Object is null", a);
+			assertNull("attribute is not null", a.getB());
+			
+			B b = new B();
+			b.setB1("b1");
+			b.setB2("b2");
+			a.setB(b);
+			
+			persistenceManager.update(a);
+			persistenceManager.save();
+
+    		// ------------------------------------------------------------------------
+    		// Retrieve 
+    		// ------------------------------------------------------------------------
+			a = (A) persistenceManager.getObject("/test");
+			assertNotNull("Object is null", a);
+			assertNotNull("attribute is null", a.getB());
+			
+    		// ------------------------------------------------------------------------
+			// Remove object
+    		// ------------------------------------------------------------------------			
+			persistenceManager.remove("/test");
+			persistenceManager.save();
+		} 
+    	catch (RuntimeException e) 
+    	{
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);    		
+		}
+    	
+    	
+    }
     public void testInlined() throws Exception {
         
         B expB = new B();

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ArrayListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ArrayListTest.java?view=diff&rev=547884&r1=547883&r2=547884
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ArrayListTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ArrayListTest.java
Sat Jun 16 01:07:49 2007
@@ -76,12 +76,27 @@
 
             // --------------------------------------------------------------------------------
             // Create and store an object graph in the repository
+        	// with a null value for the arraylist
             // --------------------------------------------------------------------------------
 
             Main main = new Main();
             main.setPath("/test");
             main.setText("Main text");
             
+            persistenceManager.insert(main);
+            persistenceManager.save();
+            
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
          
+            main = (Main) persistenceManager.getObject( "/test");
+            ArrayList arrayList = main.getList();
+            assertNull("main.getList is not null", arrayList ); 
+            
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            
             ArrayListElement arrayListElement = new ArrayListElement();
             Element e1 = new Element();
             e1.setId("e1");
@@ -94,15 +109,14 @@
             arrayListElement.add(e2);
             
             main.setList(arrayListElement);
-            
-            persistenceManager.insert(main);
+            persistenceManager.update(main);
             persistenceManager.save();
-            
+
             // --------------------------------------------------------------------------------
             // Get the object
             // --------------------------------------------------------------------------------
          
             main = (Main) persistenceManager.getObject( "/test");
-            ArrayList arrayList = main.getList();
+            arrayList = main.getList();
             assertNotNull("main.getList is null", arrayList ); 
             Element[] elements = (Element[]) arrayList.toArray(new Element[arrayList.size()]);
             assertTrue("Incorrect para element", elements[0].getText().equals("Element 1"));

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/DefaultCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/DefaultCollectionConverterImplTest.java?view=diff&rev=547884&r1=547883&r2=547884
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/DefaultCollectionConverterImplTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/DefaultCollectionConverterImplTest.java
Sat Jun 16 01:07:49 2007
@@ -68,6 +68,88 @@
     	
         super.tearDown();
     }
+
+    public void testNull()
+    {
+        try
+        {
+        	PersistenceManager persistenceManager = getPersistenceManager();
+
+            // --------------------------------------------------------------------------------
+            // Create and store an object with a null collection field
+            // --------------------------------------------------------------------------------
+            A a = new A();
+            a.setPath("/test");               
+            
+            persistenceManager.insert(a);
+            persistenceManager.save();
+            
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
          
+            a = (A) persistenceManager.getObject( "/test");
+            assertNull("a.collection is not null", a.getCollection());
+            
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            C c1 = new C();
+            c1.setId("first");
+            c1.setName("First Element");
+            C c2 = new C();
+            c2.setId("second");
+            c2.setName("Second Element");
+            
+            C c3 = new C();
+            c3.setId("third");
+            c3.setName("Third Element");
+            
+            
+            Collection collection = new ArrayList();
+            collection.add(c1);
+            collection.add(c2);
+            collection.add(c3);
+            
+            a.setCollection(collection);
+            
+            persistenceManager.update(a);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
          
+            a = (A) persistenceManager.getObject("/test");
+            assertNotNull("a is null", a);
+            assertNotNull("a.collection is null", a.getCollection());
+            assertTrue("Incorrect collection size", a.getCollection().size() == 3);
+            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+            
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            a.setCollection(null);
+            persistenceManager.update(a);
+            persistenceManager.save();
+            
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
          
+            a = (A) persistenceManager.getObject( "/test");
+            assertNull("a.collection is not null", a.getCollection());
+            
+            // --------------------------------------------------------------------------------
+            // Export to check the content
+            // --------------------------------------------------------------------------------
          
+            this.exportDocument("target/DefaultCollectionConverterExport.xml", "/test", true,
false);         
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
     
     public void testDropElement()
     {

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/HashMapTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/HashMapTest.java?view=diff&rev=547884&r1=547883&r2=547884
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/HashMapTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/HashMapTest.java
Sat Jun 16 01:07:49 2007
@@ -73,14 +73,31 @@
         {
         	PersistenceManager persistenceManager = getPersistenceManager();
         	
-
             // --------------------------------------------------------------------------------
-            // Create and store an object graph in the repository
+            // Create and store an object graph in the repository with null hashmap
             // --------------------------------------------------------------------------------
 
             Main main = new Main();
             main.setPath("/test");
             main.setText("Main text");
+                        
+            persistenceManager.insert(main);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
          
+            main = (Main) persistenceManager.getObject( "/test");            
+            assertTrue("Incorrect text", main.getText().equals("Main text"));           
+            assertNull("HashMap is not null", main.getHashMap());
+            
+            // --------------------------------------------------------------------------------
+            // Update an object graph in the repository
+            // --------------------------------------------------------------------------------
+
+            main = new Main();
+            main.setPath("/test");
+            main.setText("Main text");
             
             HashMapElement hashMapElement = new HashMapElement();
             Element e1 = new Element();
@@ -95,7 +112,7 @@
             
             main.setHashMap(hashMapElement);
             
-            persistenceManager.insert(main);
+            persistenceManager.update(main);
             persistenceManager.save();
             
             // --------------------------------------------------------------------------------

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/NTCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/NTCollectionConverterImplTest.java?view=diff&rev=547884&r1=547883&r2=547884
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/NTCollectionConverterImplTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/NTCollectionConverterImplTest.java
Sat Jun 16 01:07:49 2007
@@ -77,15 +77,28 @@
         try
         {
         	PersistenceManager persistenceManager = getPersistenceManager();
-
-            // --------------------------------------------------------------------------------
-            // Create and store an object graph in the repository
+            
+        	// --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository with a null collection
             // --------------------------------------------------------------------------------
 
             Page page = new Page();
             page.setPath("/test");
             page.setTitle("Page Title");
             
+            persistenceManager.insert(page);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
          
+            page = (Page) persistenceManager.getObject( "/test");
+            assertNull("page.getParagraphs is not null", page.getParagraphs());
+            assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));   
                    
+            
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
             ArrayList paragraphs = new ArrayList();
             
             paragraphs.add(new Paragraph("Para 1"));
@@ -93,7 +106,7 @@
             paragraphs.add(new Paragraph("Para 3"));
             page.setParagraphs(paragraphs);
             
-            persistenceManager.insert(page);
+            persistenceManager.update(page);
             persistenceManager.save();
             
             // --------------------------------------------------------------------------------
@@ -142,6 +155,5 @@
         }
         
     }
-
    
 }

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualNodesCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualNodesCollectionConverterImplTest.java?view=diff&rev=547884&r1=547883&r2=547884
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualNodesCollectionConverterImplTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualNodesCollectionConverterImplTest.java
Sat Jun 16 01:07:49 2007
@@ -75,11 +75,26 @@
         	PersistenceManager persistenceManager = getPersistenceManager();
 
             // --------------------------------------------------------------------------------
-            // Create and store an object graph in the repository
+            // Create and store an object graph in the repository with null values
             // --------------------------------------------------------------------------------
 
             Residual residual = new Residual.ResidualNodes();
             residual.setPath("/test");
+            persistenceManager.insert(residual);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
          
+            residual = (Residual) persistenceManager.getObject( "/test");
+            assertNotNull("Object is null", residual);
+            assertNull("Map is not null", residual.getElements());
+            
+            // --------------------------------------------------------------------------------
+            // Update an object graph in the repository
+            // --------------------------------------------------------------------------------
+            residual = new Residual.ResidualNodes();
+            residual.setPath("/test");
             
             ManagedHashMap map = new ManagedHashMap();
             map.put("value1", new Paragraph("Value1"));
@@ -88,7 +103,7 @@
             map.put("value4", new Paragraph("Value4"));
             residual.setElements(map);
             
-            persistenceManager.insert(residual);
+            persistenceManager.update(residual);
             persistenceManager.save();
             
             // --------------------------------------------------------------------------------

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualPropertiesCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualPropertiesCollectionConverterImplTest.java?view=diff&rev=547884&r1=547883&r2=547884
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualPropertiesCollectionConverterImplTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/persistence/collectionconverter/ResidualPropertiesCollectionConverterImplTest.java
Sat Jun 16 01:07:49 2007
@@ -77,11 +77,28 @@
         	PersistenceManager persistenceManager = getPersistenceManager();
 
             // --------------------------------------------------------------------------------
-            // Create and store an object graph in the repository
+            // Create and store an object graph in the repository with a null hashmap
             // --------------------------------------------------------------------------------
 
             Residual residual = new Residual.ResidualProperties();
             residual.setPath("/test");
+                        
+            persistenceManager.insert(residual);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
          
+            residual = (Residual) persistenceManager.getObject( "/test");
+            assertNotNull("Object is null", residual);
+            assertNull("Hashmap is not null", residual.getElements());
+            
+            // --------------------------------------------------------------------------------
+            // Update an object graph in the repository
+            // --------------------------------------------------------------------------------
+
+            residual = new Residual.ResidualProperties();
+            residual.setPath("/test");
             
             ManagedHashMap map = new ManagedHashMap();
             map.put("value1", "Value1");
@@ -91,7 +108,7 @@
             map.put("value5", Arrays.asList(new String[]{ "Value5-1", "Value5-2" }));
             residual.setElements(map);
             
-            persistenceManager.insert(residual);
+            persistenceManager.update(residual);
             persistenceManager.save();
             
             // --------------------------------------------------------------------------------



Mime
View raw message