KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > deploymentdesc > TestBasicElements


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: TestBasicElements.java 977 2006-07-28 13:18:26Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.deploymentdesc;
26
27 import org.objectweb.easybeans.tests.common.ejbs.base.xmldescriptor.ItfBasicBeanRemote;
28 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.xmldescriptor.ItfXmlDescriptorTester;
29 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.xmldescriptor.SFSBXmlDescriptorTester00;
30 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.xmldescriptor.SFSBXmlDescriptorTester01;
31 import org.objectweb.easybeans.tests.common.helper.EJBHelper;
32 import org.testng.annotations.BeforeMethod;
33 import org.testng.annotations.Test;
34
35 /**
36  * Verifies if the container can deploy an bean with the parameters defined in
37  * the deployment descriptor. The elements that are tested are the mappedName,
38  * ejb-name, local, remote and sesison type.
39  * @reference JSR 220 - FINAL RELEASE
40  * @requirement the bean SFSBXmlDescriptorTester must be deployed to make the
41  * tests, and, the BasicBean with the different deployment
42  * descriptors must be deployed too.
43  * @setup gets an instance of the SFSBXmlDescriptorTester.
44  * @author Gisele Pinheiro Souza
45  * @author Eduardo Studzinski Estima de Castro
46  */

47 public class TestBasicElements {
48
49     /**
50      * Bean used to verify the local access.
51      */

52     private ItfXmlDescriptorTester sfTester;
53
54     /**
55      * Bean used to verify the local access.
56      */

57     private ItfXmlDescriptorTester slTester;
58
59     /**
60      * Creates the stateful bean used during the tests.
61      * @throws Exception if an error occurs during the lookup.
62      */

63     @BeforeMethod
64     public void setup() throws Exception JavaDoc {
65         slTester = EJBHelper.getBeanRemoteInstance(SFSBXmlDescriptorTester00.class, ItfXmlDescriptorTester.class);
66         sfTester = EJBHelper.getBeanRemoteInstance(SFSBXmlDescriptorTester01.class, ItfXmlDescriptorTester.class);
67     }
68
69     /**
70      * Verifies if the bean can get an instance of a stateless bean by the
71      * mappedName.This test verifies the local interface.
72      * @input -
73      * @output the correct method execution.
74      * @throws Exception if an error occurs.
75      */

76     @Test
77     public void verifySLMappedName() throws Exception JavaDoc {
78         ItfBasicBeanRemote bean = EJBHelper.getBeanByMappedName("SLSBBasicBeanByXMLMappedRemote");
79         bean.toString();
80     }
81
82     /**
83      * Verifies if the bean can get an instance of a stateful bean by the
84      * mappedName.This test verifies the remote interface.
85      * @input -
86      * @output the correct method execution.
87      * @throws Exception if an error occurs.
88      */

89     @Test
90     public void verifySFMappedName() throws Exception JavaDoc {
91         ItfBasicBeanRemote bean = EJBHelper.getBeanByMappedName("SFSBBasicBeanByXMLMappedRemote");
92         bean.toString();
93     }
94
95     /**
96      * Verifies if the bean defined as stateless is deployed as a stateless. The
97      * bean class begins an userTransaction, but does not make the commit. So,
98      * if the bean is stateless the container must throw an EJBException.
99      * @input -
100      * @output an EJBException.
101      * @throws Exception if an error occurs.
102      */

103     @Test(dependsOnMethods = {"verifySLMappedName"}, expectedExceptions = javax.ejb.EJBException JavaDoc.class)
104     public void verifySLBeanTypeElement() throws Exception JavaDoc {
105         ItfBasicBeanRemote bean = EJBHelper.getBeanByMappedName("SLSBBasicBeanByXMLMappedRemote");
106         bean.openTransaction();
107     }
108
109     /**
110      * Verifies if the bean defined as stateful is deployed as a stateless. The
111      * bean class begins an userTransaction, but does not make the commit. So,
112      * if the bean is stateful the container must NOT throw any exception.
113      * @input -
114      * @output the correct method execution.
115      * @throws Exception if an error occurs.
116      */

117     @Test(dependsOnMethods = {"verifySFMappedName"})
118     public void verifySFBeanTypeElement() throws Exception JavaDoc {
119         ItfBasicBeanRemote bean = EJBHelper.getBeanByMappedName("SFSBBasicBeanByXMLMappedRemote");
120         bean.openTransaction();
121     }
122
123     /**
124      * Verifies if a bean can make a lookup in other bean(stateless) by the
125      * mappedName. This test verifies the local interface.
126      * @input -
127      * @output the correct method execution.
128      * @throws Exception if an error occurs.
129      */

130     @Test
131     public void verifySLMappedNameLocal() throws Exception JavaDoc {
132         slTester.verifyBeanMappedName();
133     }
134
135     /**
136      * Verifies if a bean can make a lookup in other bean(stateful) by the
137      * mappedName. This test verifies the local interface.
138      * @throws Exception
139      * @input -
140      * @output the correct method execution.
141      * @throws Exception if an error occurs.
142      */

143     @Test
144     public void verifySFMappedNameLocal() throws Exception JavaDoc {
145         sfTester.verifyBeanMappedName();
146     }
147
148     /**
149      * Verifies if the stateless bean is injected by the ejb-name.
150      * @input -
151      * @output an EJBException because the stateless bean begins a transaction
152      * without making a commit.
153      * @throws Exception if an error occurs.
154      */

155     @Test(expectedExceptions = javax.ejb.EJBException JavaDoc.class)
156     public void verifySLInjectionByEjbName() throws Exception JavaDoc{
157         slTester.verifyBeanTypeElement();
158     }
159
160     /**
161      * Verifies if the stateful bean is injected by the ejb-name.
162      * @input -
163      * @output the correct method execution.
164      * @throws Exception if an error occurs.
165      */

166     @Test(expectedExceptions = javax.ejb.EJBException JavaDoc.class)
167     public void verifySFInjectionByEjbName() throws Exception JavaDoc{
168         sfTester.verifyBeanTypeElement();
169     }
170
171 }
172
Popular Tags