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: SFSBOverrideTester00.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.xmldescriptor;
025:
026: import javax.ejb.EJB;
027: import javax.ejb.Remote;
028: import javax.ejb.Stateful;
029: import javax.naming.NamingException;
030: import javax.transaction.HeuristicMixedException;
031: import javax.transaction.HeuristicRollbackException;
032: import javax.transaction.NotSupportedException;
033: import javax.transaction.RollbackException;
034: import javax.transaction.SystemException;
035:
036: import org.ow2.easybeans.tests.common.exception.TransactionException;
037: import org.ow2.easybeans.tests.common.helper.EJBHelper;
038:
039: /**
040: * Verifies if the container overrides the annotation by the deployment
041: * descriptor.
042: * @author Gisele Pinheiro Souza
043: * @author Eduardo Studzinski Estima de Castro
044: */
045: @Stateful
046: @Remote(ItfOverrideTester00.class)
047: public class SFSBOverrideTester00 implements ItfOverrideTester00 {
048:
049: /**
050: * Bean injected by the ejb name defined in the deployment descriptor.
051: */
052: @EJB(beanName="SLSBSimpleBeanOverrideLocal")
053: private ItfSimpleBeanOverridedLocal bean1;
054:
055: /**
056: * Bean injected by the ejb name defined in the deployment descriptor.
057: */
058: @EJB(beanName="SLSBSimpleBeanOverrideLocal")
059: private ItfSimpleBeanOverridedRemote bean2;
060:
061: /**
062: * Verifies if the bean was injected correctly. The local interface is used.
063: */
064: public void testLocalInjection() {
065: bean1.toString();
066: }
067:
068: /**
069: * Verifies if the bean was injected correctly. The remote interface is
070: * used.
071: */
072: public void testRemoteInjection() {
073: bean2.toString();
074: }
075:
076: /**
077: * Verifies if the bean(with the local interface) can be obtained by the
078: * lookup.
079: * @throws Exception if a lookup error occurs.
080: */
081: public void testLookupLocal() throws Exception {
082: ItfSimpleBeanOverridedLocal bean = EJBHelper
083: .getBeanLocalInstance(SFSBSimpleBeanOverrided.class,
084: ItfSimpleBeanOverridedLocal.class);
085: bean.toString();
086: }
087:
088: /**
089: * Verifies if the bean(with the remote interface) can be obtained by the
090: * lookup.
091: * @throws Exception if a lookup error occurs.
092: */
093: public void testLookupRemote() throws Exception {
094: ItfSimpleBeanOverridedRemote bean = EJBHelper
095: .getBeanRemoteInstance(SFSBSimpleBeanOverrided.class,
096: ItfSimpleBeanOverridedRemote.class);
097: bean.toString();
098: }
099:
100: /**
101: * Verifies if the transaction type was overriden by the container. The bean
102: * has the transaction management defined as Container and the xml
103: * descriptor defines the transaction management as bean.
104: * @throws NamingException if a lookup error occurs.
105: * @throws SystemException if an unexpected error occurs.
106: * @throws NotSupportedException if the resquest cannot be made.
107: * @throws HeuristicRollbackException if a heuristic decision was made and
108: * some relevant update was rolled back.
109: * @throws RollbackException if the transaction was rolled back instead of
110: * committed.
111: * @throws HeuristicMixedException if a heuristic decision was made and some
112: * relevant update was commited and others rolled back.
113: * @throws TransactionException if a rollback was made.
114: */
115: public void testTransactionType() throws IllegalStateException,
116: SecurityException, HeuristicMixedException,
117: HeuristicRollbackException, RollbackException,
118: SystemException, NotSupportedException, NamingException {
119: bean1.verifyBMT();
120: bean2.verifyBMT();
121: }
122:
123: }
|