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: TestNeverException.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: * SFSBContainerTransactionNeverApp,
041: * SFSBContainerTransactionNeverRollback and
042: * SFSBContainerTransactionNeverRuntime must be deployed for
043: * testing stateful session bean. And, the bean
044: * SLSBContainerTransactionNeverApp,
045: * SLSBContainerTransactionNeverRollback and
046: * SLSBContainerTransactionNeverRuntime 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 TestNeverException 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 NOT_SUPPORTED. The attribute
059: * transaction NEVER does not has a transaction context, so there is not
060: * transaction to be managed.
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 testCallOtherBeanNotSup() throws Exception {
067: super .testCallOtherBeanNotSup();
068: verifyCallOtherBean();
069: }
070:
071: /**
072: * Verifies if the container does not use the same transaction when the
073: * other bean has the transaction attribute REQUIRED. The attribute
074: * transaction NEVER does not has a transaction context, so there is not
075: * transaction to be managed.
076: * @input -
077: * @output the method execution without error
078: * @throws Exception if an error during the tests occurs.
079: */
080: @Override
081: public void testCallOtherBeanReq() throws Exception {
082: super .testCallOtherBeanReq();
083: verifyCallOtherBean();
084: }
085:
086: /**
087: * Verifies if the container did not make a rollback. The transaction
088: * attribute never does not have a transaction context.
089: * @throws Exception if an error occurs.
090: */
091: private void verifyCallOtherBean() throws Exception {
092: // verifies if the transaction in the bean was rolled back.
093: try {
094: ExceptionHandleUtil.verifyTable(DATABASE_1,
095: ItfContainerTransaction.TABLE);
096: } catch (SQLException e) {
097: fail("The container made a rollback in the transaction.");
098: }
099: // verifies if the table in the second bean was destroyed. This table
100: // must not to be destroyed because the two beans are not using the same
101: // transaction.
102: try {
103: ExceptionHandleUtil.verifyTable(DATABASE_2,
104: ItfTransactionMisc00.TABLE);
105: } catch (SQLException e) {
106: fail("The container made a rollback in the transaction.");
107: }
108: }
109: }
|