KickJava   Java API By Example, From Geeks To Geeks.

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


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: TestEJb2AnnotationRemote.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.ItfEjb2Client;
28 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.ejb2view.SFSBEjb2Client;
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 remote 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 SFSBEjb2Client
39  * and SFSBSimpleEjb2Bean must be deployed.
40  * @setup gets a reference of the bean SFSBEjb2Client.
41  * @author Gisele Pinheiro Souza
42  * @author Eduardo Studzinski Estima de Castro
43  */

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

49     private ItfEjb2Client 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(SFSBEjb2Client.class, ItfEjb2Client.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 testCreateWithDefaultName() throws Exception JavaDoc {
70         bean.createWithoutParameters();
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 testCreateWithAnnotationInit() throws Exception JavaDoc {
83         bean.createWithParameters();
84     }
85
86     /**
87      * Verifies if the client can get a bean by lookup.
88      * @input -
89      * @output the correct method execution.
90      * @throws Exception If an error occurs during the test.
91      */

92     @Test
93     public void testGetBeanByLookup() throws Exception JavaDoc {
94         bean.getBeanByLookup();
95     }
96
97     /**
98      * Verifies if the method isIdentical that is defined in the EJBObject
99      * interface.
100      * @input -
101      * @output the correct method execution.
102      * @throws Exception If an error occurs during the test.
103      */

104     @Test
105     public void testIsIdentical() throws Exception JavaDoc {
106         bean.verifyIdentity();
107     }
108
109     /**
110      * Verifies if the method remove from the interface EJBHome works.
111      * @input -
112      * @output the correct method execution.
113      * @throws Exception If an error occurs during the test.
114      */

115     @Test
116     public void testRemove() throws Exception JavaDoc {
117         bean.removeObject();
118     }
119
120     /**
121      * Verifies if the method getMetaData from the interface EJBHome works.
122      * @input -
123      * @output the correct method execution.
124      * @throws Exception If an error occurs during the test.
125      */

126     @Test
127     public void testMetadata() throws Exception JavaDoc {
128         bean.getEJBMetaData();
129     }
130
131     /**
132      * Verifies if the container throws RemoteException when a client tries to
133      * call getPrimaryKey().
134      * @input -
135      * @output the EJBException.
136      * @throws Exception If an error occurs during the test.
137      */

138     @Test
139     public void verifyGetPrimaryKey() throws Exception JavaDoc{
140         bean.verifyGetPrimaryKey();
141     }
142 }
143
Popular Tags