KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > entity > B_AdvancedHomeEC


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id:
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.entity;
27
28 import org.objectweb.jonas.jtests.beans.annuaire.Personne;
29 import org.objectweb.jonas.jtests.beans.annuaire.PersonneHome;
30 import org.objectweb.jonas.jtests.util.JTestCase;
31
32
33 /**
34  * This is an advanced test suite for home interface on entity bean CMP.
35  * Beans used: annuaire
36  * @author Philippe Coq, Philippe Durieux, Helene Joanin (jonas team)
37  */

38 public abstract class B_AdvancedHomeEC extends JTestCase {
39
40     String JavaDoc mynum = "638";
41     String JavaDoc myname = "Philippe Durieux";
42
43     public B_AdvancedHomeEC(String JavaDoc name) {
44         super(name);
45     }
46
47     protected void setUp() {
48         super.setUp();
49         useBeans("annuaire", true);
50     }
51
52     /**
53      * return PersonneHome, that can be either CMP v1 or CMP v2 bean.
54      */

55     abstract public PersonneHome getHome();
56
57
58     /**
59      * test a simple Remove
60      * Find an instance already in database and remove it.
61      */

62     public void testFindbynomRemoveCreate() throws Exception JavaDoc {
63         Personne p = getHome().findByNom("Adriana Danes");
64         p.remove();
65         getHome().create("Adriana Danes", "777"); // cleaning
66

67     }
68
69   
70
71     /**
72      * Test create + remove in transactions
73      */

74     public void testCreateRemoveInTx() throws Exception JavaDoc {
75         for (int i = 0; i < 20; i++) {
76             utx.begin();
77             try {
78                 getHome().create("Eric Paire", "500");
79                 getHome().remove("Eric Paire");
80                
81             }
82             catch (Exception JavaDoc e) {
83                 fail(e.getMessage());
84             }
85             finally {
86                 utx.commit();
87             }
88         }
89     }
90 }
91
92
Popular Tags