KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > entity > TestEntityManager02


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: TestEntityManager02.java 977 2006-07-28 13:18:26Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.entity;
26
27 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.entitymanager.ItfTransactionContextTester;
28 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.entitymanager.SLSBTransactionContextTester;
29 import org.objectweb.easybeans.tests.common.helper.EJBHelper;
30 import org.testng.annotations.BeforeMethod;
31 import org.testng.annotations.Test;
32
33 /**
34  * Verifies if the entity manager works well among different trasnactions.
35  * @reference JSR 220-PROPOSED FINAL
36  * @requirement Application Server must be running; the bean
37  * SLSBTransactionContextTester and the entity EBStore must be deployed.
38  * @setup gets the reference of SLSBTransactionContextTester
39  * @author Gisele Pinheiro Souza
40  * @author Eduardo Studzinski Estima de Castro
41  */

42 public class TestEntityManager02 {
43
44     /**
45      * The stateless bean used to verify the EntityManager.
46      */

47     private ItfTransactionContextTester tester;
48
49     /**
50      * Creates the stateless bean used during the tests.
51      * @throws Exception if an error occurs during the lookup.
52      */

53     @BeforeMethod
54     public void setup() throws Exception JavaDoc {
55         tester = EJBHelper.getBeanRemoteInstance(SLSBTransactionContextTester.class, ItfTransactionContextTester.class);
56
57     }
58
59     /**
60      * The entity bean is instanciated in a method and the
61      * EntityManager.persist() is made in other method. The both methods are
62      * using the same transaction.
63      * @input -
64      * @output the bean must be persisted without error.
65      */

66     @Test
67     public void testRequired() {
68         tester.createBeanRequired();
69     }
70
71     /**
72      * The entity bean is instanciated in a method and the
73      * EntityManager.persist() is made in other method. The methods are not
74      * using the same transaction, so the transaction of the first method is
75      * resume, and other transaction is created before the entity manager makes the persist.
76      * @input -
77      * @output the bean must be persisted without error.
78      */

79     @Test
80     public void testRequiresNew() {
81         tester.createBeanRequiresNewWithClientTransaction();
82     }
83
84     /**
85      * The entity bean is instanciated in a method and the
86      * EntityManager.persist() is made in other method. The first method has not
87      * transaction and the second method creates a trasnaction before the entity
88      * manager makes the persist.
89      * @input -
90      * @output the bean must be persisted without error.
91      */

92     @Test
93     public void testNotSupported() {
94         tester.createBeanRequiresNewWithoutClientTransaction();
95     }
96
97 }
98
Popular Tags