KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestEntityManager01.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.ItfEntityManagerTester01;
28 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.entitymanager.SLSBEntityManagerTester01;
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 methods remove and persist from EntityManager are working
35  * properly. The items 3.2.1 e 3.2.2 (Persistence doc)
36  * @reference JSR 220-PROPOSED FINAL
37  * @requirement Application Server must be running; the bean
38  * SLSBEntityManagerTester must be deployed.
39  * @setup gets the reference of SLSBEntityManagerTester
40  * @author Gisele Pinheiro Souza
41  * @author Eduardo Studzinski Estima de Castro
42  */

43 public class TestEntityManager01 {
44
45     /**
46      * The entity bean primary key that is used during the tests.
47      */

48     public static final int PRIMARY_KEY = 1;
49
50     /**
51      * The entity bean name that is used during the tests.
52      */

53     public static final String JavaDoc ENTITY_NAME = "test";
54
55     /**
56      * The entity bean alternative name that is used during the tests.
57      */

58     public static final String JavaDoc ALTERNATIVE_ENTITY_NAME = "test2";
59
60     /**
61      * The stateless bean used to verify the EntityManager.
62      */

63     private ItfEntityManagerTester01 slsbEntityManagerTester01;
64
65     /**
66      * Creates the stateless bean used during the tests.
67      * @throws Exception if an error occurs during the lookup.
68      */

69     @BeforeMethod
70     public void setup() throws Exception JavaDoc {
71         slsbEntityManagerTester01 = EJBHelper.getBeanRemoteInstance(SLSBEntityManagerTester01.class,
72                 ItfEntityManagerTester01.class);
73         slsbEntityManagerTester01.removeEBStore(PRIMARY_KEY);
74     }
75
76     /**
77      * Tests if the EntityManager can make a merge with a detached entity.
78      * @input PRIMARY_KEY,ENTITY_NAME and ALTERNATIVE_ENTITY_NAME.
79      * @output the method execution without error.
80      */

81     @Test
82     public void testMerge() {
83         slsbEntityManagerTester01.mergeEBStore(PRIMARY_KEY, ENTITY_NAME, ALTERNATIVE_ENTITY_NAME);
84     }
85
86     /**
87      * Tests if the EntityManager can make a refresh.
88      * @input PRIMARY_KEY,ENTITY_NAME and ALTERNATIVE_ENTITY_NAME.
89      * @output the method execution without error.
90      */

91     @Test
92     public void testRefresh() {
93         slsbEntityManagerTester01.refreshEBStore(PRIMARY_KEY, ENTITY_NAME, ALTERNATIVE_ENTITY_NAME);
94     }
95
96     /**
97      * Tests if the contains method in the EntityManager works well.
98      * @input PRIMARY_KEY and ENTITY_NAME.
99      * @output the method execution without error.
100      */

101     @Test
102     public void testContains() {
103         slsbEntityManagerTester01.containsEBStore(PRIMARY_KEY, ENTITY_NAME);
104     }
105
106 }
107
Popular Tags