KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateless > containermanaged > sessioncontext > SLSBSessionCtxMethods


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$
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.sessioncontext;
26
27 import static org.testng.Assert.assertEquals;
28 import static org.testng.Assert.assertNotNull;
29 import static org.testng.Assert.assertTrue;
30
31 import javax.annotation.Resource;
32 import javax.ejb.Remote JavaDoc;
33 import javax.ejb.SessionContext JavaDoc;
34 import javax.ejb.Stateless 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 import org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextWS;
41
42 /**
43  * This class is used to test SessionContext methods.
44  * @author Eduardo Studzinski Estima de Castro
45  * @author Gisele Pinheiro Souza
46  */

47 @Stateless JavaDoc(name = "SLSBSessionCtxMethods")
48 @Remote JavaDoc({ItfSessionContextBMT.class, ItfSessionContextCMT.class, ItfSessionContextEJB3.class,
49     ItfSessionContextTimer.class, ItfSessionContextWS.class})
50 public class SLSBSessionCtxMethods implements ItfSessionContextBMT, ItfSessionContextCMT, ItfSessionContextEJB3,
51          ItfSessionContextTimer, ItfSessionContextWS{
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         ctx.setRollbackOnly();
64         assertTrue(ctx.getRollbackOnly(), "The transaction should be marked to rollback.");
65     }
66
67     /**
68      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextCMT
69      */

70     public void verifyGetRollbackOnly() {
71         this.verifySetRollbackOnly();
72     }
73
74     /**
75      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
76      */

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

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

94     public void verifyGetTimerService() {
95         assertNotNull(ctx.getTimerService(), "The Timer should not be null.");
96     }
97
98     /**
99      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT
100      */

101     public void verifyGetUserTransaction() {
102         //Must throw an IllegalStateException
103
ctx.getUserTransaction();
104     }
105
106     /**
107      * @see org.objectweb.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextWS
108      */

109     public void verifyGetMessageContext() {
110         // TODO: Code
111

112     }
113
114 }
115
Popular Tags