01: /*
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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.fannuaire.Personne;
29: import org.objectweb.jonas.jtests.beans.fannuaire.PersonneHome;
30: import org.objectweb.jonas.jtests.util.JTestCase;
31:
32: import javax.ejb.DuplicateKeyException;
33: import javax.ejb.FinderException;
34: import javax.ejb.RemoveException;
35: import javax.ejb.CreateException;
36: import javax.rmi.PortableRemoteObject;
37: import javax.transaction.RollbackException;
38: import javax.transaction.HeuristicMixedException;
39: import javax.transaction.HeuristicRollbackException;
40: import javax.transaction.SystemException;
41: import javax.transaction.NotSupportedException;
42: import java.util.Enumeration;
43: import java.rmi.RemoteException;
44:
45: /**
46: * This is an advanced test suite for home interface on entity bean CMP.
47: * Beans used: annuaire
48: * @author Philippe Coq, Philippe Durieux, Helene Joanin (jonas team)
49: */
50: public abstract class B_AdvancedHomeEC extends JTestCase {
51:
52: String mynum = "638";
53: String myname = "Philippe Durieux";
54:
55: public B_AdvancedHomeEC(String name) {
56: super (name);
57: }
58:
59: protected void setUp() {
60: super .setUp();
61: useBeans("fannuaire", true);
62: }
63:
64: /**
65: * return PersonneHome, that can be either CMP v1 or CMP v2 bean.
66: */
67: abstract public PersonneHome getHome();
68:
69: /**
70: * test a simple Remove
71: * Find an instance already in database and remove it.
72: */
73: public void testFindbynomRemoveCreate() throws Exception {
74: Personne p = getHome().findByNom("Adriana Danes");
75: p.remove();
76: getHome().create("Adriana Danes", "777"); // cleaning
77:
78: }
79:
80: /**
81: * Test create + remove in transactions
82: */
83: public void testCreateRemoveInTx() throws Exception {
84: for (int i = 0; i < 20; i++) {
85: utx.begin();
86: try {
87: getHome().create("Eric Paire", "500");
88: getHome().remove("Eric Paire");
89:
90: } catch (Exception e) {
91: fail(e.getMessage());
92: } finally {
93: utx.commit();
94: }
95: }
96: }
97: }
|