KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestPersistenceLifetimeCMExtended00.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.BasePctxLifeCMETester00;
30 import org.objectweb.easybeans.tests.common.ejbs.base.persistencectxlife.ItfPCtxLifetime00;
31 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.persistencectxlife.SFSBPCtxLifeCME00;
32 import org.testng.annotations.AfterMethod;
33 import org.testng.annotations.BeforeMethod;
34 import org.testng.annotations.Test;
35
36 /**
37  * Tests container-managed extended-scoped persistence context. It uses this test class as client and a
38  * Stateful with extendended-scoped persistence context.
39  * @reference JSR 220 - Persistence API - FINAL DRAFT - 5.6.2
40  * @requirement Application Server must be running; the package
41  * org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.persistencectxlife
42  * must be deployed
43  * @setup gets the reference of the bean.
44  * @author Eduardo Studzinski Estima de Castro
45  * @author Gisele Pinheiro Souza
46  */

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

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

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

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

95     @Override JavaDoc
96     @Test
97     public void test02() throws Exception JavaDoc {
98         super.test02();
99     }
100
101     /**
102      * This test creates an entity and verifies if it remains managed.
103      * In this test, the transaction is created by the container for each bean method invocation,
104      * however, as it is an extended persistence context, it must remains managed.
105      * @input Without providing a client transaction, invocation of a bean method which creates an entity and persists it.
106      * @output A managed entity.
107      * @throws Exception if a problem occurs.
108      */

109     @Override JavaDoc
110     @Test
111     public void test03() throws Exception JavaDoc {
112         super.test03();
113     }
114
115     /**
116      * This test creates an entity, persists the entity and verifies if it remains managed.
117      * In this test, the transaction is created by the container for each bean method invocation,
118      * however, as it is an extended persistence context, it must remains managed.
119      * @input Without providing a client transaction, invocation of a bean method which creates an entity and persists it.
120      * @output A managed entity.
121      * @throws Exception if a problem occurs.
122      */

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

133     @Override JavaDoc
134     @AfterMethod
135     public void tearDown() throws Exception JavaDoc {
136         super.tearDown();
137     }
138 }
139
Popular Tags