brj 2005/05/06 11:30:18
Modified: src/schema Tag: OJB_1_0_RELEASE ojbtest-schema.xml
src/test/org/apache/ojb Tag: OJB_1_0_RELEASE
repository_junit_reference.xml
src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
M2NTest.java
Log:
extended testcase with a second m:n relationship from Movie to Actor
Revision Changes Path
No revision
No revision
1.80.2.20 +18 -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.19
retrieving revision 1.80.2.20
diff -u -r1.80.2.19 -r1.80.2.20
--- ojbtest-schema.xml 26 Apr 2005 01:51:00 -0000 1.80.2.19
+++ ojbtest-schema.xml 6 May 2005 18:30:17 -0000 1.80.2.20
@@ -934,6 +934,23 @@
</foreign-key>
</table>
+ <table name="M2N_TEST_ROLE_2">
+ <column name="ACTOR_ID" required="true" primaryKey="true"
type="INTEGER"/>
+ <column name="ACTOR_ID2" required="true" primaryKey="true"
type="INTEGER"/>
+ <column name="MOVIE_ID_INT" required="true" primaryKey="true"
type="INTEGER"/>
+ <column name="MOVIE_ID2_INT" required="true" primaryKey="true"
type="INTEGER"/>
+ <column name="MOVIE_ID_STR" required="true" primaryKey="true"
type="VARCHAR" size="150"/>
+ <foreign-key foreignTable="M2N_TEST_ACTOR">
+ <reference local="ACTOR_ID" foreign="OBJ_ID"/>
+ <reference local="ACTOR_ID2" foreign="OBJ_ID2"/>
+ </foreign-key>
+ <foreign-key foreignTable="M2N_TEST_MOVIE">
+ <reference local="MOVIE_ID_INT" foreign="OBJ_ID_INT"/>
+ <reference local="MOVIE_ID2_INT" foreign="OBJ_ID2_INT"/>
+ <reference local="MOVIE_ID_STR" foreign="OBJ_ID_STR"/>
+ </foreign-key>
+ </table>
+
<!-- =================================================== -->
<!-- M2NGraph test table -->
<!-- =================================================== -->
No revision
No revision
1.17.2.4 +17 -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.3
retrieving revision 1.17.2.4
diff -u -r1.17.2.3 -r1.17.2.4
--- repository_junit_reference.xml 10 Mar 2005 13:11:17 -0000 1.17.2.3
+++ repository_junit_reference.xml 6 May 2005 18:30:17 -0000 1.17.2.4
@@ -1504,6 +1504,22 @@
<fk-pointing-to-element-class column="ACTOR_ID"/>
<fk-pointing-to-element-class column="ACTOR_ID2"/>
</collection-descriptor>
+
+ <collection-descriptor
+ name="actors2"
+ element-class-ref="org.apache.ojb.broker.M2NTest$Actor"
+ auto-retrieve="false"
+ auto-update="false"
+ auto-delete="false"
+ indirection-table="M2N_TEST_ROLE_2"
+ >
+ <fk-pointing-to-this-class column="MOVIE_ID_INT"/>
+ <fk-pointing-to-this-class column="MOVIE_ID2_INT"/>
+ <fk-pointing-to-this-class column="MOVIE_ID_STR"/>
+ <fk-pointing-to-element-class column="ACTOR_ID"/>
+ <fk-pointing-to-element-class column="ACTOR_ID2"/>
+ </collection-descriptor>
+
</class-descriptor>
<class-descriptor
No revision
No revision
1.7.2.5 +47 -18 db-ojb/src/test/org/apache/ojb/broker/M2NTest.java
Index: M2NTest.java
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/M2NTest.java,v
retrieving revision 1.7.2.4
retrieving revision 1.7.2.5
diff -u -r1.7.2.4 -r1.7.2.5
--- M2NTest.java 27 Nov 2004 02:17:47 -0000 1.7.2.4
+++ M2NTest.java 6 May 2005 18:30:18 -0000 1.7.2.5
@@ -51,21 +51,24 @@
super.tearDown();
}
+ /**
+ * Test deprecated auto Settings
+ */
public void testAutoUpdateDeleteSettings()
{
changeActorCollectionDescriptorTo(false, false, false, false);
CollectionDescriptor ord = broker.getClassDescriptor(Actor.class)
.getCollectionDescriptorByName("movies");
- assertEquals(CollectionDescriptor.CASCADE_LINK,
ord.getCascadingStore());
- assertEquals(CollectionDescriptor.CASCADE_LINK,
ord.getCascadingDelete());
+ assertEquals(LINK, ord.getCascadingStore());
+ assertEquals(LINK, ord.getCascadingDelete());
assertEquals(false, ord.getCascadeStore());
assertEquals(false, ord.getCascadeDelete());
changeActorCollectionDescriptorTo(false, true, true, false);
ord = broker.getClassDescriptor(Actor.class)
.getCollectionDescriptorByName("movies");
- assertEquals(CollectionDescriptor.CASCADE_OBJECT,
ord.getCascadingStore());
- assertEquals(CollectionDescriptor.CASCADE_OBJECT,
ord.getCascadingDelete());
+ assertEquals(OBJECT, ord.getCascadingStore());
+ assertEquals(OBJECT, ord.getCascadingDelete());
assertEquals(true, ord.getCascadeStore());
assertEquals(true, ord.getCascadeDelete());
}
@@ -777,7 +780,7 @@
Query queryActor = queryActor(postfix);
Collection resultActor = broker.getCollectionByQuery(queryActor);
- assertEquals(3, resultActor.size());
+ assertEquals(3 + 2, resultActor.size());
Query queryRole = queryRole(null, movie);
Collection resultRole = broker.getCollectionByQuery(queryRole);
@@ -788,6 +791,7 @@
Movie readMovie = (Movie) broker.getObjectByIdentity(oid);
assertNotNull(readMovie);
assertEquals(3, readMovie.getActors().size());
+ assertEquals(2, readMovie.getActors2().size());
}
/**
@@ -858,7 +862,7 @@
Query queryActor = queryActor(postfix);
Collection resultActor = broker.getCollectionByQuery(queryActor);
- assertEquals(3, resultActor.size());
+ assertEquals(3 + 2, resultActor.size());
Query queryRole = queryRole(null, movie);
Collection resultRole = broker.getCollectionByQuery(queryRole);
@@ -880,7 +884,7 @@
assertEquals(1, resultMovie.size());
resultActor = broker.getCollectionByQuery(queryActor);
- assertEquals(3, resultActor.size());
+ assertEquals(3 + 2, resultActor.size());
resultRole = broker.getCollectionByQuery(queryRole);
assertEquals(0, resultRole.size());
@@ -1094,7 +1098,8 @@
}
/**
- * Returns 1 movie object with 3 actor objects
+ * Returns 1 movie object with 3 actor objects in actors-collection
+ * and 2 actor objects in actors2-collection
*/
Movie buildMovieWithActors(String postfixId)
{
@@ -1102,6 +1107,7 @@
"Dr. Strangelove or: How I Learned to Stop Worrying and Love
the Bomb " + postfixId,
"An insane general starts a process to nuclear holocaust
that a war" +
" room of politicians and generals frantically try to stop.
" + postfixId);
+
Actor a1 = new Actor("Peter Sellers " + postfixId);
Actor a2 = new Actor("George C. Scott " + postfixId);
Actor a3 = new Actor("Sterling Hayden " + postfixId);
@@ -1110,6 +1116,14 @@
list.add(a2);
list.add(a3);
m.setActors(list);
+
+ Actor a4 = new Actor("Actor 2 A " + postfixId);
+ Actor a5 = new Actor("Actor 2 B " + postfixId);
+ ArrayList list2 = new ArrayList();
+ list2.add(a4);
+ list2.add(a5);
+ m.setActors2(list2);
+
return m;
}
@@ -1218,11 +1232,16 @@
void changeMovieCollectionDescriptorTo(boolean autoRetrieve, int
autoUpdate, int autoDelete, boolean proxy)
{
ClassDescriptor cld = broker.getClassDescriptor(MovieImpl.class);
- CollectionDescriptor cod = (CollectionDescriptor)
cld.getCollectionDescriptors().get(0);
- cod.setLazy(proxy);
- cod.setCascadeRetrieve(autoRetrieve);
- cod.setCascadingStore(autoUpdate);
- cod.setCascadingDelete(autoDelete);
+ Iterator iter = cld.getCollectionDescriptors().iterator();
+
+ while (iter.hasNext())
+ {
+ CollectionDescriptor cod = (CollectionDescriptor) iter.next();
+ cod.setLazy(proxy);
+ cod.setCascadeRetrieve(autoRetrieve);
+ cod.setCascadingStore(autoUpdate);
+ cod.setCascadingDelete(autoDelete);
+ }
}
@@ -1362,9 +1381,11 @@
public static interface Movie
{
public Collection getActors();
-
public void setActors(Collection actors);
+ public Collection getActors2();
+ public void setActors2(Collection actors);
+
public Integer getIdInt2();
public Integer getIdInt();
@@ -1372,15 +1393,12 @@
public void setIdInt(Integer idInt);
public String getIdStr();
-
public void setIdStr(String idStr);
public String getTitle();
-
public void setTitle(String title);
public String getDescription();
-
public void setDescription(String description);
}
@@ -1392,6 +1410,7 @@
private String title;
private String description;
private Collection actors;
+ private Collection actors2;
public MovieImpl()
{
@@ -1414,6 +1433,16 @@
this.actors = actors;
}
+ public Collection getActors2()
+ {
+ return actors2;
+ }
+
+ public void setActors2(Collection actors)
+ {
+ this.actors2 = actors;
+ }
+
public Integer getIdInt()
{
return idInt;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]