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: TestSFBeanManagedSessionContextMethods00.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.sessionbean.stateful.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.stateful.beanmanaged.sessioncontext.SFSBBeanManagedSessionCtxMethods;
037: import org.testng.annotations.BeforeMethod;
038: import org.testng.annotations.Test;
039:
040: /**
041: * Verifies the SessionContext's method invocation. The tests for the methods
042: * isCallerPrincipal, isCallerInRole and getCallerIdentity are defined in the
043: * security package.
044: * @reference JSR 220-PROPOSED FINAL
045: * @requirement Application Server must be running; the beans
046: * org.ow2.easybeans.tests.common.ejbs.stateful.beanmanaged.sessioncontext.*
047: * must be deployed.
048: * @author Eduardo Studzinski Estima de Castro
049: * @author Gisele Pinheiro Souza
050: */
051: public class TestSFBeanManagedSessionContextMethods00 implements
052: ItfSessionContextBMT, ItfSessionContextCMT,
053: ItfSessionContextEJB3, ItfSessionContextTimer {
054:
055: /**
056: * Bean.
057: */
058: private ItfSessionContextBMT beanBMT;
059:
060: /**
061: * Bean.
062: */
063: private ItfSessionContextCMT beanCMT;
064:
065: /**
066: * Bean.
067: */
068: private ItfSessionContextEJB3 beanEJB3;
069:
070: /**
071: * Bean.
072: */
073: private ItfSessionContextTimer beanTimer;
074:
075: /**
076: * Gets bean instances used in the tests.
077: * @throws Exception if there is a problem with bean initialization.
078: */
079: @BeforeMethod
080: public void startUp() throws Exception {
081: beanBMT = getBeanRemoteInstance(
082: SFSBBeanManagedSessionCtxMethods.class,
083: ItfSessionContextBMT.class);
084: beanCMT = getBeanRemoteInstance(
085: SFSBBeanManagedSessionCtxMethods.class,
086: ItfSessionContextCMT.class);
087: beanEJB3 = getBeanRemoteInstance(
088: SFSBBeanManagedSessionCtxMethods.class,
089: ItfSessionContextEJB3.class);
090: beanTimer = getBeanRemoteInstance(
091: SFSBBeanManagedSessionCtxMethods.class,
092: ItfSessionContextTimer.class);
093: }
094:
095: /**
096: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT
097: * @input -
098: * @output -
099: */
100: @Test
101: public void verifyGetUserTransaction() {
102: beanBMT.verifyGetUserTransaction();
103: }
104:
105: /**
106: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
107: * @input -
108: * @output -
109: */
110: @Test
111: public void verifyGetBusinessObject() {
112: beanEJB3.verifyGetBusinessObject();
113: }
114:
115: /**
116: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
117: * @input -
118: * @output -
119: */
120: @Test
121: public void verifyGetInvokedBusinessInterface() {
122: beanEJB3.verifyGetInvokedBusinessInterface();
123: }
124:
125: /**
126: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
127: * @input -
128: * @output IllegalStateException encapsulated into an EJBException.
129: */
130: @Test
131: public void verifyGetTimerService() {
132: try {
133: beanTimer.verifyGetTimerService();
134: fail("The bean must throw an exception.");
135: } catch (EJBException e) {
136: checkCause(e, IllegalStateException.class);
137: }
138:
139: }
140:
141: /**
142: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
143: * @input -
144: * @output IllegalStateException encapsulated into an EJBException.
145: */
146: @Test
147: public void verifySetRollbackOnly() {
148: try {
149: beanCMT.verifySetRollbackOnly();
150: fail("The bean must throw an exception.");
151: } catch (EJBException e) {
152: checkCause(e, IllegalStateException.class);
153: }
154: }
155:
156: /**
157: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
158: * @input -
159: * @output IllegalStateException encapsulated into an EJBException.
160: */
161: @Test
162: public void verifyGetRollbackOnly() {
163: try {
164: beanCMT.verifyGetRollbackOnly();
165: fail("The bean must throw an exception.");
166: } catch (EJBException e) {
167: checkCause(e, IllegalStateException.class);
168: }
169: }
170:
171: }
|