KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > sessionbean > stateful > context > TestSFBeanManagedSessionContextMethods00


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: TestSFBeanManagedSessionContextMethods00.java 979 2006-07-28 13:19:50Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.sessionbean.stateful.context;
26
27 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
28 import static org.objectweb.easybeans.tests.common.helper.ExceptionHelper.checkCause;
29 import static org.testng.Assert.fail;
30
31 import javax.ejb.EJBException JavaDoc;
32
33 import org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT;
34 import org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextCMT;
35 import org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3;
36 import org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer;
37 import org.objectweb.easybeans.tests.common.ejbs.stateful.beanmanaged.sessioncontext.SFSBBeanManagedSessionCtxMethods;
38 import org.testng.annotations.BeforeMethod;
39 import org.testng.annotations.Test;
40
41 /**
42  * Verifies the SessionContext's method invocation. The tests for the methods
43  * isCallerPrincipal, isCallerInRole and getCallerIdentity are defined in the
44  * security package.
45  * @reference JSR 220-PROPOSED FINAL
46  * @requirement Application Server must be running; the beans
47  * org.objectweb.easybeans.tests.common.ejbs.stateful.beanmanaged.sessioncontext.*
48  * must be deployed.
49  * @author Eduardo Studzinski Estima de Castro
50  * @author Gisele Pinheiro Souza
51  */

52 public class TestSFBeanManagedSessionContextMethods00 implements ItfSessionContextBMT, ItfSessionContextCMT,
53         ItfSessionContextEJB3, ItfSessionContextTimer {
54
55     /**
56      * Bean.
57      */

58     private ItfSessionContextBMT beanBMT;
59
60     /**
61      * Bean.
62      */

63     private ItfSessionContextCMT beanCMT;
64
65     /**
66      * Bean.
67      */

68     private ItfSessionContextEJB3 beanEJB3;
69
70
71     /**
72      * Bean.
73      */

74     private ItfSessionContextTimer beanTimer;
75
76     /**
77      * Gets bean instances used in the tests.
78      * @throws Exception if there is a problem with bean initialization.
79      */

80     @BeforeMethod
81     public void startUp() throws Exception JavaDoc {
82         beanBMT = getBeanRemoteInstance(SFSBBeanManagedSessionCtxMethods.class, ItfSessionContextBMT.class);
83         beanCMT = getBeanRemoteInstance(SFSBBeanManagedSessionCtxMethods.class, ItfSessionContextCMT.class);
84         beanEJB3 = getBeanRemoteInstance(SFSBBeanManagedSessionCtxMethods.class, ItfSessionContextEJB3.class);
85         beanTimer = getBeanRemoteInstance(SFSBBeanManagedSessionCtxMethods.class, ItfSessionContextTimer.class);
86     }
87
88     /**
89      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT
90      * @input -
91      * @output -
92      */

93     @Test
94     public void verifyGetUserTransaction() {
95         beanBMT.verifyGetUserTransaction();
96     }
97
98     /**
99      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
100      * @input -
101      * @output -
102      */

103     @Test
104     public void verifyGetBusinessObject() {
105         beanEJB3.verifyGetBusinessObject();
106     }
107
108     /**
109      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
110      * @input -
111      * @output -
112      */

113     @Test
114     public void verifyGetInvokedBusinessInterface() {
115         beanEJB3.verifyGetInvokedBusinessInterface();
116     }
117
118     /**
119      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
120      * @input -
121      * @output IllegalStateException encapsulated into an EJBException.
122      */

123     @Test
124     public void verifyGetTimerService() {
125         try {
126             beanTimer.verifyGetTimerService();
127             fail("The bean must throw an exception.");
128         } catch (EJBException JavaDoc e) {
129             checkCause(e, IllegalStateException JavaDoc.class);
130         }
131
132     }
133
134     /**
135      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
136      * @input -
137      * @output IllegalStateException encapsulated into an EJBException.
138      */

139     @Test
140     public void verifySetRollbackOnly() {
141         try {
142             beanCMT.verifySetRollbackOnly();
143             fail("The bean must throw an exception.");
144         } catch (EJBException JavaDoc e) {
145             checkCause(e, IllegalStateException JavaDoc.class);
146         }
147     }
148
149     /**
150      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
151      * @input -
152      * @output IllegalStateException encapsulated into an EJBException.
153      */

154     @Test
155     public void verifyGetRollbackOnly() {
156         try {
157             beanCMT.verifyGetRollbackOnly();
158             fail("The bean must throw an exception.");
159         } catch (EJBException JavaDoc e) {
160             checkCause(e, IllegalStateException JavaDoc.class);
161         }
162     }
163
164
165 }
166
Popular Tags