1 5 package org.apache.ojb.odmg; 6 7 import junit.framework.TestCase; 8 import org.apache.ojb.broker.Table_1Object; 9 import org.apache.ojb.broker.Table_2Object; 10 import org.apache.ojb.broker.TestHelper; 11 import org.odmg.Database; 12 import org.odmg.Implementation; 13 import org.odmg.Transaction; 14 15 24 public class AutoIncrementWithRelatedObjectTest extends TestCase 25 { 26 private static Class CLASS = AutoIncrementWithRelatedObjectTest.class; 27 private String databaseName; 28 29 public static void main(String [] args) 30 { 31 String [] arr = {CLASS.getName()}; 32 junit.textui.TestRunner.main(arr); 33 } 34 35 40 public void testCreateWithoutRelatedObject() throws Exception  41 { 42 Implementation odmg = OJB.getInstance(); 43 Database db = odmg.newDatabase(); 44 db.open(databaseName, Database.OPEN_READ_WRITE); 45 try 46 { 47 Transaction tx = odmg.newTransaction(); 48 tx.begin(); 49 Table_1Object table1Ojb = new Table_1Object(); 50 db.makePersistent(table1Ojb); 51 tx.commit(); 52 } 53 finally 54 { 55 db.close(); 56 } 57 } 58 59 62 public void testCreateWithRelatedObject() throws Exception  63 { 64 Implementation odmg = OJB.getInstance(); 65 Database db = odmg.newDatabase(); 66 db.open(databaseName, Database.OPEN_READ_WRITE); 67 try 68 { 69 Transaction tx = odmg.newTransaction(); 70 tx.begin(); 71 Table_1Object table1Obj = new Table_1Object(); 72 Table_2Object table2Obj = new Table_2Object(); 73 table1Obj.setTable2Object(table2Obj); 74 db.makePersistent(table2Obj); 75 db.makePersistent(table1Obj); 76 tx.commit(); 77 } 78 finally 79 { 80 db.close(); 81 } 82 } 83 84 88 public AutoIncrementWithRelatedObjectTest(String name) 89 { 90 super(name); 91 } 92 93 97 public void setUp() 98 { 99 databaseName = TestHelper.DEF_DATABASE_NAME; 100 } 101 102 106 public void tearDown() 107 { 108 } 109 } 110 | Popular Tags |