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: TestNotSupportedException.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.transaction.containermanaged.base;
025:
026: import static org.testng.Assert.fail;
027:
028: import java.sql.SQLException;
029:
030: import org.ow2.easybeans.tests.common.ejbs.base.transaction.ItfContainerTransaction;
031: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.transaction.ItfTransactionMisc00;
032:
033: /**
034: * Verifies if the container-managed transaction in the session bean is
035: * following the JSR 220. The container must handle the different types of
036: * exception in the transaction context. The items covered in this test are:
037: * 13.3
038: * @reference JSR 220-PROPOSED FINAL
039: * @requirement Application Server must be running; the bean .
040: * SFSBContainerTransactionNotSupportedApp,
041: * SFSBContainerTransactionNotSupportedRollback and
042: * SFSBContainerTransactionNotSupportedRuntime must be deployed for
043: * testing stateful session bean. And, the bean
044: * SLSBContainerTransactionNotSupportedApp,
045: * SLSBContainerTransactionNotSupportedRollback and
046: * SLSBContainerTransactionNotSupportedRuntime must be deployed for
047: * testing stateless session bean.
048: * @setup gets the reference of the bean and binds the databases specified in
049: * the EmbeddedTest.
050: * @author Gisele Pinheiro Souza
051: * @author Eduardo Studzinski Estima de Castro
052: */
053: public abstract class TestNotSupportedException extends
054: TestContainerTransactionException {
055:
056: /**
057: * Verifies if the container does not use the same transaction when the
058: * other bean has the transaction attribute REQUIRED. The attribute
059: * transaction NOT_SUPPORTED does not has a transaction context, so there is not
060: * transaction to be managed.The method throws a runtime exception.
061: * @input -
062: * @output the method execution without error
063: * @throws Exception if an error during the tests occurs.
064: */
065: @Override
066: public void testCallOtherBeanReq() throws Exception {
067: super .testCallOtherBeanReq();
068: }
069:
070: /**
071: * Verifies if the container does not use the same transaction when the
072: * other bean has the transaction attribute NOT_SUPPORTED. The attribute
073: * transaction NOT_SUPPORTED does not has a transaction context, so there is not
074: * transaction to be managed.The method throws a runtime exception.
075: * @input -
076: * @output the method execution without error
077: * @throws Exception if an error during the tests occurs.
078: */
079: @Override
080: public void testCallOtherBeanNotSup() throws Exception {
081: super .testCallOtherBeanNotSup();
082: verifyCallOtherBean();
083: }
084:
085: /**
086: * Verifies if the container made the rollback. The transaction attribute is
087: * not_supports, so there is not transaction context.
088: * @throws Exception if an error occurs.
089: */
090: private void verifyCallOtherBean() throws Exception {
091: //verifies if the transaction in the bean was rolled back.
092: try {
093: ExceptionHandleUtil.verifyTable(DATABASE_1,
094: ItfContainerTransaction.TABLE);
095: } catch (SQLException e) {
096: fail("The container made a rollback in the transaction.");
097: }
098: // verifies if the table in the second bean was destroyed. This table
099: // must not to be destroyed because the two beans are not using the same
100: // transaction.
101: try {
102: ExceptionHandleUtil.verifyTable(DATABASE_2,
103: ItfTransactionMisc00.TABLE);
104: } catch (SQLException e) {
105: fail("The container made a rollback in the transaction.");
106: }
107: }
108:
109: }
|