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: ItfContainerTransaction.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.base.transaction;
025:
026: import org.ow2.easybeans.tests.common.exception.TransactionException;
027:
028: /**
029: * Inserts table in two database and uses the annotation @TransactionAttribute(REQUIRED) in all methods.
030: * @author Gisele Pinheiro Souza
031: * @author Eduardo Studzinski Estima de Castro
032: */
033: public interface ItfContainerTransaction {
034:
035: /**
036: * Table name used during the tests.
037: */
038: String TABLE = "test";
039:
040: /**
041: * Inserts the table test in the both database using a correct statement.
042: * @param db1 the name of the first database.
043: * @param db2 the name of the second database.
044: * @throws Exception if an error occurs.
045: */
046: void insertCorrectTableInBothDB(final String db1, final String db2)
047: throws Exception;
048:
049: /**
050: * Inserts the table test in the first database and makes an incorrect query
051: * in the second database. This incorrect query forces a roll back.
052: * @param db1 the name of the first database.
053: * @param db2 the name of the second database.
054: * @throws Exception if an error occurs.
055: */
056: void insertCorrectFirstErrorSecond(final String db1,
057: final String db2) throws Exception;
058:
059: /**
060: * Calls the method SessionContext.setRollbackOnly().
061: * @param dbName1 the first database where the table should be inserted.
062: * @param dbName2 the second database where the table should be inserted.
063: * @throws TransactionException if an IllegalStateException occurs.
064: * @throws Exception if an error occurs.
065: */
066: public void setRollbackOnly(final String dbName1,
067: final String dbName2) throws TransactionException,
068: Exception;
069:
070: /**
071: * Calls the method EJBContext.getRollbackOnly().
072: * @return true if the rollback only is set, false otherwise.
073: */
074: boolean getRollbackOnly() throws TransactionException;
075:
076: /**
077: * Inserts a table in the first database,calls an auxiliary bean to create a
078: * table in the second database and makes an exception to force a rollback
079: * if the transaction attribute supports. The auxiliary bean uses the
080: * transaction attribute REQUIRED.
081: * @param db1 the name of the first database.
082: * @param db2 the name of the second database
083: * @throws Exception if an error during the execution occurs.
084: */
085: void insertTablesUsingAuxBeanReq(final String db1, final String db2)
086: throws Exception;
087:
088: /**
089: * Inserts a table in the first database,calls an auxiliary bean to create a
090: * table in the second database and makes an exception to force a rollback
091: * if the transaction attribute supports. The auxiliary bean uses the
092: * transaction attribute NOT_SUPPORTED.
093: * @param db1 the name of the first database.
094: * @param db2 the name of the second database
095: * @throws Exception if an error during the execution occurs.
096: */
097: void insertTablesUsingAuxBeanNotSup(final String db1,
098: final String db2) throws Exception;
099:
100: /**
101: * Makes a lookup in the registry to get an UserTransaction.An exception
102: * must be throwed because the bean with container-managed transaction
103: * cannot call a bean-managed transaction.
104: * @throws Exception if an error occurs.
105: */
106: void getUserTransactionWithLookup() throws Exception;
107:
108: /**
109: * Call the method getUserTransaction() in the EJBContext to get an
110: * UserTransaction.An exception must be throwed because the bean with
111: * container-managed transaction cannot call a bean-managed transaction.
112: * @throws Exception if an error occurs.
113: */
114: void getUserTransactionWithEJBContext() throws Exception;
115:
116: }
|