KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > persistence > lifetime > TestPersistenceLifetimeCMTransaction00


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: TestPersistenceLifetimeCMTransaction00.java 979 2006-07-28 13:19:50Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.persistence.lifetime;
26
27 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
28
29 import org.objectweb.easybeans.tests.common.ejbs.base.persistencectxlife.BasePctxLifeCMTTester00;
30 import org.objectweb.easybeans.tests.common.ejbs.base.persistencectxlife.ItfPCtxLifetime00;
31 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.persistencectxlife.SFSBPCtxLifeCMT00;
32 import org.testng.annotations.AfterMethod;
33 import org.testng.annotations.BeforeMethod;
34 import org.testng.annotations.Test;
35
36 /**
37  * Tests container-managed transaction-scoped persistence context. It uses this test class as client and a
38  * Stateful with transaction-scoped persistence context.
39  * In this scope, the lifecycle of a persistence context ends when the associated transaction ends.
40  * @reference JSR 220 - Persistence API - FINAL DRAFT - 5.6.1
41  * @requirement Application Server must be running; the package
42  * org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.persistencectxlife
43  * must be deployed
44  * @setup gets the reference of the bean.
45  * @author Eduardo Studzinski Estima de Castro
46  * @author Gisele Pinheiro Souza
47  */

48 public class TestPersistenceLifetimeCMTransaction00 extends BasePctxLifeCMTTester00{
49
50     /**
51      * Gets bean instances used in the tests.
52      * @throws Exception if there is a problem with the bean initialization.
53      */

54     @BeforeMethod
55     public void startUp() throws Exception JavaDoc {
56         ItfPCtxLifetime00 bean00 = getBeanRemoteInstance(SFSBPCtxLifeCMT00.class, ItfPCtxLifetime00.class);
57         super.setBean(bean00);
58     }
59
60     /**
61      * This test begins a transaction, creates an entity and rolls back the transaction.
62      * The entity must not exists after the rollback and the entity instance must become detached.
63      * A rollback in a transaction, which is used with the persistence context,
64      * always turns detached all entities associated with the persistence context.
65      * @input UserTransaction and entity.
66      * @output After the rollback, the bean must not exists.
67      * @throws Exception if a problem occurs.
68      */

69     @Override JavaDoc
70     @Test
71     public void test00() throws Exception JavaDoc {
72         super.test00();
73     }
74
75     /**
76      * This test begins a transaction, creates an entity and commits the transaction. The entity must
77      * exists after the commit and it must become detached, because it is an transaction persistence context.
78      * @input With a client transaction, invocation of a bean method which creates an entity.
79      * @output After the commit, the bean must become detached.
80      * @throws Exception if a problem occurs.
81      */

82     @Override JavaDoc
83     @Test
84     public void test01() throws Exception JavaDoc {
85         super.test01();
86     }
87
88     /**
89      * This test begins a transaction and creates an entity. As it uses an transaction
90      * persistence context and the transaction is still open,
91      * the entity remains managed after its creation. After this step,
92      * the test rolls back the transaction and the entity must be removed.
93      * @input With a client transaction, invocation of a bean method which creates an entity.
94      * @output The entity must be removed.
95      * @throws Exception if a problem occurs.
96      */

97     @Override JavaDoc
98     @Test
99     public void test02() throws Exception JavaDoc {
100         super.test02();
101     }
102
103     /**
104      * Tests if an entity manager with a stateful can manage a
105      * transaction-scoped persistence context.
106      * @throws Exception if a problem occurs.
107      */

108     @Override JavaDoc
109     @Test
110     public void test03() throws Exception JavaDoc {
111         super.test03();
112     }
113
114     /**
115      * Tests if an entity manager with a stateful can manage a
116      * transaction-scoped persistence context.
117      * @throws Exception if a problem occurs.
118      */

119     @Override JavaDoc
120     @Test
121     public void test04() throws Exception JavaDoc {
122         super.test04();
123     }
124
125     /**
126      * Cleans the test results.
127      * @throws Exception if a problem occurs
128      */

129     @Override JavaDoc
130     @AfterMethod
131     public void tearDown() throws Exception JavaDoc {
132         super.tearDown();
133     }
134 }
135
Popular Tags