001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: TestSLSessionContextMethods00.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.sessionbean.stateless.context;
025:
026: import static org.ow2.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
027: import static org.ow2.easybeans.tests.common.helper.ExceptionHelper.checkCause;
028: import static org.testng.Assert.fail;
029:
030: import javax.ejb.EJBException;
031:
032: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT;
033: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextCMT;
034: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3;
035: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer;
036: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextWS;
037: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.sessioncontext.SLSBSessionCtxMethods;
038: import org.testng.annotations.BeforeMethod;
039: import org.testng.annotations.Test;
040:
041: /**
042: * Verifies the SessionContext's method invocation.The tests for the methods
043: * isCallerPrincipal, isCallerInRole and getCallerIdentity are defined in the
044: * security package.
045: * @reference JSR 220-PROPOSED FINAL
046: * @requirement Application Server must be running; the beans
047: * org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.sessioncontext.*
048: * must be deployed.
049: * @author Eduardo Studzinski Estima de Castro
050: * @author Gisele Pinheiro Souza
051: */
052: public class TestSLSessionContextMethods00 implements
053: ItfSessionContextBMT, ItfSessionContextCMT,
054: ItfSessionContextEJB3, ItfSessionContextTimer,
055: ItfSessionContextWS {
056:
057: /**
058: * Bean.
059: */
060: private ItfSessionContextBMT beanBMT;
061:
062: /**
063: * Bean.
064: */
065: private ItfSessionContextCMT beanCMT;
066:
067: /**
068: * Bean.
069: */
070: private ItfSessionContextEJB3 beanEJB3;
071:
072: /**
073: * Bean.
074: */
075: private ItfSessionContextTimer beanTimer;
076:
077: /**
078: * Bean.
079: */
080: private ItfSessionContextWS beanWS;
081:
082: /**
083: * Gets bean instances used in the tests.
084: * @throws Exception if there is a problem with bean initialization.
085: */
086: @BeforeMethod
087: public void startUp() throws Exception {
088: beanBMT = getBeanRemoteInstance(SLSBSessionCtxMethods.class,
089: ItfSessionContextBMT.class);
090: beanCMT = getBeanRemoteInstance(SLSBSessionCtxMethods.class,
091: ItfSessionContextCMT.class);
092: beanEJB3 = getBeanRemoteInstance(SLSBSessionCtxMethods.class,
093: ItfSessionContextEJB3.class);
094: beanTimer = getBeanRemoteInstance(SLSBSessionCtxMethods.class,
095: ItfSessionContextTimer.class);
096: // beanWS = getBeanRemoteInstance(SLSBSessionCtxMethods.class, ItfSessionContextWS.class);
097: }
098:
099: /**
100: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT
101: * @input -
102: * @output IllegalStateException encapsulated into an EJBException.
103: */
104: @Test
105: public void verifyGetUserTransaction() {
106: try {
107: beanBMT.verifyGetUserTransaction();
108: fail("The bean must throw an exception.");
109: } catch (EJBException e) {
110: checkCause(e, IllegalStateException.class);
111: }
112: }
113:
114: /**
115: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
116: * @input -
117: * @output -
118: */
119: @Test
120: public void verifyGetBusinessObject() {
121: beanEJB3.verifyGetBusinessObject();
122: }
123:
124: /**
125: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
126: * @input -
127: * @output -
128: */
129: @Test
130: public void verifyGetInvokedBusinessInterface() {
131: beanEJB3.verifyGetInvokedBusinessInterface();
132: }
133:
134: /**
135: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
136: * @input -
137: * @output -
138: */
139: @Test
140: public void verifyGetTimerService() {
141: beanTimer.verifyGetTimerService();
142: }
143:
144: /**
145: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
146: * @input -
147: * @output -
148: */
149: @Test
150: public void verifySetRollbackOnly() {
151: beanCMT.verifySetRollbackOnly();
152: }
153:
154: /**
155: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
156: * @input -
157: * @output -
158: */
159: @Test
160: public void verifyGetRollbackOnly() {
161: beanCMT.verifyGetRollbackOnly();
162: }
163:
164: /**
165: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
166: * @input -
167: * @output -
168: */
169: // @Test
170: public void verifyGetMessageContext() {
171: // TODO: implement
172: }
173:
174: }
|