01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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 1970 2007-10-16 11:49:25Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.tests.entity;
25:
26: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.entitymanager.ItfTransactionContextTester;
27: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.entitymanager.SLSBTransactionContextTester;
28: import org.ow2.easybeans.tests.common.helper.EJBHelper;
29: import org.testng.annotations.BeforeMethod;
30: import org.testng.annotations.Test;
31:
32: /**
33: * Verifies if the entity manager works well among different trasnactions.
34: * @reference JSR 220-PROPOSED FINAL
35: * @requirement Application Server must be running; the bean
36: * SLSBTransactionContextTester and the entity EBStore must be deployed.
37: * @setup gets the reference of SLSBTransactionContextTester
38: * @author Gisele Pinheiro Souza
39: * @author Eduardo Studzinski Estima de Castro
40: */
41: public class TestEntityManager02 {
42:
43: /**
44: * The stateless bean used to verify the EntityManager.
45: */
46: private ItfTransactionContextTester tester;
47:
48: /**
49: * Creates the stateless bean used during the tests.
50: * @throws Exception if an error occurs during the lookup.
51: */
52: @BeforeMethod
53: public void setup() throws Exception {
54: tester = EJBHelper.getBeanRemoteInstance(
55: SLSBTransactionContextTester.class,
56: ItfTransactionContextTester.class);
57:
58: }
59:
60: /**
61: * The entity bean is instanciated in a method and the
62: * EntityManager.persist() is made in other method. The both methods are
63: * using the same transaction.
64: * @input -
65: * @output the bean must be persisted without error.
66: */
67: @Test
68: public void testRequired() {
69: tester.createBeanRequired();
70: }
71:
72: /**
73: * The entity bean is instanciated in a method and the
74: * EntityManager.persist() is made in other method. The methods are not
75: * using the same transaction, so the transaction of the first method is
76: * resume, and other transaction is created before the entity manager makes the persist.
77: * @input -
78: * @output the bean must be persisted without error.
79: */
80: @Test
81: public void testRequiresNew() {
82: tester.createBeanRequiresNewWithClientTransaction();
83: }
84:
85: /**
86: * The entity bean is instanciated in a method and the
87: * EntityManager.persist() is made in other method. The first method has not
88: * transaction and the second method creates a trasnaction before the entity
89: * manager makes the persist.
90: * @input -
91: * @output the bean must be persisted without error.
92: */
93: @Test
94: public void testNotSupported() {
95: tester.createBeanRequiresNewWithoutClientTransaction();
96: }
97:
98: }
|