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