KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > AutoIncrementWithRelatedObjectTest


1 package org.apache.ojb.broker;
2
3 import org.apache.ojb.junit.PBTestCase;
4 /**
5  * @author MBaird mattbaird@yahoo.com
6  * Equivalent to the ODMG test of the same name, but redone using PB api.
7  *
8  * works for HSQLDB
9  * fails for MSSQL :(
10  * If you have results for other databases, please enter them here.
11  */

12 public class AutoIncrementWithRelatedObjectTest extends PBTestCase
13 {
14     public static void main(String JavaDoc[] args)
15     {
16         String JavaDoc[] arr = {AutoIncrementWithRelatedObjectTest.class.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     {
27         Table_1Object table1Ojb = new Table_1Object();
28         broker.beginTransaction();
29         broker.store(table1Ojb);
30         broker.commitTransaction();
31     }
32
33     /**
34      * do the create with a related object to prove it works.
35      */

36     public void testCreateWithRelatedObject()
37     {
38         Table_1Object table1Obj = new Table_1Object();
39         Table_2Object table2Obj = new Table_2Object();
40         table1Obj.setTable2Object(table2Obj);
41         broker.beginTransaction();
42         broker.store(table2Obj);
43         broker.store(table1Obj);
44         broker.commitTransaction();
45     }
46
47     public AutoIncrementWithRelatedObjectTest(String JavaDoc name)
48     {
49         super(name);
50     }
51 }
52
Popular Tags