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: TestPersistenceLifetimeCMTransaction00.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.persistence.lifetime;
025:
026: import static org.ow2.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
027:
028: import org.ow2.easybeans.tests.common.ejbs.base.persistencectxlife.BasePctxLifeCMTTester00;
029: import org.ow2.easybeans.tests.common.ejbs.base.persistencectxlife.ItfPCtxLifetime00;
030: import org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.persistencectxlife.SFSBPCtxLifeCMT00;
031: import org.testng.annotations.AfterMethod;
032: import org.testng.annotations.BeforeMethod;
033: import org.testng.annotations.Test;
034:
035: /**
036: * Tests container-managed transaction-scoped persistence context. It uses this test class as client and a
037: * Stateful with transaction-scoped persistence context.
038: * In this scope, the lifecycle of a persistence context ends when the associated transaction ends.
039: * @reference JSR 220 - Persistence API - FINAL DRAFT - 5.6.1
040: * @requirement Application Server must be running; the package
041: * org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.persistencectxlife
042: * must be deployed
043: * @setup gets the reference of the bean.
044: * @author Eduardo Studzinski Estima de Castro
045: * @author Gisele Pinheiro Souza
046: */
047: public class TestPersistenceLifetimeCMTransaction00 extends
048: BasePctxLifeCMTTester00 {
049:
050: /**
051: * Gets bean instances used in the tests.
052: * @throws Exception if there is a problem with the bean initialization.
053: */
054: @BeforeMethod
055: public void startUp() throws Exception {
056: ItfPCtxLifetime00 bean00 = getBeanRemoteInstance(
057: SFSBPCtxLifeCMT00.class, ItfPCtxLifetime00.class);
058: super .setBean(bean00);
059: }
060:
061: /**
062: * This test begins a transaction, creates an entity and rolls back the transaction.
063: * The entity must not exists after the rollback and the entity instance must become detached.
064: * A rollback in a transaction, which is used with the persistence context,
065: * always turns detached all entities associated with the persistence context.
066: * @input UserTransaction and entity.
067: * @output After the rollback, the bean must not exists.
068: * @throws Exception if a problem occurs.
069: */
070: @Override
071: @Test
072: public void test00() throws Exception {
073: super .test00();
074: }
075:
076: /**
077: * This test begins a transaction, creates an entity and commits the transaction. The entity must
078: * exists after the commit and it must become detached, because it is an transaction persistence context.
079: * @input With a client transaction, invocation of a bean method which creates an entity.
080: * @output After the commit, the bean must become detached.
081: * @throws Exception if a problem occurs.
082: */
083: @Override
084: @Test
085: public void test01() throws Exception {
086: super .test01();
087: }
088:
089: /**
090: * This test begins a transaction and creates an entity. As it uses an transaction
091: * persistence context and the transaction is still open,
092: * the entity remains managed after its creation. After this step,
093: * the test rolls back the transaction and the entity must be removed.
094: * @input With a client transaction, invocation of a bean method which creates an entity.
095: * @output The entity must be removed.
096: * @throws Exception if a problem occurs.
097: */
098: @Override
099: @Test
100: public void test02() throws Exception {
101: super .test02();
102: }
103:
104: /**
105: * Tests if an entity manager with a stateful can manage a
106: * transaction-scoped persistence context.
107: * @throws Exception if a problem occurs.
108: */
109: @Override
110: @Test
111: public void test03() throws Exception {
112: super .test03();
113: }
114:
115: /**
116: * Tests if an entity manager with a stateful can manage a
117: * transaction-scoped persistence context.
118: * @throws Exception if a problem occurs.
119: */
120: @Override
121: @Test
122: public void test04() throws Exception {
123: super .test04();
124: }
125:
126: /**
127: * Cleans the test results.
128: * @throws Exception if a problem occurs
129: */
130: @Override
131: @AfterMethod
132: public void tearDown() throws Exception {
133: super.tearDown();
134: }
135: }
|