KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateless > containermanaged > basic > SLSBSessionObjectIdentity


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: SLSBSessionObjectIdentity.java 878 2006-07-17 09:14:42Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.basic;
26
27 import static org.testng.Assert.assertFalse;
28 import static org.testng.Assert.assertTrue;
29
30 import javax.ejb.EJB JavaDoc;
31 import javax.ejb.Remote JavaDoc;
32 import javax.ejb.Stateless JavaDoc;
33
34 import org.objectweb.easybeans.tests.common.ejbs.base.ItfSimplePrintMessage;
35 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.basic.SFSBDeployTest;
36 import org.objectweb.easybeans.tests.common.helper.EJBHelper;
37
38
39 /**
40  * Verifies the identity test for stateful and stateless beans.
41  * @author Gisele Pinheiro Souza
42  * @author Eduardo Studzinski Estima de Castro
43  *
44  */

45 @Stateless JavaDoc
46 @Remote JavaDoc
47 public class SLSBSessionObjectIdentity implements ItfSessionObjectIdentity {
48
49     /**
50      * Simple stateless bean.
51      */

52     @EJB JavaDoc(beanName = "SLSBDeployTest")
53     private ItfSimplePrintMessage slsbBean1;
54
55     /**
56      * Simple stateless bean.
57      */

58     @EJB JavaDoc(beanName = "SLSBDeployTest")
59     private ItfSimplePrintMessage slsbBean2;
60
61     /**
62      * Simple stateful bean.
63      */

64     @EJB JavaDoc(beanName = "SFSBDeployTest")
65     private ItfSimplePrintMessage sfsbBean1;
66
67     /**
68      * Simple stateful bean.
69      */

70     @EJB JavaDoc(beanName = "SFSBDeployTest")
71     private ItfSimplePrintMessage sfsbBean2;
72
73     /**
74      * Verifies if the method equals of a stateless bean returns true when the
75      * bean is compared with itself. Example bean1.equals(bean1). The beans in
76      * this test were injected by annotation.
77      */

78     public void testSLSameInstanceIdentityInjected() {
79         assertTrue(slsbBean1.equals(slsbBean1), "The stateless bean is not equal to itself.");
80     }
81
82     /**
83      * Verifies if the method equals of a stateless bean returns true when the
84      * bean is compared with other bean that has the same name. Example
85      * bean1.equals(bean2).The beans in this test were injected by annotation.
86      */

87     public void testSLDifferentInstanceIdentityInjected() {
88         assertTrue(slsbBean1.equals(slsbBean2),
89                 "The stateless bean is not equal to other stateless with the same name.");
90     }
91
92     /**
93      * Verifies if the method equals of a stateful bean returns true when the
94      * bean is compared with itself. Example bean1.equals(bean1). The beans in
95      * this test were injected by annotation.
96      */

97     public void testSFSameInstanceIdentityInjected() {
98         assertTrue(sfsbBean1.equals(sfsbBean1), "The stateful bean is not equal to itself.");
99     }
100
101     /**
102      * Verifies if the method equals of a stateful bean returns false when the
103      * bean is compared with other bean that has the same name. Example bean1.equals(bean2). The beans in
104      * this test were injected by annotation.
105      */

106     public void testSFDifferentInstanceIdentityInjected() {
107         assertFalse(sfsbBean1.equals(sfsbBean2), "The stateful bean is equal to other stateful with the same name.");
108     }
109
110     /**
111      * Verifies if the method equals of a stateless bean returns true when the
112      * bean is compared with itself. Example bean1.equals(bean1). The beans in
113      * this test were goten by a lookup.
114      * @throws Exception if a lookup error occurs.
115      */

116     public void testSLSameInstanceIdentityLookup() throws Exception JavaDoc {
117         ItfSimplePrintMessage bean1 = EJBHelper
118                 .getBeanRemoteInstance(SLSBDeployTest.class, ItfSimplePrintMessage.class);
119         assertTrue(bean1.equals(bean1), "The stateless bean is not equal to itself.");
120     }
121
122     /**
123      * Verifies if the method equals of a stateless bean returns true when the
124      * bean is compared with other bean that has the same name. Example bean1.equals(bean2). The beans in
125      * this test were goten by a lookup.
126      * @throws Exception if a lookup error occurs.
127      */

128     public void testSLDifferentInstanceIdentityLookup() throws Exception JavaDoc {
129         ItfSimplePrintMessage bean1 = EJBHelper
130                 .getBeanRemoteInstance(SLSBDeployTest.class, ItfSimplePrintMessage.class);
131         ItfSimplePrintMessage bean2 = EJBHelper
132                 .getBeanRemoteInstance(SLSBDeployTest.class, ItfSimplePrintMessage.class);
133         assertTrue(bean1.equals(bean2), "The stateless bean is not equal to other stateless with the same name.");
134     }
135
136     /**
137      * Verifies if the method equals of a stateful bean returns true when the
138      * bean is compared with itself. Example bean1.equals(bean1). The beans in
139      * this test were goten by a lookup.
140      * @throws Exception if a lookup error occurs.
141      */

142     public void testSFSameInstanceIdentityLookup() throws Exception JavaDoc {
143         ItfSimplePrintMessage bean1 = EJBHelper
144                 .getBeanRemoteInstance(SFSBDeployTest.class, ItfSimplePrintMessage.class);
145         assertTrue(bean1.equals(bean1), "The stateful bean is not equal to itself.");
146     }
147
148     /**
149      * Verifies if the method equals of a stateful bean returns false when the
150      * bean is compared with other bean that has the same name. Example bean1.equals(bean2). The beans in
151      * this test were goten by a lookup.
152      * @throws Exception if a lookup error occurs.
153      */

154     public void testSFDifferentInstanceIdentityLookup() throws Exception JavaDoc {
155         ItfSimplePrintMessage bean1 = EJBHelper
156                 .getBeanRemoteInstance(SFSBDeployTest.class, ItfSimplePrintMessage.class);
157         ItfSimplePrintMessage bean2 = EJBHelper
158                 .getBeanRemoteInstance(SFSBDeployTest.class, ItfSimplePrintMessage.class);
159         assertFalse(bean1.equals(bean2), "The stateful bean is equal to other stateful with the same name.");
160     }
161
162 }
163
Popular Tags