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$
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.sessioncontext;
025:
026: import static org.testng.Assert.assertEquals;
027: import static org.testng.Assert.assertNotNull;
028: import static org.testng.Assert.assertTrue;
029:
030: import javax.annotation.Resource;
031: import javax.ejb.Remote;
032: import javax.ejb.SessionContext;
033: import javax.ejb.Stateless;
034:
035: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT;
036: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextCMT;
037: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3;
038: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer;
039: import org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextWS;
040:
041: /**
042: * This class is used to test SessionContext methods.
043: * @author Eduardo Studzinski Estima de Castro
044: * @author Gisele Pinheiro Souza
045: */
046: @Stateless(name="SLSBSessionCtxMethods")
047: @Remote({ItfSessionContextBMT.class,ItfSessionContextCMT.class,ItfSessionContextEJB3.class,ItfSessionContextTimer.class,ItfSessionContextWS.class})
048: public class SLSBSessionCtxMethods implements ItfSessionContextBMT,
049: ItfSessionContextCMT, ItfSessionContextEJB3,
050: ItfSessionContextTimer, ItfSessionContextWS {
051:
052: /**
053: * SessionContext.
054: */
055: @Resource
056: private SessionContext ctx;
057:
058: /**
059: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextCMT
060: */
061: public void verifySetRollbackOnly() {
062: ctx.setRollbackOnly();
063: assertTrue(ctx.getRollbackOnly(),
064: "The transaction should be marked to rollback.");
065: }
066:
067: /**
068: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextCMT
069: */
070: public void verifyGetRollbackOnly() {
071: this .verifySetRollbackOnly();
072: }
073:
074: /**
075: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
076: */
077: public void verifyGetBusinessObject() {
078: ItfSessionContextCMT bean = ctx
079: .getBusinessObject(ItfSessionContextCMT.class);
080: bean.verifyGetRollbackOnly();
081: }
082:
083: /**
084: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextEJB3
085: */
086: public void verifyGetInvokedBusinessInterface() {
087: Class cl = ctx.getInvokedBusinessInterface();
088: assertEquals(
089: cl,
090: ItfSessionContextEJB3.class,
091: "This method should return the "
092: + "interface ItfSessionContextEJB3, but returned "
093: + cl.getName());
094: }
095:
096: /**
097: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextTimer
098: */
099: public void verifyGetTimerService() {
100: assertNotNull(ctx.getTimerService(),
101: "The Timer should not be null.");
102: }
103:
104: /**
105: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextBMT
106: */
107: public void verifyGetUserTransaction() {
108: //Must throw an IllegalStateException
109: ctx.getUserTransaction();
110: }
111:
112: /**
113: * @see org.ow2.easybeans.tests.common.ejbs.base.sessioncontext.ItfSessionContextWS
114: */
115: public void verifyGetMessageContext() {
116: // TODO: Code
117:
118: }
119:
120: }
|