db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r378882 - in /db/ojb/trunk/src: schema/ test/org/apache/ojb/ test/org/apache/ojb/broker/
Date Sun, 19 Feb 2006 11:51:30 GMT
Author: tomdz
Date: Sun Feb 19 03:51:27 2006
New Revision: 378882

URL: http://svn.apache.org/viewcvs?rev=378882&view=rev
Log:
Added unit test for proxy handling for interface inheritance heirarchies

Added:
    db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1Impl.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2Impl.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/Owner.java
Modified:
    db/ojb/trunk/src/schema/ojbtest-data-new.xml
    db/ojb/trunk/src/schema/ojbtest-data.dtd
    db/ojb/trunk/src/schema/ojbtest-data.xml
    db/ojb/trunk/src/schema/ojbtest-schema.xml
    db/ojb/trunk/src/test/org/apache/ojb/broker/ProxyExamples.java
    db/ojb/trunk/src/test/org/apache/ojb/repository_junit.xml

Modified: db/ojb/trunk/src/schema/ojbtest-data-new.xml
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/schema/ojbtest-data-new.xml?rev=378882&r1=378881&r2=378882&view=diff
==============================================================================
--- db/ojb/trunk/src/schema/ojbtest-data-new.xml (original)
+++ db/ojb/trunk/src/schema/ojbtest-data-new.xml Sun Feb 19 03:51:27 2006
@@ -200,4 +200,9 @@
 
    	<InitializableObject id="1"/>
     <InitializableObject id="2"/>
+
+    <Ownable1 id="1"/>
+    <Ownable2 id="2"/>
+    <Owner id="1" ownedid="2"/>
+    <Owner id="2" ownedid="1"/>
 </dataset>

Modified: db/ojb/trunk/src/schema/ojbtest-data.dtd
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/schema/ojbtest-data.dtd?rev=378882&r1=378881&r2=378882&view=diff
==============================================================================
--- db/ojb/trunk/src/schema/ojbtest-data.dtd (original)
+++ db/ojb/trunk/src/schema/ojbtest-data.dtd Sun Feb 19 03:51:27 2006
@@ -177,7 +177,10 @@
     PATable|
     PBTable|
     PCTable|
-    PDTable)*>
+    PDTable|
+    Owner|
+    Ownable1|
+    Ownable2)*>
 <!ATTLIST dataset
     name CDATA #REQUIRED
 >
@@ -1362,3 +1365,18 @@
     DAttrib CDATA #IMPLIED
 >
 
+<!ELEMENT Owner EMPTY>
+<!ATTLIST Owner
+    Id CDATA #REQUIRED
+    OwnedId CDATA #IMPLIED
+>
+
+<!ELEMENT Ownable1 EMPTY>
+<!ATTLIST Ownable1
+    Id CDATA #REQUIRED
+>
+
+<!ELEMENT Ownable2 EMPTY>
+<!ATTLIST Ownable2
+    Id CDATA #REQUIRED
+>

Modified: db/ojb/trunk/src/schema/ojbtest-data.xml
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/schema/ojbtest-data.xml?rev=378882&r1=378881&r2=378882&view=diff
==============================================================================
--- db/ojb/trunk/src/schema/ojbtest-data.xml (original)
+++ db/ojb/trunk/src/schema/ojbtest-data.xml Sun Feb 19 03:51:27 2006
@@ -204,5 +204,10 @@
     <ContentQualifier ContentId="11" QualifierId="31"/>
 
     <InitializableObject Id="1"/>
-	<InitializableObject Id="2"/>
+    <InitializableObject Id="2"/>
+
+    <Ownable1 Id="1"/>
+    <Ownable2 Id="2"/>
+    <Owner Id="1" OwnedId="2"/>
+    <Owner Id="2" OwnedId="1"/>
 </dataset>

Modified: db/ojb/trunk/src/schema/ojbtest-schema.xml
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/schema/ojbtest-schema.xml?rev=378882&r1=378881&r2=378882&view=diff
==============================================================================
--- db/ojb/trunk/src/schema/ojbtest-schema.xml (original)
+++ db/ojb/trunk/src/schema/ojbtest-schema.xml Sun Feb 19 03:51:27 2006
@@ -1879,4 +1879,14 @@
     </foreign-key>
   </table>
 
+  <table name="Owner">
+    <column name="id" required="true" primaryKey="true" type="INTEGER"/>
+    <column name="ownedid" javaName="ownedId" type="INTEGER"/>
+  </table>
+  <table name="Ownable1">
+    <column name="id" required="true" primaryKey="true" type="INTEGER"/>
+  </table>
+  <table name="Ownable2">
+    <column name="id" required="true" primaryKey="true" type="INTEGER"/>
+  </table>
 </database>

Added: db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable.java?rev=378882&view=auto
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable.java (added)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable.java Sun Feb 19 03:51:27 2006
@@ -0,0 +1,9 @@
+package org.apache.ojb.broker;
+
+import java.io.Serializable;
+
+/**
+ * Interface for testing proxies with interface-hierarchies.
+ */
+public interface Ownable extends Serializable
+{}

Added: db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1.java?rev=378882&view=auto
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1.java (added)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1.java Sun Feb 19 03:51:27 2006
@@ -0,0 +1,7 @@
+package org.apache.ojb.broker;
+
+/**
+ * Interface for testing proxies with interface-hierarchies.
+ */
+public interface Ownable1 extends Ownable
+{}

Added: db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1Impl.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1Impl.java?rev=378882&view=auto
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1Impl.java (added)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable1Impl.java Sun Feb 19 03:51:27 2006
@@ -0,0 +1,9 @@
+package org.apache.ojb.broker;
+
+/**
+ * Class for testing proxies with interface-hierarchies.
+ */
+public class Ownable1Impl implements Ownable1
+{
+    private Integer id;
+}

Added: db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2.java?rev=378882&view=auto
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2.java (added)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2.java Sun Feb 19 03:51:27 2006
@@ -0,0 +1,7 @@
+package org.apache.ojb.broker;
+
+/**
+ * Interface for testing proxies with interface-hierarchies.
+ */
+public interface Ownable2 extends Ownable
+{}

Added: db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2Impl.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2Impl.java?rev=378882&view=auto
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2Impl.java (added)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/Ownable2Impl.java Sun Feb 19 03:51:27 2006
@@ -0,0 +1,9 @@
+package org.apache.ojb.broker;
+
+/**
+ * Class for testing proxies with interface-hierarchies.
+ */
+public class Ownable2Impl implements Ownable2
+{
+    private Integer id;
+}

Added: db/ojb/trunk/src/test/org/apache/ojb/broker/Owner.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/test/org/apache/ojb/broker/Owner.java?rev=378882&view=auto
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/Owner.java (added)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/Owner.java Sun Feb 19 03:51:27 2006
@@ -0,0 +1,18 @@
+package org.apache.ojb.broker;
+
+import java.io.Serializable;
+
+/**
+ * Class for testing proxies with interface-hierarchies.
+ */
+public class Owner implements Serializable
+{
+    private Integer id;
+    private Integer ownedId;
+    private Ownable owned;
+
+    public Ownable getOwned()
+    {
+        return owned;
+    }
+}

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/ProxyExamples.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/test/org/apache/ojb/broker/ProxyExamples.java?rev=378882&r1=378881&r2=378882&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/ProxyExamples.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/ProxyExamples.java Sun Feb 19 03:51:27 2006
@@ -1,6 +1,5 @@
 package org.apache.ojb.broker;
 
-import java.lang.reflect.Proxy;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Vector;
@@ -346,4 +345,23 @@
         }
     }
 
+    public void testReferenceProxyWithInheritance()
+    {
+        Query      query = QueryFactory.newQuery(Owner.class, new Criteria());
+        Collection objs  = broker.getCollectionByQuery(query);
+
+        assertEquals(2,
+                     objs.size());
+
+        Iterator it     = objs.iterator();
+        Ownable  owned1 = ((Owner)it.next()).getOwned();
+        Ownable  owned2 = ((Owner)it.next()).getOwned();
+
+        assertTrue(ojb.getProxyFactory().isProxy(owned1));
+        assertTrue(ojb.getProxyFactory().isProxy(owned2));
+        // This should be true according the docs of class Proxy and because
+        // the concrete classes are Onwable2Impl/Onwable1Impl
+        assertTrue(owned1 instanceof Ownable2);
+        assertTrue(owned2 instanceof Ownable1);
+    }
 }

Modified: db/ojb/trunk/src/test/org/apache/ojb/repository_junit.xml
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/test/org/apache/ojb/repository_junit.xml?rev=378882&r1=378881&r2=378882&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/repository_junit.xml (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/repository_junit.xml Sun Feb 19 03:51:27 2006
@@ -3378,4 +3378,70 @@
              jdbc-type="VARCHAR"
         />
     </class-descriptor>
+
+    <class-descriptor
+       class="org.apache.ojb.broker.Owner"
+       table="Owner"
+    >
+       <field-descriptor
+           name="id"
+           column="id"
+           jdbc-type="INTEGER"
+           primarykey="true"
+       >
+       </field-descriptor>
+       <field-descriptor
+           name="ownedId"
+           column="ownedid"
+           jdbc-type="INTEGER"
+       >
+       </field-descriptor>
+       <reference-descriptor
+           name="owned"
+           class-ref="org.apache.ojb.broker.Ownable"
+           proxy="true"
+           auto-retrieve="true"
+           auto-update="link"
+           auto-delete="link"
+       >
+           <foreignkey field-ref="ownedId"/>
+       </reference-descriptor>
+    </class-descriptor>
+    <class-descriptor
+       class="org.apache.ojb.broker.Ownable"
+    >
+       <extent-class class-ref="org.apache.ojb.broker.Ownable1Impl"/>
+       <extent-class class-ref="org.apache.ojb.broker.Ownable2Impl"/>
+       <field-descriptor
+           name="id"
+           column="id"
+           jdbc-type="INTEGER"
+           primarykey="true"
+       >
+       </field-descriptor>
+    </class-descriptor>
+    <class-descriptor
+       class="org.apache.ojb.broker.Ownable1Impl"
+       table="Ownable1"
+    >
+       <field-descriptor
+           name="id"
+           column="id"
+           jdbc-type="INTEGER"
+           primarykey="true"
+       >
+       </field-descriptor>
+    </class-descriptor>
+    <class-descriptor
+       class="org.apache.ojb.broker.Ownable2Impl"
+       table="Ownable2"
+    >
+       <field-descriptor
+           name="id"
+           column="id"
+           jdbc-type="INTEGER"
+           primarykey="true"
+       >
+       </field-descriptor>
+    </class-descriptor>
 <!-- Mapping of classes used in junit tests and tutorials ends here -->



---------------------------------------------------------------------
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