KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > ejb2view > TestCMTExceptions


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@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: TestCMTExceptions.java 981 2006-07-28 14:16:22Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.ejb2view;
26
27 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.ejb2view.ItfCMTEjb2ViewClient;
28 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.ejb2view.SLSBCMTEjb2ViewClient;
29 import org.objectweb.easybeans.tests.common.helper.EJBHelper;
30 import org.testng.annotations.BeforeMethod;
31 import org.testng.annotations.Test;
32
33 /**
34  * Verifies the compatibility between the ejb 2.1 and the ejb 3.0. More
35  * specifically, it verifies if the exceptions thrown when methods with
36  * different transaction attributes are called incorrectly. The items are 13.6.2.5 and 13.6.2.6.
37  * @reference JSR 220-FINAL RELEASE
38  * @requirement Application Server must be running; the beans
39  * SFSBCMTEjb2ViewClient and CMTEJb2ViewBean must be deployed.
40  * @setup gets a reference of the bean SFSBCMTEjb2ViewClient.
41  * @author Gisele Pinheiro Souza
42  * @author Eduardo Studzinski Estima de Castro
43  */

44 public class TestCMTExceptions {
45
46     /**
47      * Bean that access the bean with ejb 2.1 remote view.
48      */

49     private ItfCMTEjb2ViewClient bean;
50
51     /**
52      * Gets an instance of the bean.
53      * @throws Exception if an error occurs.
54      */

55     @BeforeMethod
56     public void setup() throws Exception JavaDoc {
57         // Gets a bean instance.
58
bean = EJBHelper.getBeanRemoteInstance(SLSBCMTEjb2ViewClient.class, ItfCMTEjb2ViewClient.class);
59     }
60
61     /**
62      * Verifies if the client with a ejb 2.1 local view receives the correct
63      * exception when a method with Transaction Attribute Mandatory is called
64      * without transaction context. The expected exception is
65      * TransactionRequiredLocalException.
66      * @input -
67      * @output the correct method execution.
68      * @throws Exception if some error occurs during the test.
69      */

70     @Test
71     public void verifyMandatoryLocalException() throws Exception JavaDoc{
72         bean.testLocalMandatoryException();
73     }
74
75     /**
76      * Verifies if the client with a ejb 2.1 remote view receives the correct
77      * exception when a method with Transaction Attribute Mandatory is called
78      * without transaction context. The expected exception is
79      * TransactionRequiredException.
80      * @input -
81      * @output the correct method execution.
82      * @throws Exception if some error occurs during the test.
83      */

84     @Test
85     public void verifyMandatoryRemoteException() throws Exception JavaDoc{
86         bean.testRemoteMandatoryException();
87     }
88
89     /**
90      * Verifies if the client with a ejb 2.1 local view receives the correct
91      * exception when a method with Transaction Attribute Never is called
92      * with transaction context. The expected exception is
93      * EJBException.
94      * @input -
95      * @output the correct method execution.
96      * @throws Exception if some error occurs during the test.
97      */

98     @Test
99     public void verifyNeverLocalException() throws Exception JavaDoc{
100         bean.testLocalNeverException();
101     }
102
103     /**
104      * Verifies if the client with a ejb 2.1 never view receives the correct
105      * exception when a method with Transaction Attribute Never is called
106      * with transaction context. The expected exception is
107      * RemoteException.
108      * @input -
109      * @output the correct method execution.
110      * @throws Exception if some error occurs during the test.
111      */

112     @Test
113     public void verifyNeverRemoteException() throws Exception JavaDoc{
114         bean.testRemoteNeverException();
115     }
116
117     /**
118      * Verifies if the method isIdentical works.
119      * @input -
120      * @output the correct method execution.
121      * @throws Exception if some error occurs during the test.
122      */

123     @Test
124     public void testIdentity() throws Exception JavaDoc{
125         bean.testIdentity();
126     }
127 }
128
Popular Tags