db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r422236 [2/3] - in /db/ojb/trunk/src: schema/ test/org/apache/ojb/broker/ test/org/apache/ojb/broker/cache/ test/org/apache/ojb/broker/cloneable/ test/org/apache/ojb/broker/metadata/ test/org/apache/ojb/broker/metadata/torque/
Date Sat, 15 Jul 2006 14:38:16 GMT
Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java Sat Jul 15 07:38:14 2006
@@ -6,75 +6,76 @@
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
+import org.apache.ojb.broker.query.Query;
 import org.apache.ojb.junit.PBTestCase;
 
 /**
  * Tests for extent aware path expressions
- * 
+ *
  * @author <a href="leandro@ibnetwork.com.br">Leandro Rodrigo Saad Cruz</a>
- * 
- * $Id$
+ *
+ *         $Id$
  */
 public class ExtentAwarePathExpressionsTest extends PBTestCase
 {
-	public static void main(String[] args)
-	{
-		String[] arr = {ExtentAwarePathExpressionsTest.class.getName()};
-		junit.textui.TestRunner.main(arr);
-	}
-
-	public ExtentAwarePathExpressionsTest(String testName)
-	{
-		super(testName);
-	}
-
-	public void testWithoutHintClass1() throws Exception
-	{
-		Criteria criteria = new Criteria();
-		criteria.addEqualTo("qualifiers.name", "Cars");
-		QueryByCriteria query = QueryFactory.newQuery(News.class, criteria);
-
-		broker.clearCache();
-		List content = (List) broker.getCollectionByQuery(query);
-		assertEquals(1, content.size());
-	}
-
-	public void testWithoutHintClass2() throws Exception
-	{
-		Criteria criteria = new Criteria();
-		criteria.addLike("qualifiers.name", "%ers%");
-		QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-
-		broker.clearCache();
-		List content = (List) broker.getCollectionByQuery(query);
-		assertEquals(2, content.size());
-	}
+    public static void main(String[] args)
+    {
+        String[] arr = {ExtentAwarePathExpressionsTest.class.getName()};
+        junit.textui.TestRunner.main(arr);
+    }
+
+    public ExtentAwarePathExpressionsTest(String testName)
+    {
+        super(testName);
+    }
+
+    public void testWithoutHintClass1() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        criteria.addEqualTo("qualifiers.name", "Cars");
+        Query query = QueryFactory.newQuery(News.class, criteria);
+
+        broker.clearCache();
+        List content = (List) broker.getCollectionByQuery(query);
+        assertEquals(1, content.size());
+    }
+
+    public void testWithoutHintClass2() throws Exception
+    {
+        Criteria criteria = new Criteria();
+        criteria.addLike("qualifiers.name", "%ers%");
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+
+        broker.clearCache();
+        List content = (List) broker.getCollectionByQuery(query);
+        assertEquals(2, content.size());
+    }
 
     public void testNotNullPathElement()
     {
         Criteria criteria = new Criteria();
         criteria.addNotNull("qualifiers.name");
-        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
         List content = (List) broker.getCollectionByQuery(query);
-        assertEquals(4,content.size());
+        assertEquals(4, content.size());
     }
-    
+
     public void testSetPathClass()
     {
         Criteria criteria = new Criteria();
         criteria.addNotNull("qualifiers.name");
         QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-        query.setPathClass("qualifiers",Category.class);
+        query.setPathClass("qualifiers", Category.class);
         List content = (List) broker.getCollectionByQuery(query);
-        assertEquals(2,content.size());
-        for (Iterator iter = content.iterator(); iter.hasNext();)
+        assertEquals(2, content.size());
+        for(Iterator iter = content.iterator(); iter.hasNext();)
         {
             BaseContentImpl element = (BaseContentImpl) iter.next();
-            assertTrue(element.getId() <=3 && element.getId() >=2);
+            assertTrue(element.getId() <= 3 && element.getId() >= 2);
         }
 
     }
-    
+
     public void testSetPathClassInCriteria()
     {
         Criteria criteria = new Criteria();
@@ -82,15 +83,15 @@
         criteria.addNotNull("qualifiers.name");
         criteria.setPathClass("qualifiers", Category.class);
 
-        QueryByCriteria query   = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-        List            content = (List)broker.getCollectionByQuery(query);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
-        assertEquals(2,content.size());
-        for (Iterator iter = content.iterator(); iter.hasNext();)
+        assertEquals(2, content.size());
+        for(Iterator iter = content.iterator(); iter.hasNext();)
         {
             BaseContentImpl element = (BaseContentImpl) iter.next();
 
-            assertTrue(element.getId() <=3 && element.getId() >=2);
+            assertTrue(element.getId() <= 3 && element.getId() >= 2);
         }
 
     }
@@ -100,11 +101,11 @@
         Criteria criteria = new Criteria();
         criteria.addNotNull("qualifiers.name");
         QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-        query.addPathClass("qualifiers",Qualifier.class);
-        query.addPathClass("qualifiers",Area.class);
+        query.addPathClass("qualifiers", Qualifier.class);
+        query.addPathClass("qualifiers", Area.class);
         List content = (List) broker.getCollectionByQuery(query);
-        assertEquals(1,content.size());
-        assertEquals(10,((Paper)content.get(0)).getId());
+        assertEquals(1, content.size());
+        assertEquals(10, ((Paper) content.get(0)).getId());
     }
 
     public void testAddPathClassInCriteria()
@@ -115,33 +116,33 @@
         criteria.addPathClass("qualifiers", Qualifier.class);
         criteria.addPathClass("qualifiers", Area.class);
 
-        QueryByCriteria query   = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-        List            content = (List)broker.getCollectionByQuery(query);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(10, ((Paper)content.get(0)).getId());
+        assertEquals(10, ((Paper) content.get(0)).getId());
     }
 
     /**
-     * The order of criteria elements influences the use of parenthesis, 
-     *  If we add the Like element before the NotNull one we get the wrong query 
+     * The order of criteria elements influences the use of parenthesis,
+     * If we add the Like element before the NotNull one we get the wrong query
      * Right clause : WHERE WHERE (A2.NAME IS NOT NULL  OR A2E1.NAME IS NOT NULL ) AND A0.HEADLINE LIKE  'Bra%
-     * Wrong clause : WHERE (A0.HEADLINE LIKE  'Bra%' ) AND A2.NAME IS NOT NULL  OR A2E1.NAME IS NOT NULL 
+     * Wrong clause : WHERE (A0.HEADLINE LIKE  'Bra%' ) AND A2.NAME IS NOT NULL  OR A2E1.NAME IS NOT NULL
      */
     public void testAddPathClasses()
     {
         Criteria criteria = new Criteria();
-        
-        criteria.addLike("headline","Bra%");
+
+        criteria.addLike("headline", "Bra%");
         criteria.addNotNull("qualifiers.name");
         QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-        query.addPathClass("qualifiers",Qualifier.class);
-        query.addPathClass("qualifiers",Topic.class);
-        query.addPathClass("qualifiers",Category.class);
-        
+        query.addPathClass("qualifiers", Qualifier.class);
+        query.addPathClass("qualifiers", Topic.class);
+        query.addPathClass("qualifiers", Category.class);
+
         List content = (List) broker.getCollectionByQuery(query);
-        assertEquals(1,content.size());
-        assertEquals(3,((News)content.get(0)).getId());
+        assertEquals(1, content.size());
+        assertEquals(3, ((News) content.get(0)).getId());
     }
 
     public void testAddPathClassesInCriteria()
@@ -154,19 +155,19 @@
         criteria.addPathClass("qualifiers", Topic.class);
         criteria.addPathClass("qualifiers", Category.class);
 
-        QueryByCriteria query   = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-        List            content = (List)broker.getCollectionByQuery(query);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(3, ((News)content.get(0)).getId());
-}
+        assertEquals(3, ((News) content.get(0)).getId());
+    }
 
     // Test for OJB-50
     public void testComplexCriteriaWithPathClasses_1()
     {
-        Criteria criteria         = new Criteria();
+        Criteria criteria = new Criteria();
         Criteria categoryCriteria = new Criteria();
-        Criteria topicCriteria    = new Criteria();
+        Criteria topicCriteria = new Criteria();
 
         topicCriteria.addEqualTo("qualifiers.importance", "important");
         topicCriteria.addPathClass("qualifiers", Topic.class);
@@ -175,19 +176,19 @@
         categoryCriteria.addPathClass("qualifiers", Category.class);
         criteria.addOrCriteria(categoryCriteria);
 
-        QueryByCriteria query   = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-        List            content = (List)broker.getCollectionByQuery(query);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(2, ((News)content.get(0)).getId());
+        assertEquals(2, ((News) content.get(0)).getId());
     }
 
     // Test for OJB-50
     public void testComplexCriteriaWithPathClasses_2()
     {
-        Criteria criteria         = new Criteria();
+        Criteria criteria = new Criteria();
         Criteria categoryCriteria = new Criteria();
-        Criteria topicCriteria    = new Criteria();
+        Criteria topicCriteria = new Criteria();
 
         categoryCriteria.addLike("qualifiers.description", "The%");
         categoryCriteria.addPathClass("qualifiers", Category.class);
@@ -200,23 +201,23 @@
         criteria.addOrCriteria(categoryCriteria);
         criteria.addOrCriteria(topicCriteria);
 
-        QueryByCriteria query   = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-        List            content = (List) broker.getCollectionByQuery(query);
+        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(2, ((News)content.get(0)).getId());
-        assertNotNull(((News)content.get(0)).getQualifiers());
-        assertEquals(3, ((News)content.get(0)).getQualifiers().size());
-}
+        assertEquals(2, ((News) content.get(0)).getId());
+        assertNotNull(((News) content.get(0)).getQualifiers());
+        assertEquals(3, ((News) content.get(0)).getQualifiers().size());
+    }
 
     // Test for OJB-50
     public void testComplexCriteriaWithPathClasses_3()
     {
-        Criteria criteria         = new Criteria();
-        Criteria criteriaTopicExtAndCategory         = new Criteria();
+        Criteria criteria = new Criteria();
+        Criteria criteriaTopicExtAndCategory = new Criteria();
         Criteria categoryCriteria = new Criteria();
-        Criteria topicCriteria    = new Criteria();
-        Criteria topicExtCriteria    = new Criteria();
+        Criteria topicCriteria = new Criteria();
+        Criteria topicExtCriteria = new Criteria();
 
         categoryCriteria.addLike("qualifiers.description", "The buyer");
         categoryCriteria.addPathClass("qualifiers", Category.class);
@@ -234,13 +235,13 @@
         criteria.addAndCriteria(criteriaTopicExtAndCategory);
         criteria.addAndCriteria(topicCriteria);
 
-        QueryByCriteria query   = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
-        List            content = (List) broker.getCollectionByQuery(query);
+        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(2, ((News)content.get(0)).getId());
-        assertNotNull(((News)content.get(0)).getQualifiers());
-        assertEquals(3, ((News)content.get(0)).getQualifiers().size());
+        assertEquals(2, ((News) content.get(0)).getId());
+        assertNotNull(((News) content.get(0)).getQualifiers());
+        assertEquals(3, ((News) content.get(0)).getQualifiers().size());
     }
 
     // Test for OJB-62
@@ -253,10 +254,10 @@
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(2, ((News)content.get(0)).getId());
-        assertNotNull(((News)content.get(0)).getQualifiers());
-        assertEquals(3, ((News)content.get(0)).getQualifiers().size());
-}
+        assertEquals(2, ((News) content.get(0)).getId());
+        assertNotNull(((News) content.get(0)).getQualifiers());
+        assertEquals(3, ((News) content.get(0)).getQualifiers().size());
+    }
 
     // Test for OJB-62
     public void testAddClassPathOnQuery_2()
@@ -274,75 +275,75 @@
     public void testMultipleClassPath_1a()
     {
         Criteria criteria = new Criteria();
-        criteria.addLike("headline", "SAL%");
+        criteria.addLike("date", "yes%");
         criteria.addEqualTo("qualifiers.importance", "unimportant");
         criteria.addEqualTo("qualifiers.name", "Sellers");
-        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        QueryByCriteria query = QueryFactory.newQuery(Paper.class, criteria, true);
         query.addPathClass("qualifiers", Qualifier.class);
         query.addPathClass("qualifiers", Topic.class);
         query.addPathClass("qualifiers", TopicExt.class);
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(11, ((Paper)content.get(0)).getId());
-        assertNotNull(((Paper)content.get(0)).getQualifiers());
-        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
+        assertEquals(11, ((Paper) content.get(0)).getId());
+        assertNotNull(((Paper) content.get(0)).getQualifiers());
+        assertEquals(2, ((Paper) content.get(0)).getQualifiers().size());
     }
 
     // Test multiple path class on query object
     public void testMultipleClassPath_1b()
     {
         Criteria criteria = new Criteria();
-        criteria.addLike("headline", "SAL%");
+        criteria.addLike("date", "yes%");
         criteria.addEqualTo("qualifiers.importance", "unimportant");
         criteria.addEqualTo("qualifiers.name", "Sellers");
-        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        QueryByCriteria query = QueryFactory.newQuery(Paper.class, criteria, true);
         //query.addPathClass("qualifiers", Qualifier.class);
         query.addPathClass("qualifiers", Topic.class);
         query.addPathClass("qualifiers", TopicExt.class);
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(11, ((Paper)content.get(0)).getId());
-        assertNotNull(((Paper)content.get(0)).getQualifiers());
-        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
+        assertEquals(11, ((Paper) content.get(0)).getId());
+        assertNotNull(((Paper) content.get(0)).getQualifiers());
+        assertEquals(2, ((Paper) content.get(0)).getQualifiers().size());
     }
 
     // Test multiple path class on criteria object
     public void testMultipleClassPath_2a()
     {
         Criteria criteria = new Criteria();
-        criteria.addLike("headline", "SAL%");
+        criteria.addLike("date", "yes%");
         criteria.addEqualTo("qualifiers.importance", "unimportant");
         criteria.addEqualTo("qualifiers.name", "Sellers");
         criteria.addPathClass("qualifiers", Qualifier.class);
         criteria.addPathClass("qualifiers", TopicExt.class);
         criteria.addPathClass("qualifiers", Topic.class);
-        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        QueryByCriteria query = QueryFactory.newQuery(Paper.class, criteria, true);
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(11, ((Paper)content.get(0)).getId());
-        assertNotNull(((Paper)content.get(0)).getQualifiers());
-        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
+        assertEquals(11, ((Paper) content.get(0)).getId());
+        assertNotNull(((Paper) content.get(0)).getQualifiers());
+        assertEquals(2, ((Paper) content.get(0)).getQualifiers().size());
     }
 
     // Test multiple path class on query object
     public void testMultipleClassPath_2b()
     {
         Criteria criteria = new Criteria();
-        criteria.addLike("headline", "SAL%");
+        criteria.addLike("date", "yes%");
         criteria.addEqualTo("qualifiers.importance", "unimportant");
         criteria.addEqualTo("qualifiers.name", "Sellers");
         //criteria.addPathClass("qualifiers", Qualifier.class);
         criteria.addPathClass("qualifiers", TopicExt.class);
         criteria.addPathClass("qualifiers", Topic.class);
-        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        QueryByCriteria query = QueryFactory.newQuery(Paper.class, criteria, true);
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(11, ((Paper)content.get(0)).getId());
-        assertNotNull(((Paper)content.get(0)).getQualifiers());
-        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
+        assertEquals(11, ((Paper) content.get(0)).getId());
+        assertNotNull(((Paper) content.get(0)).getQualifiers());
+        assertEquals(2, ((Paper) content.get(0)).getQualifiers().size());
     }
-}
\ No newline at end of file
+}

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/FactoryCreatedBaseObject.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/FactoryCreatedBaseObject.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/FactoryCreatedBaseObject.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/FactoryCreatedBaseObject.java Sat Jul 15 07:38:14 2006
@@ -16,6 +16,16 @@
         this.value = value;
     }
 
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId(Integer id)
+    {
+        this.id = id;
+    }
+
     public String getName()
     {
         return name;

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/FactoryCreatedObject.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/FactoryCreatedObject.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/FactoryCreatedObject.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/FactoryCreatedObject.java Sat Jul 15 07:38:14 2006
@@ -12,13 +12,33 @@
         this.value = value;
     }
 
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId(Integer id)
+    {
+        this.id = id;
+    }
+
     public String getName()
     {
         return name;
     }
 
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
     public int getValue()
     {
         return value;
+    }
+
+    public void setValue(int value)
+    {
+        this.value = value;
     }
 }

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/FieldConversionTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/FieldConversionTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/FieldConversionTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/FieldConversionTest.java Sat Jul 15 07:38:14 2006
@@ -1,13 +1,22 @@
 package org.apache.ojb.broker;
 
+import java.io.Serializable;
+import java.sql.Time;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
 import org.apache.ojb.broker.accesslayer.conversions.ConversionException;
 import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
+import org.apache.ojb.broker.accesslayer.conversions.IntList2VarcharFieldConversion;
+import org.apache.ojb.broker.accesslayer.conversions.StringList2VarcharFieldConversion;
+import org.apache.ojb.broker.accesslayer.conversions.StringVector2VarcharFieldConversion;
+import org.apache.ojb.broker.accesslayer.conversions.TimeList2VarcharFieldConversion;
 import org.apache.ojb.junit.PBTestCase;
 
-import java.io.Serializable;
-
 /**
  * Test case to check the field conversion.
  *
@@ -22,6 +31,296 @@
         junit.textui.TestRunner.main(arr);
     }
 
+    public void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    public void testStringList2VarcharFieldConversion()
+    {
+        FieldConversion conv = new StringList2VarcharFieldConversion();
+        List list = new ArrayList();
+        list.add("1");
+        List result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new ArrayList();
+        list.add("");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new ArrayList();
+        list.add("");
+        list.add("");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new ArrayList();
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new ArrayList();
+        list.add(null);
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        result = doubleConvertList2Varchar(conv, null);
+        assertEquals(null, result);
+
+        result = doubleConvertList2Varchar(conv, Collections.EMPTY_LIST);
+        assertEquals(0, result.size());
+
+        list = new ArrayList();
+        list.add("");
+        list.add("1");
+        list.add("2");
+        // '#' is not allowed, but within a String the
+        // conversion pass nevertheless
+        list.add("2#a");
+        list.add("3");
+        list.add("");
+        list.add(null);
+        list.add("");
+        list.add(null);
+        list.add("8");
+        list.add("+9+");
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        // '#' is not allowed, but within a String the
+        // conversion pass nevertheless
+        list = new ArrayList();
+        list.add("e#e");
+        list.add("test");
+        list.add("a#a#a#a#a");
+        list.add("2#####a#b");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new ArrayList();
+        list.add("NULL");
+        list.add("EMPTY");
+        list.add("EMTPY");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new ArrayList();
+        list.add("NULL");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new ArrayList();
+        list.add("EMPTY");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new ArrayList();
+        list.add("EMTPY");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+    }
+
+    public void testStringVector2VarcharFieldConversion()
+    {
+        FieldConversion conv = new StringVector2VarcharFieldConversion();
+        List list = new Vector();
+        list.add("1");
+        List result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new Vector();
+        list.add("");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new Vector();
+        list.add("");
+        list.add("");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new Vector();
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new Vector();
+        list.add(null);
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        result = doubleConvertList2Varchar(conv, null);
+        assertEquals(null, result);
+
+        result = doubleConvertList2Varchar(conv, Collections.EMPTY_LIST);
+        assertEquals(0, result.size());
+
+        list = new Vector();
+        list.add("");
+        list.add("1");
+        list.add("2");
+        // '#' is not allowed, but within a String the
+        // conversion pass nevertheless
+        list.add("2#a");
+        list.add("3");
+        list.add("");
+        list.add(null);
+        list.add("");
+        list.add(null);
+        list.add("8");
+        list.add("+9+");
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        // '#' is not allowed, but within a String the
+        // conversion pass nevertheless
+        list = new Vector();
+        list.add("e#e");
+        list.add("test");
+        list.add("a#a#a#a#a");
+        list.add("2#####a#b");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new Vector();
+        list.add("NULL");
+        list.add("EMPTY");
+        list.add("EMTPY");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new Vector();
+        list.add("NULL");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new Vector();
+        list.add("EMPTY");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+
+        list = new Vector();
+        list.add("EMTPY");
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list, result);
+    }
+
+    public void testTimeList2VarcharFieldConversion()
+    {
+        FieldConversion conv = new TimeList2VarcharFieldConversion();
+
+        List list = new ArrayList();
+        list.add(new Time(1));
+        List result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list.toString(), result.toString());
+
+        list = new ArrayList();
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list.toString(), result.toString());
+
+        list = new ArrayList();
+        list.add(null);
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list.toString(), result.toString());
+
+        result = doubleConvertList2Varchar(conv, null);
+        assertEquals(null, result);
+
+        result = doubleConvertList2Varchar(conv, Collections.EMPTY_LIST);
+        assertEquals(0, result.size());
+
+        list = new ArrayList();
+        list.add(null);
+        list.add(new Time(1));
+        list.add(new Time(2));
+        list.add(new Time(System.currentTimeMillis()));
+        // '#' is not allowed, but within a String the
+        // conversion pass nevertheless
+        list.add(new Time(3));
+        list.add(new Time(4));
+        list.add(null);
+        list.add(null);
+        list.add(new Time(5));
+        list.add(new Time(6));
+        list.add(new Time(Long.MAX_VALUE));
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list.toString(), result.toString());
+    }
+
+    public void testIntList2VarcharFieldConversion()
+    {
+        FieldConversion conv = new IntList2VarcharFieldConversion();
+
+        List list = new ArrayList();
+        list.add(new Integer(1));
+        List result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list.toString(), result.toString());
+
+        list = new ArrayList();
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list.toString(), result.toString());
+
+        list = new ArrayList();
+        list.add(null);
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list.toString(), result.toString());
+
+        result = doubleConvertList2Varchar(conv, null);
+        assertEquals(null, result);
+
+        result = doubleConvertList2Varchar(conv, Collections.EMPTY_LIST);
+        assertEquals(0, result.size());
+
+        list = new ArrayList();
+        list.add(null);
+        list.add(new Integer(1));
+        list.add(new Integer(2));
+        // '#' is not allowed, but within a String the
+        // conversion pass nevertheless
+        list.add(new Integer(3));
+        list.add(new Integer(4));
+        list.add(null);
+        list.add(null);
+        list.add(new Integer(5));
+        list.add(new Integer(6));
+        list.add(null);
+        result = doubleConvertList2Varchar(conv, list);
+        assertEquals(list.toString(), result.toString());
+    }
+
+    private List doubleConvertList2Varchar(FieldConversion conv, List list)
+    {
+        String str = (String) conv.javaToSql(list);
+        //System.out.println("start: " + list);
+        //System.out.println("-->conv_sql: " + str);
+        List list2 = (List) conv.sqlToJava(str);
+        //System.out.println(" -->conv_java: " + list2);
+        str = (String) conv.javaToSql(list2);
+        //System.out.println(" -->conv_sql: " + str);
+        list2 = (List) conv.sqlToJava(str);
+        //System.out.println(" -->conv_java: " + list2);
+        //System.out.println("");
+
+        return list2;
+    }
+
+
+
     public void testConversion()
     {
         int id = (int) (System.currentTimeMillis() % Integer.MAX_VALUE);
@@ -31,9 +330,9 @@
         broker.store(vo);
         broker.commitTransaction();
 
-        Identity identity = new Identity(vo, broker);
+        Identity identity = broker.serviceIdentity().buildIdentity(vo);
         broker.clearCache();
-        ConversionVO find_vo = (ConversionVO) broker.getObjectByIdentity(identity);
+        broker.getObjectByIdentity(identity);
     }
 
     public static class FieldConversionConversionIdToInteger implements FieldConversion
@@ -66,6 +365,7 @@
     {
         public Object javaToSql(Object source) throws ConversionException
         {
+            if(source == null) return null;
             if (!(source instanceof Long))
             {
                 throw new ConversionException(
@@ -77,6 +377,7 @@
 
         public Object sqlToJava(Object source) throws ConversionException
         {
+            if(source == null) return null;
             if (!(source instanceof Integer))
             {
                 throw new ConversionException(

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java Sat Jul 15 07:38:14 2006
@@ -11,14 +11,11 @@
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
-import org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl;
 import org.apache.ojb.broker.metadata.ClassDescriptor;
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.Query;
 import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
-import org.apache.ojb.broker.util.logging.LoggerFactory;
-import org.apache.ojb.broker.util.logging.PoorMansLoggerImpl;
 import org.apache.ojb.junit.PBTestCase;
 
 /**
@@ -43,6 +40,41 @@
         broker.serviceBatchManager().setBatchMode(true);
     }
 
+    /**
+     * Bug:
+     * this test show a problem when using table-per-subclass inheritance
+     * and method PB.getByIdentity. When the real class of the Identity is not
+     * correct the returned object has the wrong type. For table-per-class inheritance strategy
+     * this behavior will be correct, but in this case OJB should anyway detect the correct
+     * type of the result.
+     * Strange: When set logging property
+     * org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.LogLevel=DEBUG
+     * instead of WARN, the test will pass.
+     */
+    public void testLookupByIdentity_2()
+    {
+        long timestamp = System.currentTimeMillis();
+        Long id_2 = new Long(timestamp);
+        String name = "testLookupByIdentity_2_" + timestamp;
+        Executive executive = new Executive(id_2, "executive_" + name, "department_1", null);
+
+        broker.beginTransaction();
+        broker.store(executive);
+        broker.commitTransaction();
+        broker.clearCache();
+
+        // we build the Identity with "wrong" real class specified
+        // (which is Executive, not Employee), but this shouldn't matter
+        // because OJB should detect the correct type on query
+        Identity oid = broker.serviceIdentity().buildIdentity(
+                Employee.class, new String[]{"id", "id_2"}, new Object[]{executive.getId(), executive.getId_2()});
+        Object result = broker.getObjectByIdentity(oid);
+
+        //System.out.println("Result: " + result);
+        assertEquals(Executive.class.getName(), result.getClass().getName());
+        assertEquals(executive, result);
+    }
+
     public void testLookupByIdentity()
     {
         long timestamp = System.currentTimeMillis();
@@ -75,54 +107,68 @@
         assertNotNull(newEm1);
         assertNotNull(newEx1);
         assertNotNull(newM1);
+
         assertEquals(em1.getId(), newEm1.getId());
         assertEquals(em1.getId_2(), newEm1.getId_2());
         assertEquals(2, newM1.getExecutives().size());
 
         assertEquals(m1.getId(), newM1.getId());
         assertEquals(m1.getId_2(), newM1.getId_2());
+        assertEquals(2, newM1.getExecutives().size());
 
         assertEquals(ex1.getId(), newEx1.getId());
         assertEquals(ex1.getId_2(), newEx1.getId_2());
+        assertEquals(ex1.getDepartment(), newEx1.getDepartment());
     }
 
-    /**
-     * Bug:
-     * this test show a problem when using table-per-subclass inheritance
-     * and method PB.getByIdentity. When the real class of the Identity is not
-     * correct the returned object has the wrong type. For table-per-class inheritance strategy
-     * this behavior will be correct, but in this case OJB should anyway detect the correct
-     * type of the result.
-     * Strange: When set logging property
-     * org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.LogLevel=DEBUG
-     * instead of WARN, the test will pass.
-     */
-    public void testLookupByIdentity_2()
+    public void testLookupByQuery()
     {
-//        PoorMansLoggerImpl logger =  (PoorMansLoggerImpl) LoggerFactory.getLogger(SqlGeneratorDefaultImpl.class);
-//        logger.setLevel("DEBUG");
-//        logger.setLevel("WARN");
-        
         long timestamp = System.currentTimeMillis();
         Long id_2 = new Long(timestamp);
-        String name = "testLookupByIdentity_2_" + timestamp;
-        Executive executive = new Executive(id_2, "executive_" + name, "department_1", null);
+        String name = "testLookupByIdentity_" + timestamp;
+        Employee em1 = new Employee(id_2, "employee_" + name);
+        Executive ex1 = new Executive(id_2, "executive_" + name, "department_1", null);
+        Executive ex2 = new Executive(id_2, "executive_" + name, "department_2", null);
+        ArrayList list = new ArrayList();
+        list.add(ex1);
+        list.add(ex2);
+        Manager m1 = new Manager(id_2, "manager_" + name);
+        m1.setExecutives(list);
 
         broker.beginTransaction();
-        broker.store(executive);
+        broker.store(em1);
+        broker.store(m1);
         broker.commitTransaction();
+
+        Criteria crit = new Criteria();
+        crit.addEqualTo("name", "employee_" + name);
+        Query q = QueryFactory.newQuery(Employee.class, crit);
+        Employee newEm1 = (Employee) broker.getObjectByQuery(q);
+
+        crit = new Criteria();
+        crit.addEqualTo("name", "executive_" + name);
+        q = QueryFactory.newQuery(Employee.class, crit);
+        Executive newEx1 = (Executive) broker.getObjectByQuery(q);
+
+        crit = new Criteria();
+        crit.addEqualTo("name", "manager_" + name);
+        q = QueryFactory.newQuery(Employee.class, crit);
+        Manager newM1 = (Manager) broker.getObjectByQuery(q);
+
         broker.clearCache();
 
-        // we build the Identity with "wrong" real class specified
-        // (which is Executive, not Employee), but this shouldn't matter
-        // because OJB should detect the correct type on query
-        Identity oid = broker.serviceIdentity().buildIdentity(
-                Employee.class, new String[]{"id", "id_2"}, new Object[]{executive.getId(), executive.getId_2()});
-        Object result = broker.getObjectByIdentity(oid);
+        assertNotNull(newEm1);
+        assertNotNull(newEx1);
+        assertNotNull(newM1);
+        assertEquals(2, newM1.getExecutives().size());
+        assertEquals(em1.getId(), newEm1.getId());
+        assertEquals(em1.getId_2(), newEm1.getId_2());
 
-        System.out.println("Result: " + result);
-        assertEquals(Executive.class.getName(), result.getClass().getName());
-        assertEquals(executive, result);
+        assertEquals(m1.getId(), newM1.getId());
+        assertEquals(m1.getId_2(), newM1.getId_2());
+
+        assertEquals(ex1.getId(), newEx1.getId());
+        assertEquals(ex1.getId_2(), newEx1.getId_2());
     }
 
     public void testQueryInheritancedObjects()
@@ -370,6 +416,9 @@
 
     public void testInheritedReferences() throws Exception
     {
+        // TODO: fix this bug
+        //if(ojbSkipKnownIssueProblem("[OJB-84] Will be fixed in next version")) return;
+
         long timestamp = System.currentTimeMillis();
         Long id_2 = new Long(timestamp);
         String name = "testInheritedReferences_" + timestamp;
@@ -1262,6 +1311,36 @@
         assertNull(newM1);
     }
 
+    public void testDelete_2()
+    {
+        long timestamp = System.currentTimeMillis();
+        Long id_2 = new Long(timestamp);
+        String name = "testDelete_2_" + timestamp;
+        Manager m1 = new Manager(id_2, "manager_" + name);
+
+        broker.beginTransaction();
+        broker.store(m1);
+        broker.commitTransaction();
+
+        Identity m1_oid = broker.serviceIdentity().buildIdentity(m1);
+        broker.clearCache();
+        Manager newM1 = (Manager) broker.getObjectByIdentity(m1_oid);
+        assertNotNull(newM1);
+
+        broker.beginTransaction();
+        broker.delete(newM1);
+        broker.commitTransaction();
+
+        newM1 = (Manager) broker.getObjectByIdentity(m1_oid);
+        assertNull(newM1);
+
+        Query q = QueryFactory.newQuery(
+                Employee.class,
+                new Criteria().addEqualTo("id", m1.getId()).addEqualTo("name", m1.getName()));
+        Object result = broker.getObjectByQuery(q);
+        assertNull(result);
+    }
+
     /**
      * Check backward compatibility with 'old' super-reference handling using explicite
      * anonymous field for FK to super class/table.
@@ -1783,6 +1862,25 @@
             this.name = name;
         }
 
+        public List getManagers()
+        {
+            return managers;
+        }
+
+        public void setManagers(List managers)
+        {
+            this.managers = managers;
+        }
+
+        public void addManager(Manager manager)
+        {
+            if(this.managers == null)
+            {
+                this.managers = new ArrayList();
+            }
+            this.managers.add(manager);
+        }
+
         public List getShareholders()
         {
             return shareholders;
@@ -1820,32 +1918,6 @@
         {
             return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE, false, Consortium.class);
         }
-
-        /**
-         * @return the managers
-         */
-        public List getManagers()
-        {
-            return managers;
-        }
-
-        /**
-         * @param managers the managers to set
-         */
-        public void setManagers(List managers)
-        {
-            this.managers = managers;
-        }
-        
-        public void addManager(Manager manager)
-        {
-            if(this.managers == null)
-            {
-                this.managers = new ArrayList();
-            }
-            this.managers.add(manager);
-        }
-
     }
 
     public static class Entity

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/InitializableObject.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/InitializableObject.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/InitializableObject.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/InitializableObject.java Sat Jul 15 07:38:14 2006
@@ -22,4 +22,24 @@
 		initCalled = true;
     }
 
+    public boolean isInitCalled()
+    {
+        return initCalled;
+    }
+
+    public void setInitCalled(boolean initCalled)
+    {
+        this.initCalled = initCalled;
+    }
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId(int id)
+    {
+        this.id = id;
+    }
+
 }

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/KeyConstraintViolationTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/KeyConstraintViolationTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/KeyConstraintViolationTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/KeyConstraintViolationTest.java Sat Jul 15 07:38:14 2006
@@ -1,5 +1,6 @@
 package org.apache.ojb.broker;
 
+import org.apache.ojb.broker.util.ObjectModification;
 import org.apache.ojb.junit.PBTestCase;
 
 /**
@@ -34,7 +35,7 @@
         obj.setProductGroupId(new Integer(1));
         obj.articleName = "repeated Article";
         // storing once should be ok.
-        broker.store(obj, OJB.INSERT);
+        broker.store(obj, ObjectModification.INSERT);
         broker.commitTransaction();
 
         broker.clearCache();
@@ -47,7 +48,7 @@
 			obj2.articleName = "repeated Article";
 
 			// store it again!
-			broker.store(obj2, OJB.INSERT);
+			broker.store(obj2, ObjectModification.INSERT);
 			broker.commitTransaction();
 
 			fail("Should have thrown a KeyConstraintViolatedException");

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/M2NTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/M2NTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/M2NTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/M2NTest.java Sat Jul 15 07:38:14 2006
@@ -110,12 +110,12 @@
         assertNull(new_p_1);
     }
 
-    public void testSimpleStore()
+    public void testSimpleStore_1()
     {
         ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, OBJECT, false);
         ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, OBJECT, false);
         ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, OBJECT, false);
-        String postfix = "testSimple_" + System.currentTimeMillis();
+        String postfix = "testSimpleStore_1_" + System.currentTimeMillis();
         Movie m = new MovieImpl(postfix, postfix, null);
         Actor a = new Actor(postfix);
 
@@ -133,6 +133,30 @@
         assertEquals(1, a.getMovies().size());
     }
 
+    public void testSimpleStore_2()
+    {
+        ojbChangeReferenceSetting(MovieImpl.class, "actors", false, OBJECT, OBJECT, false);
+        ojbChangeReferenceSetting(MovieImpl.class, "actors2", false, OBJECT, OBJECT, false);
+        ojbChangeReferenceSetting(Actor.class, "movies", false, OBJECT, OBJECT, false);
+        String postfix = "testSimpleStore_2_" + System.currentTimeMillis();
+        Movie m = new MovieImpl(postfix, postfix, null);
+        Actor a = new Actor(postfix);
+
+        broker.beginTransaction();
+        broker.store(m);
+        broker.store(a);
+
+        m.addActor(a);
+        broker.store(m);
+        broker.commitTransaction();
+
+        // needed, because autoretrieve is set false
+        broker.retrieveAllReferences(a);
+
+        assertNotNull(a.getMovies());
+        assertEquals(1, a.getMovies().size());
+    }
+
     /**
      * Test deprecated auto Settings
      */
@@ -654,7 +678,6 @@
         broker.beginTransaction();
         broker.store(movie);
         broker.commitTransaction();
-        broker.clearCache();
 
         /*
         all auto-xxx settings are false, so only the movie object should be
@@ -1246,21 +1269,14 @@
         return QueryFactory.newQuery(Movie.class, c);
     }
 
-    QueryByCriteria movieWithArrayQuery(String postfix)
-    {
-        Criteria c = new Criteria();
-        c.addLike("idStr", "%" + postfix + "%");
-        return QueryFactory.newQuery(MovieWithArray.class, c);
-    }
-
-    QueryByCriteria queryActor(String postfix)
+    Query queryActor(String postfix)
     {
         Criteria c = new Criteria();
         c.addLike("name", "%" + postfix + "%");
         return QueryFactory.newQuery(Actor.class, c);
     }
 
-    QueryByCriteria queryRole(Actor actor, Movie movie)
+    Query queryRole(Actor actor, Movie movie)
     {
         Criteria c = new Criteria();
         if(actor != null) c.addEqualTo("actorId", actor.getId());
@@ -1279,7 +1295,7 @@
         return QueryFactory.newQuery(Role.class, c);
     }
 
-    QueryByCriteria roleQueryActorOrMovieMatch(Actor actor, Movie movie)
+    Query roleQueryActorOrMovieMatch(Actor actor, Movie movie)
     {
         Criteria c_1 = new Criteria();
         Criteria c_2 = new Criteria();
@@ -1298,6 +1314,13 @@
             c_2 = c_1;
         }
         return QueryFactory.newQuery(Role.class, c_2);
+    }
+
+    QueryByCriteria movieWithArrayQuery(String postfix)
+    {
+        Criteria c = new Criteria();
+        c.addLike("idStr", "%" + postfix + "%");
+        return QueryFactory.newQuery(MovieWithArray.class, c);
     }
 
     /**

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/MtoNTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/MtoNTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/MtoNTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/MtoNTest.java Sat Jul 15 07:38:14 2006
@@ -126,9 +126,9 @@
             qual.setName("qual " + now);
             paper.setQualifiers(Arrays.asList(new Qualifier[] { qual }));
             broker.beginTransaction();
-            broker.store(paper);        // store Paper and intermediary table only
             broker.store(qual);         // store Qualifier
-            Identity paperId = new Identity(paper, broker);
+            broker.store(paper);        // store Paper and intermediary table only
+            Identity paperId = broker.serviceIdentity().buildIdentity(paper);
             broker.commitTransaction();
 
             broker.clearCache();
@@ -366,8 +366,10 @@
 
         Category categoryId1 = new Category(1);
 
+        broker.beginTransaction();
         MtoNImplementor m2n = new MtoNImplementor(broker, "qualifiers", newsId2, categoryId1);
         broker.deleteMtoNImplementor(m2n);
+        broker.commitTransaction();
 
 		broker.clearCache();
 		newNews = (News) broker.getObjectByIdentity(id);
@@ -386,7 +388,9 @@
 		int size = newNews.getQualifiers().size();
 
 		MtoNImplementor m2n = new MtoNImplementor(broker, "qualifiers", newsId2,categoryId2);
+        broker.beginTransaction();
 		broker.addMtoNImplementor(m2n);
+        broker.commitTransaction();
 
 		broker.clearCache();
 		newNews = (News) broker.getObjectByIdentity(id);

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/MultipleDBTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/MultipleDBTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/MultipleDBTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/MultipleDBTest.java Sat Jul 15 07:38:14 2006
@@ -61,7 +61,7 @@
      */
     public void testMaterializeFromDifferentDB()
     {
-        String name = "testMaterializeFromDifferentDB" + System.currentTimeMillis();
+        String name = "testMaterializeFromDifferentDB_" + System.currentTimeMillis();
         PersistenceBroker broker = ojb.lookupBroker();
         PersistenceBroker brokerFarAway = ojb.lookupBroker(TestHelper.FAR_AWAY_KEY);
 
@@ -73,7 +73,7 @@
             broker.store(obj);
             broker.commitTransaction();
 
-            Identity oid = new Identity(obj, broker);
+            Identity oid = broker.serviceIdentity().buildIdentity(obj);
 
             MultipleObjectRef ref_1 = new MultipleObjectRef();
             MultipleObjectRef ref_2 = new MultipleObjectRef();
@@ -99,14 +99,8 @@
         }
         finally
         {
-            if(broker != null)
-            {
-                broker.close();
-            }
-            if(brokerFarAway != null)
-            {
-                brokerFarAway.close();
-            }
+            if(broker != null) broker.close();
+            if(brokerFarAway != null) brokerFarAway.close();
         }
     }
 

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/ObjectRepository.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/ObjectRepository.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/ObjectRepository.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/ObjectRepository.java Sat Jul 15 07:38:14 2006
@@ -149,14 +149,33 @@
 
     public static abstract class AB extends ABE implements Serializable
     {
-        /** the special attribute telling OJB which concrete class this Object has.
+         private int id;
+        /**
+         * This special attribute telling OJB which concrete class this Object has.
          * NOTE: this attribute MUST be called ojbConcreteClass
          */
-        protected String ojbConcreteClass;
+        private String ojbConcreteClass;
 
-        public String getConcreteClass()
+        protected AB()
         {
-            return ojbConcreteClass;
+            // this guarantee that always the correct class name will be set
+            this.ojbConcreteClass = this.getClass().getName();
+        }
+
+        protected AB(int id)
+        {
+            this();
+            this.id = id;
+        }
+
+        public int getId()
+        {
+            return id;
+        }
+
+        public void setId(int id)
+        {
+            this.id = id;
         }
 
         public String getOjbConcreteClass()
@@ -170,7 +189,6 @@
         }
     }
 
-   
     public static interface AAlone
     {
     }
@@ -181,19 +199,17 @@
 
     public static class A extends AB implements AAlone
     {
-        int id;
-        int someValue;
-        String someAField;
+        private int someValue;
+        private String someAField;
 
         public A()
         {
-            setOjbConcreteClass(A.class.getName());
+            super();
         }
 
-        public A(int pId, String pOjbConcreteClass, int pSomeValue)
+        public A(int pId, int pSomeValue)
         {
-            this.id = pId;
-            this.ojbConcreteClass = pOjbConcreteClass;
+            super(pId);
             this.someValue = pSomeValue;
         }
 
@@ -207,16 +223,6 @@
             this.someAField = someAField;
         }
 
-        public int getId()
-        {
-            return id;
-        }
-
-        public void setId(int id)
-        {
-            this.id = id;
-        }
-
         public int getSomeValue()
         {
             return someValue;
@@ -230,19 +236,17 @@
 
     public static class B extends AB
     {
-        int id;
-        int someValue;
-        String someBField;
+        private int someValue;
+        private String someBField;
 
         public B()
         {
-            setOjbConcreteClass(B.class.getName());
+            super();
         }
 
-        public B(int pId, String pOjbConcreteClass, int pSomeValue)
+        public B(int pId, int pSomeValue)
         {
-            this.id = pId;
-            this.ojbConcreteClass = pOjbConcreteClass;
+            super(pId);
             this.someValue = pSomeValue;
         }
 
@@ -256,16 +260,6 @@
             this.someBField = someBField;
         }
 
-        public int getId()
-        {
-            return id;
-        }
-
-        public void setId(int id)
-        {
-            this.id = id;
-        }
-
         public int getSomeValue()
         {
             return someValue;
@@ -282,35 +276,29 @@
         public B1()
         {
             super();
-            setOjbConcreteClass(B1.class.getName());
         }
 
-        public B1(int pId, String pOjbConcreteClass, int pSomeValue)
+        public B1(int pId, int pSomeValue)
         {
-            super(pId, pOjbConcreteClass, pSomeValue);
+            super(pId, pSomeValue);
         }
     }
 
     public static class C implements Serializable
     {
-        int id;
-        String ojbConcreteClass;
-        int someValue;
-
-        public String getConcreteClass()
-        {
-            return ojbConcreteClass;
-        }
+        private String ojbConcreteClass;
+        private int id;
+        private int someValue;
 
         public C()
         {
-            ojbConcreteClass = C.class.getName();
+            ojbConcreteClass = this.getClass().getName();
         }
 
-        public C(int pId, String pOjbConcreteClass, int pSomeValue)
+        public C(int pId, int pSomeValue)
         {
+            this();
             this.id = pId;
-            this.ojbConcreteClass = pOjbConcreteClass;
             this.someValue = pSomeValue;
         }
 
@@ -349,21 +337,19 @@
     {
         public D()
         {
-            ojbConcreteClass = D.class.getName();
+            super();
         }
 
-        public D(int pId, String pOjbConcreteClass, int pSomeValue)
+        public D(int pId, int pSomeValue)
         {
-            this.id = pId;
-            this.ojbConcreteClass = pOjbConcreteClass;
-            this.someValue = pSomeValue;
+            super(pId, pSomeValue);
         }
     }
 
     public static class E extends ABE implements Serializable
     {
-        Integer id;
-        protected int someSuperValue;
+        private Integer id;
+        private int someSuperValue;
 
         public Integer getId()
         {
@@ -384,7 +370,6 @@
         {
             this.someSuperValue = someSuperValue;
         }
-        
     }
 
     public static abstract class LMNO implements Serializable

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/OneToManyTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/OneToManyTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/OneToManyTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/OneToManyTest.java Sat Jul 15 07:38:14 2006
@@ -54,23 +54,23 @@
 
     	broker.clearCache();
     	pg = (ProductGroupWithRemovalAwareCollection) broker.getObjectByIdentity(pgId);
-    	assertEquals(3,pg.getAllArticles().size());
+    	assertEquals(3,pg.getAllArticlesInGroup().size());
 
-    	InterfaceArticle ic = (InterfaceArticle) pg.getAllArticles().get(2);
+    	InterfaceArticle ic = (InterfaceArticle) pg.getAllArticlesInGroup().get(2);
     	
     	// BRJ:
     	// the object to be removed must be part of the collection
     	// removing a materialized object when the collection contains proxies
     	// does not work with the new implementation of RemovalAwareCollection
-    	pg.getAllArticles().remove(ic);
-    	pg.getAllArticles().remove(0);
+    	pg.getAllArticlesInGroup().remove(ic);
+    	pg.getAllArticlesInGroup().remove(0);
         broker.beginTransaction();
     	broker.store(pg);
         broker.commitTransaction();
 
     	broker.clearCache();
     	pg = (ProductGroupWithRemovalAwareCollection) broker.getObjectByIdentity(pgId);
-    	assertEquals(1,pg.getAllArticles().size());
+    	assertEquals(1,pg.getAllArticlesInGroup().size());
     }
 
     /**

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1Impl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1Impl.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1Impl.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1Impl.java Sat Jul 15 07:38:14 2006
@@ -6,4 +6,14 @@
 public class Ownable1Impl implements Ownable1
 {
     private Integer id;
+
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId(Integer id)
+    {
+        this.id = id;
+    }
 }

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2Impl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2Impl.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2Impl.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2Impl.java Sat Jul 15 07:38:14 2006
@@ -6,4 +6,14 @@
 public class Ownable2Impl implements Ownable2
 {
     private Integer id;
+
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId(Integer id)
+    {
+        this.id = id;
+    }
 }

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/Owner.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/Owner.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/Owner.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/Owner.java Sat Jul 15 07:38:14 2006
@@ -11,8 +11,33 @@
     private Integer ownedId;
     private Ownable owned;
 
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId(Integer id)
+    {
+        this.id = id;
+    }
+
+    public Integer getOwnedId()
+    {
+        return ownedId;
+    }
+
+    public void setOwnedId(Integer ownedId)
+    {
+        this.ownedId = ownedId;
+    }
+
     public Ownable getOwned()
     {
         return owned;
+    }
+
+    public void setOwned(Ownable owned)
+    {
+        this.owned = owned;
     }
 }

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/cache/LocalCacheTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/cache/LocalCacheTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/cache/LocalCacheTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/cache/LocalCacheTest.java Sat Jul 15 07:38:14 2006
@@ -21,8 +21,6 @@
 import java.util.List;
 
 import org.apache.ojb.broker.Identity;
-import org.apache.ojb.broker.metadata.ClassDescriptor;
-import org.apache.ojb.broker.metadata.MetadataException;
 import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.Query;
@@ -33,13 +31,12 @@
  * Tests both caching level (LocalCache + real OjbjectCache) using circular
  * relationship tests.
  *
- * @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
  * @version $Id$
  */
 public class LocalCacheTest extends PBTestCase
 {
-    private static final int CASCADE_NONE = ObjectReferenceDescriptor.CASCADE_NONE;
-    private static final int CASCADE_LINK = ObjectReferenceDescriptor.CASCADE_LINK;
+    //private static final int CASCADE_NONE = ObjectReferenceDescriptor.CASCADE_NONE;
+    //private static final int CASCADE_LINK = ObjectReferenceDescriptor.CASCADE_LINK;
     private static final int CASCADE_OBJECT = ObjectReferenceDescriptor.CASCADE_OBJECT;
 
     public static void main(String[] args)
@@ -50,28 +47,24 @@
 
     public void tearDown() throws Exception
     {
-        setReferenceMetadata(Person.class, "father", true, CASCADE_NONE, CASCADE_NONE, false);
-        setReferenceMetadata(Person.class, "grandfather", true, CASCADE_NONE, CASCADE_NONE, false);
-        setReferenceMetadata(Person.class, "childs", true, CASCADE_NONE, CASCADE_NONE, false);
-        setReferenceMetadata(Person.class, "grandchilds", true, CASCADE_NONE, CASCADE_NONE, false);
         super.tearDown();
     }
 
     public void testCircularStore()
     {
         // prepare test
-        setReferenceMetadata(Person.class, "father", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
-        setReferenceMetadata(Person.class, "grandfather", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
-        setReferenceMetadata(Person.class, "childs", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
-        setReferenceMetadata(Person.class, "grandchilds", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "father", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "grandfather", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "childs", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "grandchilds", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
 
         String postfix = "_testCircularStore_" + System.currentTimeMillis();
         Person junior = createComplexFamily(postfix);
         broker.beginTransaction();
         broker.store(junior);
         broker.commitTransaction();
-        Identity oidJunior = new Identity(junior, broker);
-        Identity oidSenior = new Identity(junior.getFather(), broker);
+        Identity oidJunior = broker.serviceIdentity().buildIdentity(junior);
+        Identity oidSenior = broker.serviceIdentity().buildIdentity(junior.getFather());
         broker.clearCache();
 
         Criteria crit = new Criteria();
@@ -93,31 +86,79 @@
 
         Collection result = broker.getCollectionByQuery(q);
         assertEquals(2, result.size());
-        for (Iterator iterator = result.iterator(); iterator.hasNext();)
+        for(Iterator iterator = result.iterator(); iterator.hasNext();)
         {
-            Person p =  (Person)iterator.next();
+            Person p = (Person) iterator.next();
             assertNotNull(p.getFather());
-            assertEquals("jeffJunior"+postfix, p.getFather().getName());
+            assertEquals("jeffJunior" + postfix, p.getFather().getName());
             assertNotNull(p.getGrandfather());
-            assertEquals("jeffSenior"+postfix, p.getGrandfather().getName());
+            assertEquals("jeffSenior" + postfix, p.getGrandfather().getName());
+        }
+    }
+
+    /**
+     * same as above but without clearing the cache
+     */
+    public void testCircularStore_2()
+    {
+        // prepare test
+        ojbChangeReferenceSetting(Person.class, "father", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "grandfather", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "childs", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "grandchilds", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+
+        String postfix = "_testCircularStore_2_" + System.currentTimeMillis();
+        Person junior = createComplexFamily(postfix);
+        broker.beginTransaction();
+        broker.store(junior);
+        broker.commitTransaction();
+        Identity oidJunior = broker.serviceIdentity().buildIdentity(junior);
+        Identity oidSenior = broker.serviceIdentity().buildIdentity(junior.getFather());
+
+        Criteria crit = new Criteria();
+        crit.addLike("name", "jeffChild_%" + postfix);
+        Query q = QueryFactory.newQuery(Person.class, crit);
+
+        Person newJunior = (Person) broker.getObjectByIdentity(oidJunior);
+        assertNotNull(newJunior);
+        assertNotNull(newJunior.getFather());
+        assertNotNull(newJunior.getChilds());
+        assertEquals(2, newJunior.getChilds().size());
+
+        Person newSenior = (Person) broker.getObjectByIdentity(oidSenior);
+        assertNotNull(newSenior);
+        assertNotNull(newSenior.getChilds());
+        assertEquals(1, newSenior.getChilds().size());
+        assertNotNull(newSenior.getGrandchilds());
+        assertEquals(2, newSenior.getGrandchilds().size());
+
+        Collection result = broker.getCollectionByQuery(q);
+        assertEquals(2, result.size());
+        for(Iterator iterator = result.iterator(); iterator.hasNext();)
+        {
+            Person p = (Person) iterator.next();
+            assertNotNull(p.getFather());
+            assertEquals("jeffJunior" + postfix, p.getFather().getName());
+            assertNotNull(p.getGrandfather());
+            assertEquals("jeffSenior" + postfix, p.getGrandfather().getName());
         }
     }
 
     public void testCircularStoreUpdate()
     {
         // prepare test
-        setReferenceMetadata(Person.class, "father", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
-        setReferenceMetadata(Person.class, "grandfather", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
-        setReferenceMetadata(Person.class, "childs", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
-        setReferenceMetadata(Person.class, "grandchilds", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "father", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "grandfather", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "childs", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "grandchilds", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
 
         String postfix = "_testCircularStore_" + System.currentTimeMillis();
         Person junior = createComplexFamily(postfix);
         broker.beginTransaction();
         broker.store(junior);
         broker.commitTransaction();
-        Identity oidJunior = new Identity(junior, broker);
-        Identity oidSenior = new Identity(junior.getFather(), broker);
+        Identity oidJunior = broker.serviceIdentity().buildIdentity(junior);
+        Identity oidSenior = broker.serviceIdentity().buildIdentity(junior.getFather());
         broker.clearCache();
 
         Criteria crit = new Criteria();
@@ -139,17 +180,17 @@
 
         Collection result = broker.getCollectionByQuery(q);
         assertEquals(2, result.size());
-        for (Iterator iterator = result.iterator(); iterator.hasNext();)
+        for(Iterator iterator = result.iterator(); iterator.hasNext();)
         {
-            Person p =  (Person)iterator.next();
+            Person p = (Person) iterator.next();
             assertNotNull(p.getFather());
-            assertEquals("jeffJunior"+postfix, p.getFather().getName());
+            assertEquals("jeffJunior" + postfix, p.getFather().getName());
             assertNotNull(p.getGrandfather());
-            assertEquals("jeffSenior"+postfix, p.getGrandfather().getName());
+            assertEquals("jeffSenior" + postfix, p.getGrandfather().getName());
         }
 
         broker.beginTransaction();
-        Person newChild = new Person("newGrandChild"+postfix, null, newSenior, null);
+        Person newChild = new Person("newGrandChild" + postfix, null, newSenior, null);
         newSenior.addGranschild(newChild);
         broker.store(newSenior);
         broker.commitTransaction();
@@ -163,22 +204,65 @@
         assertEquals(3, newSenior.getGrandchilds().size());
     }
 
-    private void setReferenceMetadata(Class clazz, String reference, boolean autoretrieve, int autoupdate, int autodelete, boolean useProxy)
+    /**
+     * same as above, but without clearing the cache
+     */
+    public void testCircularStoreUpdate_2()
     {
-        ClassDescriptor cld = broker.getClassDescriptor(clazz);
-        ObjectReferenceDescriptor ord = cld.getObjectReferenceDescriptorByName(reference);
-        if(ord == null)
-        {
-            ord = cld.getCollectionDescriptorByName(reference);
-        }
-        if(ord == null)
+        // prepare test
+        ojbChangeReferenceSetting(Person.class, "father", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "grandfather", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "childs", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+        ojbChangeReferenceSetting(Person.class, "grandchilds", true, CASCADE_OBJECT, CASCADE_OBJECT, false);
+
+        String postfix = "_testCircularStore_2_" + System.currentTimeMillis();
+        Person junior = createComplexFamily(postfix);
+        broker.beginTransaction();
+        broker.store(junior);
+        broker.commitTransaction();
+        Identity oidJunior = broker.serviceIdentity().buildIdentity(junior);
+        Identity oidSenior = broker.serviceIdentity().buildIdentity(junior.getFather());
+
+        Criteria crit = new Criteria();
+        crit.addLike("name", "jeffChild_%" + postfix);
+        Query q = QueryFactory.newQuery(Person.class, crit);
+
+        Person newJunior = (Person) broker.getObjectByIdentity(oidJunior);
+        assertNotNull(newJunior);
+        assertNotNull(newJunior.getFather());
+        assertNotNull(newJunior.getChilds());
+        assertEquals(2, newJunior.getChilds().size());
+
+        Person newSenior = (Person) broker.getObjectByIdentity(oidSenior);
+        assertNotNull(newSenior);
+        assertNotNull(newSenior.getChilds());
+        assertEquals(1, newSenior.getChilds().size());
+        assertNotNull(newSenior.getGrandchilds());
+        assertEquals(2, newSenior.getGrandchilds().size());
+
+        Collection result = broker.getCollectionByQuery(q);
+        assertEquals(2, result.size());
+        for(Iterator iterator = result.iterator(); iterator.hasNext();)
         {
-            throw new MetadataException("Reference with name '" + reference + "' does not exist in " + clazz.getName());
+            Person p = (Person) iterator.next();
+            assertNotNull(p.getFather());
+            assertEquals("jeffJunior" + postfix, p.getFather().getName());
+            assertNotNull(p.getGrandfather());
+            assertEquals("jeffSenior" + postfix, p.getGrandfather().getName());
         }
-        ord.setCascadeRetrieve(autoretrieve);
-        ord.setCascadingStore(autoupdate);
-        ord.setCascadingDelete(autodelete);
-        ord.setLazy(useProxy);
+
+        broker.beginTransaction();
+        Person newChild = new Person("newGrandChild" + postfix, null, newSenior, null);
+        newSenior.addGranschild(newChild);
+        broker.store(newSenior);
+        broker.commitTransaction();
+
+        newSenior = (Person) broker.getObjectByIdentity(oidSenior);
+        assertNotNull(newSenior);
+        assertNotNull(newSenior.getChilds());
+        assertEquals(1, newSenior.getChilds().size());
+        assertNotNull(newSenior.getGrandchilds());
+        assertEquals(3, newSenior.getGrandchilds().size());
     }
 
     /**

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/cloneable/CloneableGroup.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/cloneable/CloneableGroup.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/cloneable/CloneableGroup.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/cloneable/CloneableGroup.java Sat Jul 15 07:38:14 2006
@@ -21,18 +21,25 @@
     return super.clone();
   }
 
-  /**
-   * mapped to column KategorieName
-   */
-  public final String getName()
-  {
-    return groupName;
-  }
+  public Integer getId()
+    {
+        return id;
+    }
 
-  public final void setName(String name)
-  {
-    this.groupName = name;
-  }
+    public void setId(Integer id)
+    {
+        this.id = id;
+    }
+
+    public String getGroupName()
+    {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName)
+    {
+        this.groupName = groupName;
+    }
 
   public String toString()
   {

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/MetadataMultithreadedTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/MetadataMultithreadedTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/MetadataMultithreadedTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/MetadataMultithreadedTest.java Sat Jul 15 07:38:14 2006
@@ -1,25 +1,23 @@
 package org.apache.ojb.broker.metadata;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.commons.lang.ClassUtils;
+import org.apache.ojb.broker.Article;
 import org.apache.ojb.broker.OJBRuntimeException;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceConfiguration;
 import org.apache.ojb.broker.Person;
-import org.apache.ojb.broker.Project;
-import org.apache.ojb.broker.Role;
-import org.apache.ojb.broker.Article;
 import org.apache.ojb.broker.ProductGroupWithCollectionProxy;
 import org.apache.ojb.broker.accesslayer.OJBIterator;
 import org.apache.ojb.broker.query.Query;
-import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
 import org.apache.ojb.broker.sequence.Repository;
 import org.apache.ojb.broker.util.ClassHelper;
+import org.apache.ojb.broker.util.logging.Logger;
+import org.apache.ojb.broker.util.logging.LoggerFactory;
 import org.apache.ojb.junit.JUnitExtensions;
 
 /**
@@ -32,10 +30,17 @@
     // we change table name in test for target class
     private String newTestObjectString = "SM_TAB_MAX_AA";
     private Class targetTestClass = Repository.SMMaxA.class;
+    int loops = 7;
+    int threads = 4;
+    // need min 80% free memory after test campared with
+    // beginning, else test fails
+    int minimalFreeMemAfterTest = 80;
 
     private String oldTestObjectString;
     DescriptorRepository defaultRepository;
 
+    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
     public MetadataMultithreadedTest(String s)
     {
         super(s);
@@ -105,9 +110,11 @@
             // supported
             Throwable expectedThrowable = null;
             try {
+                //System.err.println("------ The following exception is part of the tests...");
                 groupIter.next();
             } catch (Throwable t) {
                 expectedThrowable = t;
+                //System.err.println("------");
             }
             assertNotNull("Should get metadata exception from proxy", expectedThrowable);
             groupIter.releaseDbResources();
@@ -189,12 +196,6 @@
 
     public void testRuntimeMetadataChanges() throws Exception
     {
-        int loops = 7;
-        int threads = 8;
-        // need min 80% free memory after test campared with
-        // beginning, else test fails
-        int minimalFreeMemAfterTest = 80;
-
         PersistenceBroker broker = null;
         try
         {
@@ -239,15 +240,21 @@
                     // run test classes
                     runTestCaseRunnables(tct);
                     ++count;
-                    System.out.println("Free/total Memory after loop " + count + ":          "
+                    if (logger.isDebugEnabled())
+                    {
+                        logger.debug("Free/total Memory after loop " + count + ":          "
                             + convertToMB(Runtime.getRuntime().freeMemory())
                             + "/" + convertToMB(getTotalMemory()) + "MB");
                 }
+                }
                 period = System.currentTimeMillis() - period;
-                System.out.println(ClassUtils.getShortClassName(MetadataMultithreadedTest.class) + " take: "
+                if (logger.isDebugEnabled())
+                {
+                    logger.debug(ClassUtils.getShortClassName(MetadataMultithreadedTest.class) + " take: "
                         + period + " ms for " + loops + " loops, creating each with " + threads + " threads");
-                System.out.println("Free/total Memory before test:          "
+                    logger.debug("Free/total Memory before test:          "
                         + convertToMB(memory) + "/" + convertToMB(totalMemory) + "MB");
+                }
                 Runtime.getRuntime().gc();
                 Thread.sleep(200);
                 Runtime.getRuntime().gc();
@@ -255,10 +262,13 @@
 
                 memoryUseBeforeTest = convertToMB(memory);
                 memoryUseAfterTest = convertToMB(Runtime.getRuntime().freeMemory());
-                System.out.println("Free/total Memory after test and gc:   "
+                if (logger.isDebugEnabled())
+                {
+                    logger.debug("Free/total Memory after test and gc:   "
                         + memoryUseAfterTest
                         + "/" + convertToMB(getTotalMemory()) + "MB");
-                System.out.println("Do cleanup now ...");
+                    logger.debug("Do cleanup now ...");
+                }
             }
             finally
             {
@@ -298,8 +308,8 @@
     class ThreadedUsingBroker extends JUnitExtensions.MultiThreadedTestCase.TestCaseRunnable
     {
         private PersistenceConfiguration persistenceConf;
-        private int loops;
-        private String title = "ThreadedUsingBroker_" + System.currentTimeMillis();
+        int loops;
+        String title = "ThreadedUsingBroker_" + System.currentTimeMillis();
 
         public ThreadedUsingBroker(PersistenceConfiguration persistenceConf, int loops)
         {
@@ -347,48 +357,11 @@
                     Query query = QueryFactory.newQuery(Person.class, null, true);
                     broker.getCollectionByQuery(query);
                     // store target object
-                    /*
-                    store some complex objects to check if references to
-                    metadata classes are cached
-                    */
-                    Project project = new Project();
-                    project.setTitle(title);
-
-                    Person p1 = new Person();
-                    p1.setFirstname(title);
-                    List l1 = new ArrayList();
-                    l1.add(project);
-                    p1.setProjects(l1);
-
-                    Person p2 = new Person();
-                    p2.setFirstname(title);
-                    List l2 = new ArrayList();
-                    l2.add(project);
-                    p2.setProjects(l2);
-
-                    Role r1 = new Role();
-                    r1.setPerson(p1);
-                    r1.setRoleName(title);
-                    r1.setProject(project);
-                    List roles1 = new ArrayList();
-                    roles1.add(r1);
-
-                    Role r2 = new Role();
-                    r2.setPerson(p2);
-                    r2.setRoleName(title);
-                    r2.setProject(project);
-                    List roles2 = new ArrayList();
-                    roles2.add(r2);
-
-                    p1.setRoles(roles1);
-                    p2.setRoles(roles2);
 
                     Object obj = ClassHelper.newInstance(targetTestClass);
 
                     broker.beginTransaction();
                     broker.store(obj);
-                    broker.store(p1);
-                    broker.store(p2);
                     broker.commitTransaction();
                     // delete target object
                     broker.beginTransaction();
@@ -421,7 +394,7 @@
     class GlobalUsingBroker extends JUnitExtensions.MultiThreadedTestCase.TestCaseRunnable
     {
         private PersistenceConfiguration persistenceConf;
-        private int loops;
+        int loops;
 
         public GlobalUsingBroker(PersistenceConfiguration persistenceConf, int loops)
         {

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/MetadataTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/MetadataTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/MetadataTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/MetadataTest.java Sat Jul 15 07:38:14 2006
@@ -1,5 +1,7 @@
 package org.apache.ojb.broker.metadata;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.util.Iterator;
 
 import org.apache.ojb.broker.Identity;
@@ -16,10 +18,9 @@
 import org.apache.ojb.broker.query.Query;
 import org.apache.ojb.broker.query.QueryFactory;
 import org.apache.ojb.broker.sequence.Repository;
-import org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl;
 import org.apache.ojb.broker.util.sequence.HighLowSequence;
+import org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl;
 import org.apache.ojb.junit.OJBTestCase;
-import org.apache.ojb.odmg.OJB;
 import org.odmg.Database;
 import org.odmg.Implementation;
 import org.odmg.OQLQuery;
@@ -34,6 +35,7 @@
     public static final String TEST_CLASS_DESCRIPTOR = "Test_ClassDescriptor.xml";
     public static final String TEST_CONNECTION_DESCRIPTOR = "Test_ConnectionDescriptor.xml";
     public static final String TEST_REPOSITORY = "Test_Repository.xml";
+    public static final String TEST_JAR = "Test_Repository_Renamed_DTD.xml";
 
     /**
      * A persistent object class
@@ -51,6 +53,11 @@
         super(name);
     }
 
+    public void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
     public void tearDown() throws Exception
     {
         try
@@ -63,6 +70,39 @@
         super.tearDown();
     }
 
+    public void testReadRepository_1() throws Exception
+    {
+        MetadataManager mm = ojb.getMetadataManager();
+
+        FileInputStream inst = new FileInputStream(new File(TEST_CLASS_DESCRIPTOR));
+        DescriptorRepository dr_1 = mm.readDescriptorRepository(inst);
+        inst.close();
+        assertNotNull(dr_1);
+
+        inst = new FileInputStream(new File(TEST_CONNECTION_DESCRIPTOR));
+        ConnectionRepository cr_1 = mm.readConnectionRepository(inst);
+        inst.close();
+        assertNotNull(cr_1);
+
+        dr_1 = mm.readDescriptorRepository(TEST_CLASS_DESCRIPTOR);
+        cr_1 = mm.readConnectionRepository(TEST_CONNECTION_DESCRIPTOR);
+        assertNotNull(dr_1);
+        assertNotNull(cr_1);
+    }
+
+    public void testReadRepository_2() throws Exception
+    {
+        MetadataManager mm = MetadataManager.getInstance();
+
+        DescriptorRepository dr_1 = mm.readDescriptorRepository(TEST_JAR);
+        assertNotNull(dr_1);
+        System.out.println("" + dr_1.toXML());
+
+        ConnectionRepository cr_1 = mm.readConnectionRepository(TEST_JAR);
+        assertNotNull(cr_1);
+        System.out.println("" + cr_1.toXML());
+    }
+
     public void testFindFirstConcreteClassDescriptor()
     {
         DescriptorRepository dr = ojb.getMetadataManager().getRepository();
@@ -70,8 +110,6 @@
         ClassDescriptor firstConcrete = dr.findFirstConcreteClass(cld);
         assertTrue(firstConcrete.isMappedToTable());
         assertFalse(firstConcrete.isAbstract());
-        firstConcrete = dr.findFirstConcreteClass(cld);
-        firstConcrete = dr.findFirstConcreteClass(cld);
     }
 
     public void testDescriptorRepository_1()
@@ -205,7 +243,7 @@
             broker.store(compChild);
             broker.commitTransaction();
 
-            Identity oid = new Identity(compChild, broker);
+            Identity oid = broker.serviceIdentity().buildIdentity(compChild);
             broker.clearCache();
             compChild = (ObjectRepository.Component) broker.getObjectByIdentity(oid);
 

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/PersistentFieldPerfTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/PersistentFieldPerfTest.java?rev=422236&r1=422235&r2=422236&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/PersistentFieldPerfTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/metadata/PersistentFieldPerfTest.java Sat Jul 15 07:38:14 2006
@@ -8,6 +8,7 @@
 import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl;
 import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImpl;
 import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldPrivilegedImpl;
+import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldCGLibImpl;
 import org.apache.ojb.broker.util.ClassHelper;
 import org.apache.ojb.junit.OJBTestCase;
 
@@ -52,6 +53,7 @@
 
     Class[] persistentFieldClasses = new Class[]{
         PersistentFieldDirectImpl.class
+        , PersistentFieldCGLibImpl.class
         , PersistentFieldIntrospectorImpl.class
         , PersistentFieldPrivilegedImpl.class
         , PersistentFieldAutoProxyImpl.class};



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message