KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > ejb2view > TestEjb2AnnotationLocal


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: TestEjb2AnnotationLocal.java 981 2006-07-28 14:16:22Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.ejb2view;
26
27 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.ejb2view.ItfEjb2LocalClient;
28 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.ejb2view.SFSBEjb2LocalClient;
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 the compatibility between the ejb 2.1 and the ejb 3.0. More
35  * specifically, it verifies if the access to the local home works properly.
36  * All interfaces are defined by annotation.
37  * @reference JSR 220-FINAL RELEASE
38  * @requirement Application Server must be running; the beans SFSBEjb2LocalClient
39  * and SFSBSimpleEjb2Bean must be deployed.
40  * @setup gets a reference of the bean SFSBEjb2LocalClient.
41  * @author Gisele Pinheiro Souza
42  * @author Eduardo Studzinski Estima de Castro
43  */

44 public class TestEjb2AnnotationLocal {
45
46     /**
47      * Bean that access the bean with ejb 2.1 remote view.
48      */

49     private ItfEjb2LocalClient bean;
50
51     /**
52      * Gets an instance of the bean.
53      * @throws Exception if an error occurs.
54      */

55     @BeforeMethod
56     public void setup() throws Exception JavaDoc {
57         // Gets a bean instance.
58
bean = EJBHelper.getBeanRemoteInstance(SFSBEjb2LocalClient.class, ItfEjb2LocalClient.class);
59     }
60
61     /**
62      * Tests if the definition of the create method as ejbCreate in the bean
63      * class works. The interface home here is goten by the annotation ejb.
64      * @input -
65      * @output the correct method execution.
66      * @throws Exception If an error occurs during the test.
67      */

68     @Test
69     public void verifyCreateWithDefaultName() throws Exception JavaDoc{
70         bean.createWithIntParameter();
71     }
72
73     /**
74      * Tests if the definition of the create method with the annotation init in
75      * the bean class works. The interface home here is goten by the annotation
76      * ejb.
77      * @input -
78      * @output the correct method execution.
79      * @throws Exception If an error occurs during the test.
80      */

81     @Test
82     public void verifyCreateWithAnnotationInit() throws Exception JavaDoc{
83         bean.createWithStrParameter();
84     }
85
86     /**
87      * Verifies if the method isIdentical that is defined in the EJBLocalObject
88      * interface.
89      * @input -
90      * @output the correct method execution.
91      * @throws Exception If an error occurs during the test.
92      */

93     @Test
94     public void verifyIsIdentical() throws Exception JavaDoc{
95         bean.verifyIdentity();
96     }
97
98     /**
99      * Verifies if the method remove from the interface EJBLocalHome works.
100      * @input -
101      * @output the correct method execution.
102      * @throws Exception If an error occurs during the test.
103      */

104     @Test
105     public void verifyRemove() throws Exception JavaDoc{
106         bean.removeObject();
107     }
108
109     /**
110      * Verifies if the client can get a bean by lookup.
111      * @input -
112      * @output the correct method execution.
113      * @throws Exception If an error occurs during the test.
114      */

115     @Test
116     public void verifyLookup() throws Exception JavaDoc{
117         bean.getBeanByLookup();
118     }
119
120     /**
121      * Verifies if the container throws EJBException when a client tries to
122      * call getPrimaryKey().
123      * @input -
124      * @output the EJBException.
125      * @throws Exception If an error occurs during the test.
126      */

127     @Test
128     public void verifyGetPrimaryKey() throws Exception JavaDoc{
129         bean.verifyGetPrimaryKey();
130     }
131 }
132
Popular Tags