KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > transaction > F_BeanToBeanTx


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: F_BeanToBeanTx.java,v 1.4 2003/10/14 07:58:54 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.transaction;
27
28 import javax.naming.NamingException JavaDoc;
29 import javax.rmi.PortableRemoteObject JavaDoc;
30 import junit.framework.Test;
31 import junit.framework.TestSuite;
32 import org.objectweb.jonas.jtests.beans.transacted.Simple;
33 import org.objectweb.jonas.jtests.beans.transacted.SimpleEHome;
34 import org.objectweb.jonas.jtests.beans.transacted.SimpleSHome;
35 import org.objectweb.jonas.jtests.util.JTestCase;
36
37 /**
38  * Test for Bean to Bean transactions
39  * @author Ph.Durieux
40  */

41 public class F_BeanToBeanTx extends JTestCase {
42
43     protected static SimpleSHome syhome = null;
44     protected static SimpleSHome sfhome = null;
45     protected static SimpleSHome slhome = null;
46     protected static SimpleEHome echome = null;
47     protected static SimpleEHome ec2home = null;
48     protected static SimpleEHome ebhome = null;
49
50     public F_BeanToBeanTx(String JavaDoc name) {
51         super(name);
52     }
53
54     protected void setUp() {
55         super.setUp();
56         useBeans("transacted", true);
57         if (syhome == null) {
58             String JavaDoc BEAN_HOME = "transactedSimpleSYHome";
59             try {
60                 syhome = (SimpleSHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleSHome.class);
61             } catch (NamingException JavaDoc e) {
62                 fail("Cannot get " + BEAN_HOME + ":" + e);
63             }
64         }
65         if (sfhome == null) {
66             String JavaDoc BEAN_HOME = "transactedSimpleSFHome";
67             try {
68                 sfhome = (SimpleSHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleSHome.class);
69             } catch (NamingException JavaDoc e) {
70                 fail("Cannot get " + BEAN_HOME + ":" + e);
71             }
72         }
73         if (slhome == null) {
74             String JavaDoc BEAN_HOME = "transactedSimpleSLHome";
75             try {
76                 slhome = (SimpleSHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleSHome.class);
77             } catch (NamingException JavaDoc e) {
78                 fail("Cannot get " + BEAN_HOME + ":" + e);
79             }
80         }
81         if (echome == null) {
82             String JavaDoc BEAN_HOME = "transactedSimpleECHome";
83             try {
84                 echome = (SimpleEHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleEHome.class);
85             } catch (NamingException JavaDoc e) {
86                 fail("Cannot get " + BEAN_HOME + ":" + e);
87             }
88         }
89         if (ec2home == null) {
90             String JavaDoc BEAN_HOME = "transactedSimpleEC2Home";
91             try {
92                 ec2home = (SimpleEHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleEHome.class);
93             } catch (NamingException JavaDoc e) {
94                 fail("Cannot get " + BEAN_HOME + ":" + e);
95             }
96         }
97         if (ebhome == null) {
98             String JavaDoc BEAN_HOME = "transactedSimpleEBHome";
99             try {
100                 ebhome = (SimpleEHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), SimpleEHome.class);
101             } catch (NamingException JavaDoc e) {
102                 fail("Cannot get " + BEAN_HOME + ":" + e);
103             }
104         }
105     }
106
107     /**
108      * SL/Required -> EC/RequiresNew
109      */

110     public void testSLToEC() throws Exception JavaDoc {
111         Simple s1 = slhome.create();
112         Simple s2 = echome.create(30);
113         assertEquals(true, s1.call_requires_new_on(s2));
114         s1.remove();
115         s2.remove();
116     }
117
118     /**
119      * SL/Required -> EC2/RequiresNew
120      */

121     public void testSLToEC2() throws Exception JavaDoc {
122         Simple s1 = slhome.create();
123         Simple s2 = ec2home.create(30);
124         assertEquals(true, s1.call_requires_new_on(s2));
125         s1.remove();
126         s2.remove();
127     }
128
129     /**
130      * SF/Required -> EC/RequiresNew
131      */

132     public void testSFToEC() throws Exception JavaDoc {
133         Simple s1 = sfhome.create();
134         Simple s2 = echome.create(30);
135         assertEquals(true, s1.call_requires_new_on(s2));
136         s1.remove();
137         s2.remove();
138     }
139
140     /**
141      * SF/Required -> EC2/RequiresNew
142      */

143     public void testSFToEC2() throws Exception JavaDoc {
144         Simple s1 = sfhome.create();
145         Simple s2 = ec2home.create(30);
146         assertEquals(true, s1.call_requires_new_on(s2));
147         s1.remove();
148         s2.remove();
149     }
150     
151     /**
152      * SY/Required -> EC/RequiresNew
153      */

154     public void testSYToEC() throws Exception JavaDoc {
155         Simple s1 = syhome.create();
156         Simple s2 = echome.create(30);
157         assertEquals(true, s1.call_requires_new_on(s2));
158         s1.remove();
159         s2.remove();
160     }
161
162     /**
163      * SY/Required -> EC2/RequiresNew
164      */

165     public void testSYToEC2() throws Exception JavaDoc {
166         Simple s1 = syhome.create();
167         Simple s2 = ec2home.create(30);
168         assertEquals(true, s1.call_requires_new_on(s2));
169         s1.remove();
170         s2.remove();
171     }
172
173     /**
174      * EC/Required -> EC/RequiresNew
175      */

176     public void testECToEC() throws Exception JavaDoc {
177         Simple s1 = echome.create(31);
178         Simple s2 = echome.create(32);
179         assertEquals(true, s1.call_requires_new_on(s2));
180         s1.remove();
181         s2.remove();
182     }
183
184     /**
185      * EC2/Required -> EC2/RequiresNew
186      */

187     public void testEC2ToEC2() throws Exception JavaDoc {
188         Simple s1 = ec2home.create(31);
189         Simple s2 = ec2home.create(32);
190         assertEquals(true, s1.call_requires_new_on(s2));
191         s1.remove();
192         s2.remove();
193     }
194
195     /**
196      * EB/Required -> EC/RequiresNew
197      */

198     public void testEBToEC() throws Exception JavaDoc {
199         Simple s1 = ebhome.create(31);
200         Simple s2 = echome.create(32);
201         assertEquals(true, s1.call_requires_new_on(s2));
202         s1.remove();
203         s2.remove();
204     }
205
206     /**
207      * EB/Required -> EC2/RequiresNew
208      */

209     public void testEBToEC2() throws Exception JavaDoc {
210         Simple s1 = ebhome.create(31);
211         Simple s2 = ec2home.create(32);
212         assertEquals(true, s1.call_requires_new_on(s2));
213         s1.remove();
214         s2.remove();
215     }
216
217     /**
218      * SL/Required -> SY/RequiresNew
219      */

220     public void testSLToSY() throws Exception JavaDoc {
221         Simple s1 = slhome.create();
222         Simple s2 = syhome.create();
223         assertEquals(true, s1.call_requires_new_on(s2));
224         s1.remove();
225         s2.remove();
226     }
227
228     /**
229      * SF/Required -> SY/RequiresNew
230      */

231     public void testSFToSY() throws Exception JavaDoc {
232         Simple s1 = sfhome.create();
233         Simple s2 = syhome.create();
234         assertEquals(true, s1.call_requires_new_on(s2));
235         s1.remove();
236         s2.remove();
237     }
238
239     /**
240      * SY/Required -> SY/RequiresNew
241      */

242     public void testSYToSY() throws Exception JavaDoc {
243         Simple s1 = syhome.create();
244         Simple s2 = syhome.create();
245         assertEquals(true, s1.call_requires_new_on(s2));
246         s1.remove();
247         s2.remove();
248     }
249
250     /**
251      * EC/Required -> SY/RequiresNew
252      */

253     public void testECToSY() throws Exception JavaDoc {
254         Simple s1 = echome.create(31);
255         Simple s2 = syhome.create();
256         assertEquals(true, s1.call_requires_new_on(s2));
257         s1.remove();
258         s2.remove();
259     }
260
261     /**
262      * EC2/Required -> SY/RequiresNew
263      */

264     public void testEC2ToSY() throws Exception JavaDoc {
265         Simple s1 = ec2home.create(31);
266         Simple s2 = syhome.create();
267         assertEquals(true, s1.call_requires_new_on(s2));
268         s1.remove();
269         s2.remove();
270     }
271
272     public void testSupports2Required() throws Exception JavaDoc {
273         Simple s2 = sfhome.create();
274         assertEquals(true, s2.supports_call_required());
275         s2.remove();
276     }
277
278     /**
279      * EB/Required -> SY/RequiresNew
280      */

281     public void testEBToSY() throws Exception JavaDoc {
282         Simple s1 = ebhome.create(31);
283         Simple s2 = syhome.create();
284         assertEquals(true, s1.call_requires_new_on(s2));
285         s1.remove();
286         s2.remove();
287     }
288
289     public static Test suite() {
290         return new TestSuite(F_BeanToBeanTx.class);
291     }
292
293     public static void main (String JavaDoc args[]) {
294         String JavaDoc testtorun = null;
295         // Get args
296
for (int argn = 0; argn < args.length; argn++) {
297             String JavaDoc s_arg = args[argn];
298             Integer JavaDoc i_arg;
299             if (s_arg.equals("-n")) {
300                 testtorun = args[++argn];
301             }
302         }
303         if (testtorun == null) {
304             junit.textui.TestRunner.run(suite());
305         } else {
306             junit.textui.TestRunner.run(new F_BeanToBeanTx(testtorun));
307         }
308     }
309 }
310
Popular Tags