KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > odmg > BatchModeTest


1 /*
2  * BatchModeTest.java
3  * JUnit based test
4  *
5  * Created on February 15, 2003, 12:47 AM
6  */

7
8 package org.apache.ojb.odmg;
9
10 import junit.framework.TestSuite;
11 import org.apache.ojb.junit.ODMGTestCase;
12 import org.apache.ojb.odmg.shared.Article;
13 import org.apache.ojb.odmg.shared.ProductGroup;
14 import org.odmg.Transaction;
15
16 /**
17  * @author Oleg Nitz
18  */

19 public class BatchModeTest extends ODMGTestCase
20 {
21     public static void main(String JavaDoc[] args)
22     {
23         junit.textui.TestRunner.run(new TestSuite(BatchModeTest.class));
24     }
25
26     public void testBatchStatementsOrder()
27     {
28         // arminw: fixed
29
// if(ojbSkipKnownIssueProblem()) return;
30

31         Transaction tx = odmg.newTransaction();
32         tx.begin();
33
34         ProductGroup pg1 = new ProductGroup();
35         pg1.setName("BatchModeTest ProductGroup #1");
36         database.makePersistent(pg1);
37
38         tx.checkpoint();
39
40         Article a1 = Article.createInstance();
41         a1.setArticleName("BatchModeTest Article #1");
42         a1.setProductGroup(pg1);
43         pg1.addArticle(a1);
44         database.makePersistent(a1);
45
46         ProductGroup pg2 = new ProductGroup();
47         pg2.setName("BatchModeTest ProductGroup #2");
48         database.makePersistent(pg2);
49
50         Article a2 = Article.createInstance();
51         a2.setArticleName("BatchModeTest Article #2");
52         a2.setProductGroup(pg2);
53         pg2.addArticle(a2);
54
55         tx.checkpoint();
56
57         database.deletePersistent(a1);
58
59         tx.checkpoint();
60
61         database.deletePersistent(pg1);
62         database.deletePersistent(a2);
63         database.deletePersistent(pg2);
64
65         tx.checkpoint();
66         tx.commit();
67     }
68 }
69
Popular Tags