incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r531579 - in /incubator/graffito/trunk/jcr/jcr-mapping/src: test-config/ test/org/apache/portals/graffito/jcr/persistence/basic/ test/org/apache/portals/graffito/jcr/testmodel/crossreference/
Date Mon, 23 Apr 2007 19:59:44 GMT
Author: clombart
Date: Mon Apr 23 12:59:44 2007
New Revision: 531579

URL: http://svn.apache.org/viewvc?view=rev&rev=531579
Log:
Add unit for GRFT-106.

Added:
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/A.java
  (contents, props changed)
      - copied, changed from r469390, incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/A.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/B.java
  (contents, props changed)
      - copied, changed from r530134, incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java
Modified:
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml?view=diff&rev=531579&r1=531578&r2=531579
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml
Mon Apr 23 12:59:44 2007
@@ -4,14 +4,17 @@
 <graffito-jcr>
 
 	<class-descriptor
-		className="org.apache.portals.graffito.jcr.testmodel.A" jcrNodeType="nt:unstructured" >
	
+		className="org.apache.portals.graffito.jcr.testmodel.crossreference.A" jcrNodeType="nt:unstructured"
>		
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="a1" jcrName="a1" />
 		<field-descriptor fieldName="a2" jcrName="a2" />
-		<bean-descriptor fieldName="b" jcrName="b" proxy="false" />		
+		<bean-descriptor fieldName="b" jcrName="b" proxy="false" />	
+		<collection-descriptor fieldName="collection"  proxy="false" 
+		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.crossreference.B"

+		                       collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl"
/>                               
 	</class-descriptor>
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.B"  jcrNodeType="nt:unstructured"
>
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.crossreference.B"
 jcrNodeType="nt:unstructured" >
 		<field-descriptor fieldName="b1" jcrName="b1"  />		
         <field-descriptor fieldName="b2" jcrName="b2"  />
         <bean-descriptor fieldName="a" jcrName="a" proxy="false" converter="org.apache.portals.graffito.jcr.persistence.beanconverter.impl.ParentBeanConverterImpl"
/>

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java?view=diff&rev=531579&r1=531578&r2=531579
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java
Mon Apr 23 12:59:44 2007
@@ -16,6 +16,8 @@
  */
 package org.apache.portals.graffito.jcr.persistence.basic;
 
+import java.util.Collection;
+
 import javax.jcr.Repository;
 import javax.jcr.UnsupportedRepositoryOperationException;
 
@@ -29,11 +31,14 @@
 import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
 import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl;
 import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
-import org.apache.portals.graffito.jcr.testmodel.A;
-import org.apache.portals.graffito.jcr.testmodel.B;
+import org.apache.portals.graffito.jcr.testmodel.crossreference.A;
+import org.apache.portals.graffito.jcr.testmodel.crossreference.B;
+
 
 /**
  * Basic test for PersistenceManager
+ * Test when objects are cross referenced 
+ * eg. object 'a' contains a reference to an object 'b' and object 'b' contains a reference
to 'a'.
  *
  * @author <a href="mailto:christophe.lombart@gmail.com>Christophe Lombart</a>
  */
@@ -71,7 +76,7 @@
         super.tearDown();
     }
     
-    public void testBean()
+    public void testCrossReferences()
     {
         try
         {
@@ -83,13 +88,27 @@
             a.setPath("/test");
             a.setA1("a1");
             a.setA2("a2");
+            
+            
             B b = new B();
             b.setB1("b1");
             b.setB2("b2");
+            // Add crossreference between b and a 
             a.setB(b);
-            b.setA(a);
-            
-            
+            b.setA(a); 
+
+            B b1 = new B();
+            b1.setB1("b1.1");
+            b1.setB2("b1.2");            
+            b1.setA(a);
+            a.addB(b1);
+
+            B b2 = new B();
+            b2.setB1("b2.1");
+            b2.setB2("b2.2");            
+            b2.setA(a);
+            a.addB(b2);
+
             persistenceManager.insert(a);
             persistenceManager.save();
             
@@ -100,6 +119,12 @@
             a = (A) persistenceManager.getObject( "/test");
             assertNotNull("a is null", a);
             assertTrue("Duplicate instance a", a == a.getB().getA());
+            
+//            Collection collection = a.getCollection();
+//            assertTrue("Invalid number of items in the collection", collection.size() ==
2);
+//            B[] bs = (B[])collection.toArray();
+//            assertTrue("Duplicate instance a", a == bs[0].getA());
+//            assertTrue("Duplicate instance a", a == bs[1].getA());
             
         }
         catch (Exception e)

Copied: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/A.java
(from r469390, incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/A.java)
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/A.java?view=diff&rev=531579&p1=incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/A.java&r1=469390&p2=incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/A.java&r2=531579
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/A.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/A.java
Mon Apr 23 12:59:44 2007
@@ -14,11 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.portals.graffito.jcr.testmodel;
+package org.apache.portals.graffito.jcr.testmodel.crossreference;
 
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.portals.graffito.jcr.testmodel.C;
+
 /**
  *
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe
</a>
@@ -29,12 +31,9 @@
 	private String path; 
     private String a1;
     private String a2;
-    private B b;
-    private B emptyB;
+    private B b;    
     private Collection collection;
-    private Collection emptyCollection; 
-    
-    
+     
     
     public String getPath() {
 		return path;
@@ -102,31 +101,14 @@
         this.collection = collection;
     }
     
-    public void addC(C c)
+    public void addB(B b)
     {
        if (collection == null )
        {
            collection = new ArrayList();
        }
        
-       collection.add(c);   
-    }
-    public Collection getEmptyCollection()
-    {
-        return emptyCollection;
-    }
-    public void setEmptyCollection(Collection emptyCollection)
-    {
-        this.emptyCollection = emptyCollection;
-    }
-    public B getEmptyB()
-    {
-        return emptyB;
+       collection.add(b);   
     }
-    public void setEmptyB(B emptyB)
-    {
-        this.emptyB = emptyB;
-    }
-    
     
 }

Propchange: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/A.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/B.java
(from r530134, incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java)
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/B.java?view=diff&rev=531579&p1=incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java&r1=530134&p2=incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/B.java&r2=531579
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/B.java
Mon Apr 23 12:59:44 2007
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.portals.graffito.jcr.testmodel;
+package org.apache.portals.graffito.jcr.testmodel.crossreference;
 
 /**
  *

Propchange: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/crossreference/B.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message