KickJava   Java API By Example, From Geeks To Geeks.

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


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: SLSBSessionBeanTester.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.assertEquals;
28
29 import javax.ejb.EJB JavaDoc;
30 import javax.ejb.Remote JavaDoc;
31 import javax.ejb.Stateless JavaDoc;
32
33 import org.objectweb.easybeans.tests.common.ejbs.base.ItfSimplePrintMessage;
34 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.basic.SFSBDeployTest;
35 import org.objectweb.easybeans.tests.common.helper.EJBHelper;
36
37 /**
38  * Verfifies if a bean that was defined only with the annotation remote without
39  * parameters works well.
40  * @author Gisele Pinheiro Souza
41  * @author Eduardo Studzinski Estima de Castro
42  */

43 @Stateless JavaDoc
44 @Remote JavaDoc
45 public class SLSBSessionBeanTester implements ItfSessionBeanTester {
46
47     /**
48      * Simple stateless bean.
49      */

50     @EJB JavaDoc(beanName = "SLSBDeployTest")
51     private ItfSimplePrintMessage slsbBean1;
52
53     /**
54      * Simple stateful bean.
55      */

56     @EJB JavaDoc(beanName = "SFSBDeployTest")
57     private ItfSimplePrintMessage sfsbBean1;
58
59     /**
60      * Calls the method getDefaultMessage() of the stateless bean that was
61      * injected.
62      */

63     public void testSLSBByInjection() {
64         assertEquals(slsbBean1.getDefaultMessage(), ItfSimplePrintMessage.DEFAULT_MESSAGE,
65                 "The bean with the remote interface did not returned the default message.");
66     }
67
68     /**
69      * Calls the method getDefaultMessage() of the stateless bean that was goten
70      * by lookup.
71      * @throws Exception if a lokkup error occurs.
72      */

73     public void testSLSBByLookup() throws Exception JavaDoc {
74         ItfSimplePrintMessage slsbBean2 = EJBHelper.getBeanRemoteInstance(SLSBDeployTest.class,
75                 ItfSimplePrintMessage.class);
76         assertEquals(slsbBean2.getDefaultMessage(), ItfSimplePrintMessage.DEFAULT_MESSAGE,
77                 "The bean with the remote interface did not returned the default message.");
78     }
79
80     /**
81      * Calls the method getDefaultMessage() of the stateful bean that was
82      * injected.
83      */

84     public void testSFSBByInjection() {
85         assertEquals(sfsbBean1.getDefaultMessage(), ItfSimplePrintMessage.DEFAULT_MESSAGE,
86                 "The bean with the remote interface did not returned the default message.");
87     }
88
89     /**
90      * Calls the method getDefaultMessage() of the stateful bean that was goten
91      * by lookup.
92      * @throws Exception if a lokkup error occurs.
93      */

94     public void testSFSBByLookup() throws Exception JavaDoc {
95         ItfSimplePrintMessage sfsbBean2 = EJBHelper.getBeanRemoteInstance(SFSBDeployTest.class,
96                 ItfSimplePrintMessage.class);
97         assertEquals(sfsbBean2.getDefaultMessage(), ItfSimplePrintMessage.DEFAULT_MESSAGE,
98                 "The bean with the remote interface did not returned the default message.");
99     }
100
101 }
102
Popular Tags