KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateful > beanmanaged > sessioncontext > SFSBBeanManagedSessionCtxMethods


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: SFSBBeanManagedSessionCtxMethods.java 863 2006-07-13 11:26:43Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateful.beanmanaged.sessioncontext;
26
27 import static org.testng.Assert.assertEquals;
28
29 import javax.annotation.Resource;
30 import javax.ejb.Remote JavaDoc;
31 import javax.ejb.SessionContext JavaDoc;
32 import javax.ejb.Stateful JavaDoc;
33 import javax.ejb.TransactionManagement JavaDoc;
34 import javax.ejb.TransactionManagementType JavaDoc;
35
36 import org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT;
37 import org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextCMT;
38 import org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3;
39 import org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer;
40
41 /**
42  * This class is used to test SessionContext methods.
43  * @author Eduardo Studzinski Estima de Castro
44  * @author Gisele Pinheiro Souza
45  */

46 @Stateful JavaDoc(name = "SFSBBeanManagedSessionCtxMethods")
47 @Remote JavaDoc({ItfSessionContextBMT.class, ItfSessionContextCMT.class, ItfSessionContextEJB3.class,
48         ItfSessionContextTimer.class})
49 @TransactionManagement JavaDoc(value = TransactionManagementType.BEAN)
50 public class SFSBBeanManagedSessionCtxMethods implements ItfSessionContextBMT, ItfSessionContextCMT,
51         ItfSessionContextEJB3, ItfSessionContextTimer {
52
53     /**
54      * SessionContext.
55      */

56     @Resource
57     private SessionContext JavaDoc ctx;
58
59     /**
60      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextCMT
61      */

62     public void verifySetRollbackOnly() {
63         // Must throw an IllegalStateException
64
ctx.setRollbackOnly();
65     }
66
67     /**
68      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextCMT
69      */

70     public void verifyGetRollbackOnly() {
71         // Must throw an IllegalStateException
72
ctx.getRollbackOnly();
73     }
74
75     /**
76      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
77      */

78     public void verifyGetBusinessObject() {
79         ItfSessionContextCMT bean = ctx.getBusinessObject(ItfSessionContextCMT.class);
80         bean.verifyGetRollbackOnly();
81     }
82
83     /**
84      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
85      */

86     public void verifyGetInvokedBusinessInterface() {
87         Class JavaDoc cl = ctx.getInvokedBusinessInterface();
88         assertEquals(cl, ItfSessionContextEJB3.class, "This method should return the "
89                 + "interface ItfSessionContextEJB3, but returned " + cl.getName());
90     }
91
92     /**
93      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
94      */

95     public void verifyGetTimerService() {
96         // Must throw an IllegalStateException
97
ctx.getTimerService();
98     }
99
100     /**
101      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT
102      */

103     public void verifyGetUserTransaction() {
104         ctx.getUserTransaction();
105     }
106
107 }
108
Popular Tags