01: package org.apache.ojb.broker;
02:
03: import org.apache.ojb.junit.PBTestCase;
04:
05: /**
06: * @author MBaird mattbaird@yahoo.com
07: * Equivalent to the ODMG test of the same name, but redone using PB api.
08: *
09: * works for HSQLDB
10: * fails for MSSQL :(
11: * If you have results for other databases, please enter them here.
12: */
13: public class AutoIncrementWithRelatedObjectTest extends PBTestCase {
14: public static void main(String[] args) {
15: String[] arr = { AutoIncrementWithRelatedObjectTest.class
16: .getName() };
17: junit.textui.TestRunner.main(arr);
18: }
19:
20: /**
21: * since java defaults the value of an int to 0, there might be a problem storing an
22: * object that uses int's as foreign keys. If this doesn't work, it means we can't use int's
23: * as foreign keys :(
24: */
25: public void testCreateWithoutRelatedObject() {
26: Table_1Object table1Ojb = new Table_1Object();
27: broker.beginTransaction();
28: broker.store(table1Ojb);
29: broker.commitTransaction();
30: }
31:
32: /**
33: * do the create with a related object to prove it works.
34: */
35: public void testCreateWithRelatedObject() {
36: Table_1Object table1Obj = new Table_1Object();
37: Table_2Object table2Obj = new Table_2Object();
38: table1Obj.setTable2Object(table2Obj);
39: broker.beginTransaction();
40: broker.store(table2Obj);
41: broker.store(table1Obj);
42: broker.commitTransaction();
43: }
44:
45: public AutoIncrementWithRelatedObjectTest(String name) {
46: super(name);
47: }
48: }
|