KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openejb > test > stateless > StatelessContainerTxTests


1 /**
2  * Redistribution and use of this software and associated documentation
3  * ("Software"), with or without modification, are permitted provided
4  * that the following conditions are met:
5  *
6  * 1. Redistributions of source code must retain copyright
7  * statements and notices. Redistributions must also contain a
8  * copy of this document.
9  *
10  * 2. Redistributions in binary form must reproduce the
11  * above copyright notice, this list of conditions and the
12  * following disclaimer in the documentation and/or other
13  * materials provided with the distribution.
14  *
15  * 3. The name "OpenEJB" must not be used to endorse or promote
16  * products derived from this Software without prior written
17  * permission of The OpenEJB Group. For written permission,
18  * please contact dev@openejb.org.
19  *
20  * 4. Products derived from this Software may not be called "OpenEJB"
21  * nor may "OpenEJB" appear in their names without prior written
22  * permission of The OpenEJB Group. OpenEJB is a registered
23  * trademark of The OpenEJB Group.
24  *
25  * 5. Due credit should be given to the OpenEJB Project
26  * (http://www.openejb.org/).
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32  * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39  * OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
42  *
43  * $Id: StatelessContainerTxTests.java 1912 2005-06-16 22:29:56Z jlaskowski $
44  */

45 package org.openejb.test.stateless;
46
47 import java.util.Properties JavaDoc;
48
49 import javax.ejb.EJBMetaData JavaDoc;
50 import javax.ejb.Handle JavaDoc;
51 import javax.ejb.HomeHandle JavaDoc;
52 import javax.naming.Context JavaDoc;
53 import javax.naming.InitialContext JavaDoc;
54
55 import org.openejb.test.TestManager;
56
57 /**
58  * [1] Should be run as the first test suite of the StatelessTestClients
59  *
60  * @author <a HREF="mailto:david.blevins@visi.com">David Blevins</a>
61  * @author <a HREF="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
62  */

63 public class StatelessContainerTxTests extends org.openejb.test.NamedTestCase{
64
65     public final static String JavaDoc jndiEJBHomeEntry = "client/tests/stateless/ContainerManagedTransactionTests/EJBHome";
66
67     protected ContainerTxStatelessHome ejbHome;
68     protected ContainerTxStatelessObject ejbObject;
69
70     protected EJBMetaData JavaDoc ejbMetaData;
71     protected HomeHandle JavaDoc ejbHomeHandle;
72     protected Handle JavaDoc ejbHandle;
73     protected Integer JavaDoc ejbPrimaryKey;
74
75     protected InitialContext JavaDoc initialContext;
76
77     public StatelessContainerTxTests(){
78         super("Stateless.ContainerManagedTransaction.");
79     }
80
81     /**
82      * Sets up the fixture, for example, open a network connection.
83      * This method is called before a test is executed.
84      */

85     protected void setUp() throws Exception JavaDoc {
86
87         Properties JavaDoc properties = TestManager.getServer().getContextEnvironment();
88         properties.put(Context.SECURITY_PRINCIPAL, "STATELESS_test00_CLIENT");
89         properties.put(Context.SECURITY_CREDENTIALS, "STATELESS_test00_CLIENT");
90
91         initialContext = new InitialContext JavaDoc(properties);
92
93         /*[1] Get bean */
94         Object JavaDoc obj = initialContext.lookup(jndiEJBHomeEntry);
95         ejbHome = (ContainerTxStatelessHome)javax.rmi.PortableRemoteObject.narrow( obj, ContainerTxStatelessHome.class);
96         ejbObject = ejbHome.create();
97
98         /*[2] Create database table */
99         TestManager.getDatabase().createAccountTable();
100     }
101
102     /**
103      * Tears down the fixture, for example, close a network connection.
104      * This method is called after a test is executed.
105      */

106     protected void tearDown() throws Exception JavaDoc {
107         /*[1] Drop database table */
108         TestManager.getDatabase().dropAccountTable();
109     }
110
111     public void test01_txMandatory_withoutTx(){
112         try{
113             String JavaDoc expected = "ping";
114             String JavaDoc actual = ejbObject.txMandatoryMethod( expected );
115             assertEquals("The method invocation was invalid.", expected, actual);
116         } catch (Exception JavaDoc e){
117             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
118         }
119     }
120
121     public void test02_txNever_withoutTx(){
122         try{
123             String JavaDoc expected = "ping";
124             String JavaDoc actual = ejbObject.txNeverMethod( expected );
125             assertEquals("The method invocation was invalid.", expected, actual);
126         } catch (Exception JavaDoc e){
127             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
128         }
129     }
130
131     public void test03_txNotSupported_withoutTx(){
132         try{
133             String JavaDoc expected = "ping";
134             String JavaDoc actual = ejbObject.txNotSupportedMethod( expected );
135             assertEquals("The method invocation was invalid.", expected, actual);
136         } catch (Exception JavaDoc e){
137             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
138         }
139     }
140
141     public void test04_txRequired_withoutTx(){
142         try{
143             String JavaDoc expected = "ping";
144             String JavaDoc actual = ejbObject.txRequiredMethod( expected );
145             assertEquals("The method invocation was invalid.", expected, actual);
146         } catch (Exception JavaDoc e){
147             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
148         }
149     }
150
151     public void test05_txRequiresNew_withoutTx(){
152         try{
153             String JavaDoc expected = "ping";
154             String JavaDoc actual = ejbObject.txRequiresNewMethod( expected );
155             assertEquals("The method invocation was invalid.", expected, actual);
156         } catch (Exception JavaDoc e){
157             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
158         }
159     }
160
161     public void test06_txSupports_withoutTx(){
162         try{
163             String JavaDoc expected = "ping";
164             String JavaDoc actual = ejbObject.txSupportsMethod( expected );
165             assertEquals("The method invocation was invalid.", expected, actual);
166         } catch (Exception JavaDoc e){
167             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
168         }
169     }
170
171     public void test07_txMandatory_withTx(){
172         try{
173             String JavaDoc expected = "ping";
174             String JavaDoc actual = ejbObject.txMandatoryMethod( expected );
175             assertEquals("The method invocation was invalid.", expected, actual);
176         } catch (Exception JavaDoc e){
177             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
178         }
179     }
180
181     public void test08_txNever_withTx(){
182         try{
183             String JavaDoc expected = "ping";
184             String JavaDoc actual = ejbObject.txNeverMethod( expected );
185             assertEquals("The method invocation was invalid.", expected, actual);
186         } catch (Exception JavaDoc e){
187             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
188         }
189     }
190
191     public void test09_txNotSupported_withTx(){
192         try{
193             String JavaDoc expected = "ping";
194             String JavaDoc actual = ejbObject.txNotSupportedMethod( expected );
195             assertEquals("The method invocation was invalid.", expected, actual);
196         } catch (Exception JavaDoc e){
197             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
198         }
199     }
200
201     public void test10_txRequired_withTx(){
202         try{
203             String JavaDoc expected = "ping";
204             String JavaDoc actual = ejbObject.txRequiredMethod( expected );
205             assertEquals("The method invocation was invalid.", expected, actual);
206         } catch (Exception JavaDoc e){
207             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
208         }
209     }
210
211     public void test11_txRequiresNew_withTx(){
212         try{
213             String JavaDoc expected = "ping";
214             String JavaDoc actual = ejbObject.txRequiresNewMethod( expected );
215             assertEquals("The method invocation was invalid.", expected, actual);
216         } catch (Exception JavaDoc e){
217             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
218         }
219     }
220
221     public void test12_txSupports_withTx(){
222         try{
223             String JavaDoc expected = "ping";
224             String JavaDoc actual = ejbObject.txSupportsMethod( expected );
225             assertEquals("The method invocation was invalid.", expected, actual);
226         } catch (Exception JavaDoc e){
227             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
228         }
229     }
230
231     public void test01_txMandatory_withoutTx_appException(){
232         try{
233             String JavaDoc expected = "ping";
234             String JavaDoc actual = ejbObject.txMandatoryMethod( expected );
235             assertEquals("The method invocation was invalid.", expected, actual);
236         } catch (Exception JavaDoc e){
237             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
238         }
239     }
240
241     public void test02_txNever_withoutTx_appException(){
242         try{
243             String JavaDoc expected = "ping";
244             String JavaDoc actual = ejbObject.txNeverMethod( expected );
245             assertEquals("The method invocation was invalid.", expected, actual);
246         } catch (Exception JavaDoc e){
247             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
248         }
249     }
250
251     public void test03_txNotSupported_withoutTx_appException(){
252         try{
253             String JavaDoc expected = "ping";
254             String JavaDoc actual = ejbObject.txNotSupportedMethod( expected );
255             assertEquals("The method invocation was invalid.", expected, actual);
256         } catch (Exception JavaDoc e){
257             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
258         }
259     }
260
261     public void test04_txRequired_withoutTx_appException(){
262         try{
263             String JavaDoc expected = "ping";
264             String JavaDoc actual = ejbObject.txRequiredMethod( expected );
265             assertEquals("The method invocation was invalid.", expected, actual);
266         } catch (Exception JavaDoc e){
267             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
268         }
269     }
270
271     public void test05_txRequiresNew_withoutTx_appException(){
272         try{
273             String JavaDoc expected = "ping";
274             String JavaDoc actual = ejbObject.txRequiresNewMethod( expected );
275             assertEquals("The method invocation was invalid.", expected, actual);
276         } catch (Exception JavaDoc e){
277             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
278         }
279     }
280
281     public void test06_txSupports_withoutTx_appException(){
282         try{
283             String JavaDoc expected = "ping";
284             String JavaDoc actual = ejbObject.txSupportsMethod( expected );
285             assertEquals("The method invocation was invalid.", expected, actual);
286         } catch (Exception JavaDoc e){
287             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
288         }
289     }
290
291     public void test07_txMandatory_withTx_appException(){
292         try{
293             String JavaDoc expected = "ping";
294             String JavaDoc actual = ejbObject.txMandatoryMethod( expected );
295             assertEquals("The method invocation was invalid.", expected, actual);
296         } catch (Exception JavaDoc e){
297             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
298         }
299     }
300
301     public void test08_txNever_withTx_appException(){
302         try{
303             String JavaDoc expected = "ping";
304             String JavaDoc actual = ejbObject.txNeverMethod( expected );
305             assertEquals("The method invocation was invalid.", expected, actual);
306         } catch (Exception JavaDoc e){
307             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
308         }
309     }
310
311     public void test09_txNotSupported_withTx_appException(){
312         try{
313             String JavaDoc expected = "ping";
314             String JavaDoc actual = ejbObject.txNotSupportedMethod( expected );
315             assertEquals("The method invocation was invalid.", expected, actual);
316         } catch (Exception JavaDoc e){
317             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
318         }
319     }
320
321     public void test10_txRequired_withTx_appException(){
322         try{
323             String JavaDoc expected = "ping";
324             String JavaDoc actual = ejbObject.txRequiredMethod( expected );
325             assertEquals("The method invocation was invalid.", expected, actual);
326         } catch (Exception JavaDoc e){
327             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
328         }
329     }
330
331     public void test11_txRequiresNew_withTx_appException(){
332         try{
333             String JavaDoc expected = "ping";
334             String JavaDoc actual = ejbObject.txRequiresNewMethod( expected );
335             assertEquals("The method invocation was invalid.", expected, actual);
336         } catch (Exception JavaDoc e){
337             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
338         }
339     }
340
341     public void test12_txSupports_withTx_appException(){
342         try{
343             String JavaDoc expected = "ping";
344             String JavaDoc actual = ejbObject.txSupportsMethod( expected );
345             assertEquals("The method invocation was invalid.", expected, actual);
346         } catch (Exception JavaDoc e){
347             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
348         }
349     }
350
351     public void test01_txMandatory_withoutTx_sysException(){
352         try{
353             String JavaDoc expected = "ping";
354             String JavaDoc actual = ejbObject.txMandatoryMethod( expected );
355             assertEquals("The method invocation was invalid.", expected, actual);
356         } catch (Exception JavaDoc e){
357             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
358         }
359     }
360
361     public void test02_txNever_withoutTx_sysException(){
362         try{
363             String JavaDoc expected = "ping";
364             String JavaDoc actual = ejbObject.txNeverMethod( expected );
365             assertEquals("The method invocation was invalid.", expected, actual);
366         } catch (Exception JavaDoc e){
367             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
368         }
369     }
370
371     public void test03_txNotSupported_withoutTx_sysException(){
372         try{
373             String JavaDoc expected = "ping";
374             String JavaDoc actual = ejbObject.txNotSupportedMethod( expected );
375             assertEquals("The method invocation was invalid.", expected, actual);
376         } catch (Exception JavaDoc e){
377             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
378         }
379     }
380
381     public void test04_txRequired_withoutTx_sysException(){
382         try{
383             String JavaDoc expected = "ping";
384             String JavaDoc actual = ejbObject.txRequiredMethod( expected );
385             assertEquals("The method invocation was invalid.", expected, actual);
386         } catch (Exception JavaDoc e){
387             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
388         }
389     }
390
391     public void test05_txRequiresNew_withoutTx_sysException(){
392         try{
393             String JavaDoc expected = "ping";
394             String JavaDoc actual = ejbObject.txRequiresNewMethod( expected );
395             assertEquals("The method invocation was invalid.", expected, actual);
396         } catch (Exception JavaDoc e){
397             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
398         }
399     }
400
401     public void test06_txSupports_withoutTx_sysException(){
402         try{
403             String JavaDoc expected = "ping";
404             String JavaDoc actual = ejbObject.txSupportsMethod( expected );
405             assertEquals("The method invocation was invalid.", expected, actual);
406         } catch (Exception JavaDoc e){
407             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
408         }
409     }
410
411     public void test07_txMandatory_withTx_sysException(){
412         try{
413             String JavaDoc expected = "ping";
414             String JavaDoc actual = ejbObject.txMandatoryMethod( expected );
415             assertEquals("The method invocation was invalid.", expected, actual);
416         } catch (Exception JavaDoc e){
417             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
418         }
419     }
420
421     public void test08_txNever_withTx_sysException(){
422         try{
423             String JavaDoc expected = "ping";
424             String JavaDoc actual = ejbObject.txNeverMethod( expected );
425             assertEquals("The method invocation was invalid.", expected, actual);
426         } catch (Exception JavaDoc e){
427             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
428         }
429     }
430
431     public void test09_txNotSupported_withTx_sysException(){
432         try{
433             String JavaDoc expected = "ping";
434             String JavaDoc actual = ejbObject.txNotSupportedMethod( expected );
435             assertEquals("The method invocation was invalid.", expected, actual);
436         } catch (Exception JavaDoc e){
437             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
438         }
439     }
440
441     public void test10_txRequired_withTx_sysException(){
442         try{
443             String JavaDoc expected = "ping";
444             String JavaDoc actual = ejbObject.txRequiredMethod( expected );
445             assertEquals("The method invocation was invalid.", expected, actual);
446         } catch (Exception JavaDoc e){
447             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
448         }
449     }
450
451     public void test11_txRequiresNew_withTx_sysException(){
452         try{
453             String JavaDoc expected = "ping";
454             String JavaDoc actual = ejbObject.txRequiresNewMethod( expected );
455             assertEquals("The method invocation was invalid.", expected, actual);
456         } catch (Exception JavaDoc e){
457             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
458         }
459     }
460
461     public void test12_txSupports_withTx_sysException(){
462         try{
463             String JavaDoc expected = "ping";
464             String JavaDoc actual = ejbObject.txSupportsMethod( expected );
465             assertEquals("The method invocation was invalid.", expected, actual);
466         } catch (Exception JavaDoc e){
467             fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
468         }
469     }
470 }
471
472
Popular Tags