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 2004/07/12 12:11:19 UTC
cvs commit: db-ojb/src/test/org/apache/ojb repository_junit_model.xml
arminw 2004/07/12 03:11:18
Modified: src/test/org/apache/ojb/broker AnonymousFieldsTest.java
ObjectRepository.java
src/test/org/apache/ojb repository_junit_model.xml
Log:
fix test cases
Revision Changes Path
1.15 +48 -48 db-ojb/src/test/org/apache/ojb/broker/AnonymousFieldsTest.java
Index: AnonymousFieldsTest.java
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AnonymousFieldsTest.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- AnonymousFieldsTest.java 13 May 2004 10:08:20 -0000 1.14
+++ AnonymousFieldsTest.java 12 Jul 2004 10:11:18 -0000 1.15
@@ -6,12 +6,12 @@
import org.apache.commons.lang.SerializationUtils;
import org.apache.ojb.broker.ObjectRepository.F1;
+import org.apache.ojb.broker.metadata.ClassDescriptor;
+import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
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.metadata.ClassDescriptor;
-import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
import org.apache.ojb.junit.PBTestCase;
/**
@@ -29,16 +29,16 @@
{
String prefix = "testHandlingOfMultipleAnonymousFieldPerObject_" + System.currentTimeMillis() + "_";
- ObjectRepository.Component parent = new ObjectRepository.Component();
+ ComponentIF parent = new ObjectRepository.Component();
parent.setName(prefix + "main_component");
- ObjectRepository.Component compSub1 = new ObjectRepository.Component();
+ ComponentIF compSub1 = new ObjectRepository.Component();
compSub1.setName(prefix + "sub_1");
- ObjectRepository.Component compSub2 = new ObjectRepository.Component();
+ ComponentIF compSub2 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_2");
- ObjectRepository.Component compSub3 = new ObjectRepository.Component();
+ ComponentIF compSub3 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_3");
ObjectRepository.Group group = new ObjectRepository.Group();
@@ -60,7 +60,7 @@
broker.clearCache();
Query query = QueryFactory.newQuery(parent);
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
Query groupQuery = QueryFactory.newQuery(group);
ObjectRepository.Group lookedUpGroup = (ObjectRepository.Group) broker.getObjectByQuery(groupQuery);
@@ -83,7 +83,7 @@
broker.clearCache();
query = QueryFactory.newQuery(parent);
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
assertNotNull(parent);
assertNull(parent.getGroup());
@@ -97,7 +97,7 @@
broker.delete(parent);
broker.commitTransaction();
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
assertNull(parent);
groupQuery = QueryFactory.newQuery(group);
@@ -113,16 +113,16 @@
{
String prefix = "testSerializedObjectsDelete_" + System.currentTimeMillis() + "_";
- ObjectRepository.Component comp = new ObjectRepository.Component();
+ ComponentIF comp = new ObjectRepository.Component();
comp.setName(prefix + "main_component");
- ObjectRepository.Component compSub1 = new ObjectRepository.Component();
+ ComponentIF compSub1 = new ObjectRepository.Component();
compSub1.setName(prefix + "sub_1");
- ObjectRepository.Component compSub2 = new ObjectRepository.Component();
+ ComponentIF compSub2 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_2");
- ObjectRepository.Component compSub3 = new ObjectRepository.Component();
+ ComponentIF compSub3 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_3");
ObjectRepository.Group group = new ObjectRepository.Group();
@@ -144,7 +144,7 @@
broker.clearCache();
Query query = QueryFactory.newQuery(comp);
- comp = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ comp = (ComponentIF) broker.getObjectByQuery(query);
Query groupQuery = QueryFactory.newQuery(group);
ObjectRepository.Group lookedUpGroup = (ObjectRepository.Group) broker.getObjectByQuery(groupQuery);
@@ -161,7 +161,7 @@
comp.setName(prefix + "updated_comp_name");
comp.setGroup(null);
- comp = (ObjectRepository.Component) SerializationUtils.deserialize(SerializationUtils.serialize(comp));
+ comp = (ComponentIF) SerializationUtils.deserialize(SerializationUtils.serialize(comp));
broker.beginTransaction();
broker.store(comp);
@@ -169,7 +169,7 @@
broker.clearCache();
query = QueryFactory.newQuery(comp);
- comp = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ comp = (ComponentIF) broker.getObjectByQuery(query);
assertNotNull(comp);
assertNull(comp.getGroup());
@@ -181,13 +181,13 @@
//*****************************************
// now we generate a deep copy
- comp = (ObjectRepository.Component) serializeDeserializeObject(comp);
+ comp = (ComponentIF) serializeDeserializeObject(comp);
broker.beginTransaction();
broker.delete(comp);
broker.commitTransaction();
//*****************************************
- comp = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ comp = (ComponentIF) broker.getObjectByQuery(query);
assertNull(comp);
groupQuery = QueryFactory.newQuery(group);
@@ -199,16 +199,16 @@
{
String prefix = "testSerializedObjectsUpdate_" + System.currentTimeMillis() + "_";
- ObjectRepository.Component parent = new ObjectRepository.Component();
+ ComponentIF parent = new ObjectRepository.Component();
parent.setName(prefix + "main_component");
- ObjectRepository.Component compSub1 = new ObjectRepository.Component();
+ ComponentIF compSub1 = new ObjectRepository.Component();
compSub1.setName(prefix + "sub_1");
- ObjectRepository.Component compSub2 = new ObjectRepository.Component();
+ ComponentIF compSub2 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_2");
- ObjectRepository.Component compSub3 = new ObjectRepository.Component();
+ ComponentIF compSub3 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_3");
ObjectRepository.Group group = new ObjectRepository.Group();
@@ -230,7 +230,7 @@
broker.clearCache();
Query query = QueryFactory.newQuery(parent);
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
Query groupQuery = QueryFactory.newQuery(group);
ObjectRepository.Group lookedUpGroup = (ObjectRepository.Group) broker.getObjectByQuery(groupQuery);
@@ -249,14 +249,14 @@
//**************************************************
// now we generate a deep copy
- parent = (ObjectRepository.Component) serializeDeserializeObject(parent);
+ parent = (ComponentIF) serializeDeserializeObject(parent);
broker.beginTransaction();
broker.store(parent);
broker.commitTransaction();
//**************************************************
query = QueryFactory.newQuery(parent);
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
assertNotNull(parent);
assertNull(parent.getGroup());
@@ -269,7 +269,7 @@
// same with cleared cache
broker.clearCache();
query = QueryFactory.newQuery(parent);
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
assertNotNull(parent);
assertNull(parent.getGroup());
@@ -283,7 +283,7 @@
broker.delete(parent);
broker.commitTransaction();
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
assertNull(parent);
groupQuery = QueryFactory.newQuery(group);
@@ -294,16 +294,16 @@
public void testSerializedObjectsRefresh()
{
String prefix = "testSerializedObjectsRefresh_" + System.currentTimeMillis() + "_";
- ObjectRepository.Component parent = new ObjectRepository.Component();
+ ComponentIF parent = new ObjectRepository.Component();
parent.setName(prefix + "main_component");
- ObjectRepository.Component compSub1 = new ObjectRepository.Component();
+ ComponentIF compSub1 = new ObjectRepository.Component();
compSub1.setName(prefix + "sub_1");
- ObjectRepository.Component compSub2 = new ObjectRepository.Component();
+ ComponentIF compSub2 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_2");
- ObjectRepository.Component compSub3 = new ObjectRepository.Component();
+ ComponentIF compSub3 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_3");
ObjectRepository.Group group = new ObjectRepository.Group();
@@ -325,7 +325,7 @@
broker.clearCache();
Query query = QueryFactory.newQuery(parent);
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
Query groupQuery = QueryFactory.newQuery(group);
ObjectRepository.Group lookedUpGroup = (ObjectRepository.Group) broker.getObjectByQuery(groupQuery);
@@ -336,7 +336,7 @@
assertNotNull(parent.getName());
assertEquals(3, parent.getChildComponents().size());
assertEquals(group.getName(), (parent.getGroup().getName()));
- ObjectRepository.Component aChild = (ObjectRepository.Component) parent.getChildComponents().iterator().next();
+ ComponentIF aChild = (ComponentIF) parent.getChildComponents().iterator().next();
assertNotNull(aChild);
assertNotNull(aChild.getParentComponent());
assertEquals(parent, aChild.getParentComponent());
@@ -345,7 +345,7 @@
//*************************************
assertNotNull(parent);
assertNotNull(parent.getGroup());
- parent = (ObjectRepository.Component) serializeDeserializeObject(parent);
+ parent = (ComponentIF) serializeDeserializeObject(parent);
broker.retrieveAllReferences(parent);
assertNotNull(parent);
/*
@@ -358,7 +358,7 @@
assertNotNull(parent.getChildComponents());
assertNotNull(parent.getName());
assertEquals(3, parent.getChildComponents().size());
- aChild = (ObjectRepository.Component) parent.getChildComponents().iterator().next();
+ aChild = (ComponentIF) parent.getChildComponents().iterator().next();
assertNotNull(aChild);
assertNotNull(aChild.getParentComponent());
assertEquals(parent, aChild.getParentComponent());
@@ -370,7 +370,7 @@
// now nothing should happen, because we don't make any changes
broker.clearCache();
query = QueryFactory.newQuery(parent);
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
groupQuery = QueryFactory.newQuery(group);
lookedUpGroup = (ObjectRepository.Group) broker.getObjectByQuery(groupQuery);
assertNotNull(parent);
@@ -379,7 +379,7 @@
assertNotNull(parent.getName());
assertEquals(3, parent.getChildComponents().size());
assertEquals(group.getName(), (parent.getGroup().getName()));
- aChild = (ObjectRepository.Component) parent.getChildComponents().iterator().next();
+ aChild = (ComponentIF) parent.getChildComponents().iterator().next();
assertNotNull(aChild);
assertNotNull(aChild.getParentComponent());
assertEquals(parent, aChild.getParentComponent());
@@ -396,16 +396,16 @@
try
{
ord.setLazy(true);
- ObjectRepository.Component parent = new ObjectRepository.Component();
+ ComponentIF parent = new ObjectRepository.Component();
parent.setName(prefix + "main_component");
- ObjectRepository.Component compSub1 = new ObjectRepository.Component();
+ ComponentIF compSub1 = new ObjectRepository.Component();
compSub1.setName(prefix + "sub_1");
- ObjectRepository.Component compSub2 = new ObjectRepository.Component();
+ ComponentIF compSub2 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_2");
- ObjectRepository.Component compSub3 = new ObjectRepository.Component();
+ ComponentIF compSub3 = new ObjectRepository.Component();
compSub2.setName(prefix + "sub_3");
ObjectRepository.Group group = new ObjectRepository.Group();
@@ -427,7 +427,7 @@
broker.clearCache();
Query query = QueryFactory.newQuery(parent);
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
Query groupQuery = QueryFactory.newQuery(group);
ObjectRepository.Group lookedUpGroup = (ObjectRepository.Group) broker.getObjectByQuery(groupQuery);
@@ -438,7 +438,7 @@
assertNotNull(parent.getName());
assertEquals(3, parent.getChildComponents().size());
assertEquals(group.getName(), (parent.getGroup().getName()));
- ObjectRepository.Component aChild = (ObjectRepository.Component) parent.getChildComponents().iterator().next();
+ ComponentIF aChild = (ComponentIF) parent.getChildComponents().iterator().next();
assertNotNull(aChild);
assertNotNull(aChild.getParentComponent());
assertEquals(parent, aChild.getParentComponent());
@@ -447,7 +447,7 @@
//*************************************
assertNotNull(parent);
assertNotNull(parent.getGroup());
- parent = (ObjectRepository.Component) serializeDeserializeObject(parent);
+ parent = (ComponentIF) serializeDeserializeObject(parent);
broker.retrieveAllReferences(parent);
assertNotNull(parent);
/*
@@ -460,7 +460,7 @@
assertNotNull(parent.getChildComponents());
assertNotNull(parent.getName());
assertEquals(3, parent.getChildComponents().size());
- aChild = (ObjectRepository.Component) parent.getChildComponents().iterator().next();
+ aChild = (ComponentIF) parent.getChildComponents().iterator().next();
assertNotNull(aChild);
assertNotNull(aChild.getParentComponent());
assertEquals(parent, aChild.getParentComponent());
@@ -472,7 +472,7 @@
// now nothing should happen, because we don't make any changes
broker.clearCache();
query = QueryFactory.newQuery(parent);
- parent = (ObjectRepository.Component) broker.getObjectByQuery(query);
+ parent = (ComponentIF) broker.getObjectByQuery(query);
groupQuery = QueryFactory.newQuery(group);
lookedUpGroup = (ObjectRepository.Group) broker.getObjectByQuery(groupQuery);
assertNotNull(parent);
@@ -481,7 +481,7 @@
assertNotNull(parent.getName());
assertEquals(3, parent.getChildComponents().size());
assertEquals(group.getName(), (parent.getGroup().getName()));
- aChild = (ObjectRepository.Component) parent.getChildComponents().iterator().next();
+ aChild = (ComponentIF) parent.getChildComponents().iterator().next();
assertNotNull(aChild);
assertNotNull(aChild.getParentComponent());
assertEquals(parent, aChild.getParentComponent());
@@ -766,7 +766,7 @@
// Utiltity methods.
private Object serializeDeserializeObject(Serializable obj)
{
- return (ObjectRepository.Component) SerializationUtils.deserialize(SerializationUtils.serialize(obj));
+ return (ComponentIF) SerializationUtils.deserialize(SerializationUtils.serialize(obj));
}
private Object findById(Class type, int id)
1.7 +8 -7 db-ojb/src/test/org/apache/ojb/broker/ObjectRepository.java
Index: ObjectRepository.java
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ObjectRepository.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ObjectRepository.java 22 Apr 2004 16:27:19 -0000 1.6
+++ ObjectRepository.java 12 Jul 2004 10:11:18 -0000 1.7
@@ -14,21 +14,22 @@
*/
public class ObjectRepository
{
- public static class Component implements Serializable
+ public static class Component
+ implements ComponentIF
{
Integer id;
int type;
String name;
Group group;
- Component parentComponent;
+ ComponentIF parentComponent;
Collection childComponents;
public boolean equals(Object obj)
{
boolean result = false;
- if(obj instanceof Component)
+ if(obj instanceof ComponentIF)
{
- Component other = (Component) obj;
+ ComponentIF other = (ComponentIF) obj;
result = new EqualsBuilder()
.append(this.getId(), other.getId())
.append(this.getName(), other.getName())
@@ -63,12 +64,12 @@
this.group = group;
}
- public Component getParentComponent()
+ public ComponentIF getParentComponent()
{
return parentComponent;
}
- public void setParentComponent(Component parentComponent)
+ public void setParentComponent(ComponentIF parentComponent)
{
this.parentComponent = parentComponent;
}
1.4 +73 -43 db-ojb/src/test/org/apache/ojb/repository_junit_model.xml
Index: repository_junit_model.xml
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit_model.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- repository_junit_model.xml 5 Apr 2004 13:58:59 -0000 1.3
+++ repository_junit_model.xml 12 Jul 2004 10:11:18 -0000 1.4
@@ -34,8 +34,10 @@
jdbc-type="VARCHAR"
/>
- <collection-descriptor name="roles" element-class-ref="org.apache.ojb.broker.ComplexReferenceTest$AbstractRole">
- <inverse-foreignkey field-ref="employeeId"/>
+ <collection-descriptor
+ name="roles"
+ element-class-ref="org.apache.ojb.broker.ComplexReferenceTest$AbstractRole">
+ <inverse-foreignkey field-ref="employeeId"/>
</collection-descriptor>
</class-descriptor>
@@ -71,19 +73,26 @@
/>
<field-descriptor
- name="name"
- column="NAME"
- jdbc-type="VARCHAR"
+ name="name"
+ column="NAME"
+ jdbc-type="VARCHAR"
/>
- <reference-descriptor name="employee" class-ref="org.apache.ojb.broker.ComplexReferenceTest$Employee"
- refresh="true">
- <foreignkey field-ref="employeeID"/>
+ <reference-descriptor
+ name="employee"
+ class-ref="org.apache.ojb.broker.ComplexReferenceTest$Employee"
+ refresh="true">
+ <foreignkey field-ref="employeeID"/>
</reference-descriptor>
- <collection-descriptor name="subProjects" element-class-ref="org.apache.ojb.broker.ComplexReferenceTest$SubProject"
- auto-delete="false" auto-update="true" auto-retrieve="true">
- <inverse-foreignkey field-ref="tutorId"/>
+ <collection-descriptor
+ name="subProjects"
+ element-class-ref="org.apache.ojb.broker.ComplexReferenceTest$SubProject"
+ auto-retrieve="true"
+ auto-update="true"
+ auto-delete="false"
+ >
+ <inverse-foreignkey field-ref="projectId"/>
</collection-descriptor>
</class-descriptor>
@@ -94,11 +103,11 @@
table="CRT_LEADER"
>
<field-descriptor
- name="id"
- column="ROLE_ID"
- jdbc-type="INTEGER"
- primarykey="true"
- autoincrement="true"
+ name="id"
+ column="ROLE_ID"
+ jdbc-type="INTEGER"
+ primarykey="true"
+ autoincrement="true"
/>
<field-descriptor
@@ -109,18 +118,26 @@
/>
<field-descriptor
- name="name"
- column="NAME"
- jdbc-type="VARCHAR"
+ name="name"
+ column="NAME"
+ jdbc-type="VARCHAR"
/>
- <reference-descriptor name="employee" class-ref="org.apache.ojb.broker.ComplexReferenceTest$Employee" refresh="true">
- <foreignkey field-ref="employeeID"/>
+ <reference-descriptor
+ name="employee"
+ class-ref="org.apache.ojb.broker.ComplexReferenceTest$Employee"
+ refresh="true">
+ <foreignkey field-ref="employeeID"/>
</reference-descriptor>
- <collection-descriptor name="projects" element-class-ref="org.apache.ojb.broker.ComplexReferenceTest$Project"
- auto-delete="true" auto-update="true" auto-retrieve="true">
- <inverse-foreignkey field-ref="projectEngineerID"/>
+ <collection-descriptor
+ name="projects"
+ element-class-ref="org.apache.ojb.broker.ComplexReferenceTest$Project"
+ auto-retrieve="true"
+ auto-update="true"
+ auto-delete="true"
+ >
+ <inverse-foreignkey field-ref="engineerId"/>
</collection-descriptor>
</class-descriptor>
@@ -130,33 +147,40 @@
table="CRT_PROJECT"
>
<field-descriptor
- name="id"
- column="PROJECT_ID"
- jdbc-type="INTEGER"
- primarykey="true"
- autoincrement="true"
+ name="id"
+ column="PROJECT_ID"
+ jdbc-type="INTEGER"
+ primarykey="true"
+ autoincrement="true"
/>
<field-descriptor
- name="name"
- column="NAME"
- jdbc-type="VARCHAR"
+ name="name"
+ column="NAME"
+ jdbc-type="VARCHAR"
/>
<field-descriptor
- name="engineerId"
- column="ENGINEER_ID"
- jdbc-type="INTEGER"
- access="anonymous"
+ name="engineerId"
+ column="ENGINEER_ID"
+ jdbc-type="INTEGER"
+ access="anonymous"
/>
- <reference-descriptor name="leader" class-ref="org.apache.ojb.broker.ComplexReferenceTest$ProjectEngineer">
- <foreignkey field-ref="engineerId"/>
+ <reference-descriptor
+ name="leader"
+ class-ref="org.apache.ojb.broker.ComplexReferenceTest$ProjectEngineer">
+ <foreignkey field-ref="engineerId"/>
</reference-descriptor>
- <collection-descriptor name="subProjects" element-class-ref="org.apache.ojb.broker.ComplexReferenceTest$SubProject"
- auto-delete="true" auto-update="true" auto-retrieve="true">
- <fk-pointing-to-element-class column="projectId"/>
+ <collection-descriptor
+ name="subProjects"
+ element-class-ref="org.apache.ojb.broker.ComplexReferenceTest$SubProject"
+ auto-retrieve="true"
+ auto-update="true"
+ auto-delete="true"
+ >
+ <inverse-foreignkey field-ref="projectId"/>
</collection-descriptor>
</class-descriptor>
@@ -194,11 +218,17 @@
jdbc-type="VARCHAR"
/>
- <reference-descriptor name="project" class-ref="org.apache.ojb.broker.ComplexReferenceTest$Project">
+ <reference-descriptor
+ name="project"
+ class-ref="org.apache.ojb.broker.ComplexReferenceTest$Project"
+ >
<foreignkey field-ref="projectId"/>
</reference-descriptor>
- <reference-descriptor name="tutor" class-ref="org.apache.ojb.broker.ComplexReferenceTest$TeamMember">
+ <reference-descriptor
+ name="tutor"
+ class-ref="org.apache.ojb.broker.ComplexReferenceTest$TeamMember"
+ >
<foreignkey field-ref="tutorId"/>
</reference-descriptor>
</class-descriptor>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org