You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2005/12/16 03:16:43 UTC
cvs commit: db-ojb/src/test/org/apache/ojb repository_junit_reference.xml
arminw 2005/12/15 18:16:43
Modified: src/schema Tag: OJB_1_0_RELEASE ojbtest-schema.xml
src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
CollectionTest.java
src/test/org/apache/ojb Tag: OJB_1_0_RELEASE
repository_junit_reference.xml
Log:
add test for OJB-82
Revision Changes Path
No revision
No revision
1.80.2.31 +8 -1 db-ojb/src/schema/ojbtest-schema.xml
Index: ojbtest-schema.xml
===================================================================
RCS file: /home/cvs/db-ojb/src/schema/ojbtest-schema.xml,v
retrieving revision 1.80.2.30
retrieving revision 1.80.2.31
diff -u -r1.80.2.30 -r1.80.2.31
--- ojbtest-schema.xml 4 Dec 2005 02:15:47 -0000 1.80.2.30
+++ ojbtest-schema.xml 16 Dec 2005 02:16:41 -0000 1.80.2.31
@@ -1242,6 +1242,13 @@
<column name="BOOKSHELF_FK" required="true" primaryKey="true" type="INTEGER"/>
</table>
+ <table name="COL_CANDIES">
+ <column name="PK" required="true" primaryKey="true" type="INTEGER"/>
+ <column name="NAME" type="VARCHAR" size="150"/>
+ <column name="INGREDIENTS" type="VARCHAR" size="250"/>
+ <column name="BOOKSHELF_FK" required="true" primaryKey="true" type="INTEGER"/>
+ </table>
+
<!-- =================================================== -->
<!-- PB nested fields test -->
No revision
No revision
1.11.2.6 +107 -1 db-ojb/src/test/org/apache/ojb/broker/CollectionTest.java
Index: CollectionTest.java
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/CollectionTest.java,v
retrieving revision 1.11.2.5
retrieving revision 1.11.2.6
diff -u -r1.11.2.5 -r1.11.2.6
--- CollectionTest.java 4 Dec 2005 02:15:47 -0000 1.11.2.5
+++ CollectionTest.java 16 Dec 2005 02:16:42 -0000 1.11.2.6
@@ -80,6 +80,49 @@
junit.textui.TestRunner.main(arr);
}
+ /**
+ * test for OJB-82
+ */
+ public void testUsingExtentWhichIsNotInheritedFromBaseClass() throws Exception
+ {
+ String prefix = "testUsingExtentWhichIsNotInheritedFromBaseClass_" + System.currentTimeMillis();
+
+ ojbChangeReferenceSetting(BookShelf.class, "items", true, OBJECT, OBJECT, false);
+ ojbChangeReferenceSetting(DVD.class, "shelf", true, NONE, NONE, false);
+ ojbChangeReferenceSetting(Book.class, "shelf", true, NONE, NONE, false);
+ ojbChangeReferenceSetting(Candie.class, "shelf", true, NONE, NONE, false);
+
+ BookShelf bookShelf = new BookShelf(prefix);
+ BookShelfItem dvd = new DVD(prefix+ "_dvd", bookShelf);
+ BookShelfItem book = new Book(prefix + "_book", bookShelf);
+ Candie candie = new Candie(prefix + "_book", bookShelf);
+ List items = new ArrayList();
+ items.add(dvd);
+ items.add(book);
+ items.add(candie);
+ bookShelf.setItems(items);
+
+ broker.beginTransaction();
+ broker.store(bookShelf);
+ broker.commitTransaction();
+
+ broker.clearCache();
+ BookShelf loadedCopy = (BookShelf) broker.getObjectByIdentity(
+ broker.serviceIdentity().buildIdentity(BookShelf.class, bookShelf.getPk()));
+ assertNotNull(loadedCopy);
+ assertNotNull(loadedCopy.getItems());
+ assertEquals(3, loadedCopy.getItems().size());
+
+ broker.beginTransaction();
+ broker.clearCache();
+ Criteria criteria = new Criteria();
+ criteria.addLike("name", prefix + "%");
+ Query q = new QueryByCriteria(BookShelfItem.class, criteria);
+ Collection result = broker.getCollectionByQuery(q);
+ assertNotNull(result);
+ assertEquals(3, result.size());
+ }
+
public void testMoveProxyCollectionFromOneToAnother() throws Exception
{
String prefix = "testMoveProxyCollectionFromOneToAnother_" + System.currentTimeMillis();
@@ -1652,4 +1695,67 @@
super(name, shelf);
}
}
+
+ public static class Candie
+ {
+ private Integer pk;
+ private String name;
+ private String ingredients;
+ private BookShelfIF shelf;
+
+ public Candie()
+ {
+ }
+
+ public Candie(BookShelfIF shelf)
+ {
+ this.shelf = shelf;
+ }
+
+ protected Candie(String name, BookShelfIF shelf)
+ {
+ this.name = name;
+ this.shelf = shelf;
+ }
+
+ public Integer getPk()
+ {
+ return pk;
+ }
+
+ public void setPk(Integer pk)
+ {
+ this.pk = pk;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getIngredients()
+ {
+ return ingredients;
+ }
+
+ public void setIngredients(String ingredients)
+ {
+ this.ingredients = ingredients;
+ }
+
+ public BookShelfIF getShelf()
+ {
+ return shelf;
+ }
+
+ public void setShelf(BookShelf shelf)
+ {
+ this.shelf = shelf;
+ }
+ }
}
No revision
No revision
1.17.2.9 +47 -1 db-ojb/src/test/org/apache/ojb/repository_junit_reference.xml
Index: repository_junit_reference.xml
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit_reference.xml,v
retrieving revision 1.17.2.8
retrieving revision 1.17.2.9
diff -u -r1.17.2.8 -r1.17.2.9
--- repository_junit_reference.xml 4 Dec 2005 02:15:52 -0000 1.17.2.8
+++ repository_junit_reference.xml 16 Dec 2005 02:16:42 -0000 1.17.2.9
@@ -1102,6 +1102,9 @@
<class-descriptor class="org.apache.ojb.broker.CollectionTest$BookShelfItem">
<extent-class class-ref="org.apache.ojb.broker.CollectionTest$Book"/>
<extent-class class-ref="org.apache.ojb.broker.CollectionTest$DVD"/>
+ <!-- This class isn't a subclass of Book or DVD or a implementation of
+ BookShelfItem, anyway it's possible to declare it as extent (but not recommended) -->
+ <extent-class class-ref="org.apache.ojb.broker.CollectionTest$Candie"/>
</class-descriptor>
<class-descriptor
@@ -1204,6 +1207,49 @@
</class-descriptor>
+ <class-descriptor
+ class="org.apache.ojb.broker.CollectionTest$Candie"
+ table="COL_CANDIES"
+ >
+ <field-descriptor
+ name="pk"
+ column="PK"
+ jdbc-type="INTEGER"
+ primarykey="true"
+ autoincrement="true"
+ />
+
+ <field-descriptor
+ name="name"
+ column="NAME"
+ jdbc-type="VARCHAR"
+ />
+
+ <field-descriptor
+ name="ingredients"
+ column="INGREDIENTS"
+ jdbc-type="VARCHAR"
+ />
+
+ <field-descriptor
+ name="shelfFk"
+ column="BOOKSHELF_FK"
+ jdbc-type="INTEGER"
+ access="anonymous"
+ />
+ <reference-descriptor
+ name="shelf"
+ class-ref="org.apache.ojb.broker.CollectionTest$BookShelf"
+ auto-retrieve="true"
+ auto-update="false"
+ auto-delete="false"
+ proxy="true"
+ >
+ <foreignkey field-ref="shelfFk"/>
+ </reference-descriptor>
+
+ </class-descriptor>
+
<!-- ************************************************* -->
<!-- broker.MultithreadedReadTest -->
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org