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: TestCMTExceptions.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.ejb2view;
025:
026: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.ejb2view.ItfCMTEjb2ViewClient;
027: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.ejb2view.SLSBCMTEjb2ViewClient;
028: import org.ow2.easybeans.tests.common.helper.EJBHelper;
029: import org.testng.annotations.BeforeMethod;
030: import org.testng.annotations.Test;
031:
032: /**
033: * Verifies the compatibility between the ejb 2.1 and the ejb 3.0. More
034: * specifically, it verifies if the exceptions thrown when methods with
035: * different transaction attributes are called incorrectly. The items are 13.6.2.5 and 13.6.2.6.
036: * @reference JSR 220-FINAL RELEASE
037: * @requirement Application Server must be running; the beans
038: * SFSBCMTEjb2ViewClient and CMTEJb2ViewBean must be deployed.
039: * @setup gets a reference of the bean SFSBCMTEjb2ViewClient.
040: * @author Gisele Pinheiro Souza
041: * @author Eduardo Studzinski Estima de Castro
042: */
043: public class TestCMTExceptions {
044:
045: /**
046: * Bean that access the bean with ejb 2.1 remote view.
047: */
048: private ItfCMTEjb2ViewClient bean;
049:
050: /**
051: * Gets an instance of the bean.
052: * @throws Exception if an error occurs.
053: */
054: @BeforeMethod
055: public void setup() throws Exception {
056: // Gets a bean instance.
057: bean = EJBHelper
058: .getBeanRemoteInstance(SLSBCMTEjb2ViewClient.class,
059: ItfCMTEjb2ViewClient.class);
060: }
061:
062: /**
063: * Verifies if the client with a ejb 2.1 local view receives the correct
064: * exception when a method with Transaction Attribute Mandatory is called
065: * without transaction context. The expected exception is
066: * TransactionRequiredLocalException.
067: * @input -
068: * @output the correct method execution.
069: * @throws Exception if some error occurs during the test.
070: */
071: @Test
072: public void verifyMandatoryLocalException() throws Exception {
073: bean.testLocalMandatoryException();
074: }
075:
076: /**
077: * Verifies if the client with a ejb 2.1 remote view receives the correct
078: * exception when a method with Transaction Attribute Mandatory is called
079: * without transaction context. The expected exception is
080: * TransactionRequiredException.
081: * @input -
082: * @output the correct method execution.
083: * @throws Exception if some error occurs during the test.
084: */
085: @Test
086: public void verifyMandatoryRemoteException() throws Exception {
087: bean.testRemoteMandatoryException();
088: }
089:
090: /**
091: * Verifies if the client with a ejb 2.1 local view receives the correct
092: * exception when a method with Transaction Attribute Never is called
093: * with transaction context. The expected exception is
094: * EJBException.
095: * @input -
096: * @output the correct method execution.
097: * @throws Exception if some error occurs during the test.
098: */
099: @Test
100: public void verifyNeverLocalException() throws Exception {
101: bean.testLocalNeverException();
102: }
103:
104: /**
105: * Verifies if the client with a ejb 2.1 never view receives the correct
106: * exception when a method with Transaction Attribute Never is called
107: * with transaction context. The expected exception is
108: * RemoteException.
109: * @input -
110: * @output the correct method execution.
111: * @throws Exception if some error occurs during the test.
112: */
113: @Test
114: public void verifyNeverRemoteException() throws Exception {
115: bean.testRemoteNeverException();
116: }
117:
118: /**
119: * Verifies if the method isIdentical works.
120: * @input -
121: * @output the correct method execution.
122: * @throws Exception if some error occurs during the test.
123: */
124: @Test
125: public void testIdentity() throws Exception {
126: bean.testIdentity();
127: }
128: }
|