KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > environment > reference > ejb > TestEjbRefMessageDrivenBean


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: TestEjbRefMessageDrivenBean.java 951 2006-07-26 14:38:12Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.environment.reference.ejb;
26
27 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.ON_MESSAGE;
28 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_INJECTION_FIELD;
29 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_INJECTION_METHOD;
30 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_RESOURCES_DECLARATION;
31 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_RESOURCE_DECLARATION;
32 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.OVERRIDE_INJECTION_FIELD;
33 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.OVERRIDE_INJECTION_METHOD;
34 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_INJECTION_FIELD;
35 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_INJECTION_METHOD;
36 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_RESOURCE_DECLARATION;
37
38 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType;
39 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.ejbref.MDBEjbRef;
40 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.OperationChecker;
41 import org.objectweb.easybeans.tests.common.jms.JMSManager;
42 import org.testng.annotations.AfterClass;
43 import org.testng.annotations.BeforeClass;
44 import org.testng.annotations.BeforeMethod;
45 import org.testng.annotations.Test;
46
47
48 /**
49  * Tests ejb reference declaration and injection in Message-Driven beans.
50  * @reference JSR 220 - EJB 3.0 Core - 16.5
51  * @requirement MDBs:<li>org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.ejbref.MDBEjbRef</li>
52  * (Ant task: install.jar.tests.ejb.reference.messagedriven)
53  * @author Eduardo Studzinski Estima de Castro
54  * @author Gisele Pinheiro Souza
55  */

56 public class TestEjbRefMessageDrivenBean {
57
58     /**
59      * JMS Manager.
60      */

61     private JMSManager jmsQueue;
62
63     /**
64      * Log checker.
65      */

66     private OperationChecker checker;
67
68     /**
69      * Configure the test.
70      * @throws Exception if there is a problem.
71      */

72     @BeforeClass
73     public void startUp00() throws Exception JavaDoc {
74         //Creates the queue
75
jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
76         //Sends a message to run the test
77
jmsQueue.sendControlMessage(MDBEjbRef.MESSAGE_TYPE, OperationType.UNDEFINED);
78     }
79
80     /**
81      * Gets a bean logger reference.
82      * @throws Exception if there is a problem.
83      */

84     @BeforeMethod
85     public void startUp01() throws Exception JavaDoc {
86         checker = new OperationChecker();
87     }
88
89     /**
90      * Verifies declaration using annotation.
91      * @input a message
92      * @output a logged onMessage() event
93      * @throws Exception if a problem occurs.
94      */

95     @Test
96     public void test00() throws Exception JavaDoc {
97         checker.check(MDBEjbRef.class.getName(), ON_MESSAGE, ANNOTATION_RESOURCES_DECLARATION);
98     }
99
100     /**
101      * Verifies declaration using annotation.
102      * @input a message
103      * @output a logged onMessage() event
104      * @throws Exception if a problem occurs.
105      */

106     @Test
107     public void test01() throws Exception JavaDoc {
108         checker.check(MDBEjbRef.class.getName(), ON_MESSAGE, ANNOTATION_RESOURCE_DECLARATION);
109     }
110
111     /**
112      * Verifies declaration using XML.
113      * @input a message
114      * @output a logged onMessage() event
115      * @throws Exception if a problem occurs.
116      */

117     @Test
118     public void test02() throws Exception JavaDoc {
119         checker.check(MDBEjbRef.class.getName(), ON_MESSAGE, XML_RESOURCE_DECLARATION);
120     }
121
122     /**
123      * Verifies injection in a field using annotation.
124      * @input a message
125      * @output a logged onMessage() event
126      * @throws Exception if a problem occurs.
127      */

128     @Test
129     public void test03() throws Exception JavaDoc {
130         checker.check(MDBEjbRef.class.getName(), ON_MESSAGE, ANNOTATION_INJECTION_FIELD);
131     }
132
133     /**
134      * Verifies injection in a method using annotation.
135      * @input a message
136      * @output a logged onMessage() event
137      * @throws Exception if a problem occurs.
138      */

139     @Test
140     public void test04() throws Exception JavaDoc {
141         checker.check(MDBEjbRef.class.getName(), ON_MESSAGE, ANNOTATION_INJECTION_METHOD);
142     }
143
144     /**
145      * Verifies injection in a field using XML.
146      * @input a message
147      * @output a logged onMessage() event
148      * @throws Exception if a problem occurs.
149      */

150     @Test
151     public void test05() throws Exception JavaDoc {
152         checker.check(MDBEjbRef.class.getName(), ON_MESSAGE, XML_INJECTION_FIELD);
153     }
154
155     /**
156      * Verifies injection in a method using XML.
157      * @input a message
158      * @output a logged onMessage() event
159      * @throws Exception if a problem occurs.
160      */

161     @Test
162     public void test06() throws Exception JavaDoc {
163         checker.check(MDBEjbRef.class.getName(), ON_MESSAGE, XML_INJECTION_METHOD);
164     }
165
166     /**
167      * Verifies an injection override in a field with a XML.
168      * @input a message
169      * @output a logged onMessage() event
170      * @throws Exception if a problem occurs.
171      */

172     @Test
173     public void test07() throws Exception JavaDoc {
174         checker.check(MDBEjbRef.class.getName(), ON_MESSAGE, OVERRIDE_INJECTION_FIELD);
175     }
176
177     /**
178      * Verifies an injection override in a method with a XML.
179      * @input a message
180      * @output a logged onMessage() event
181      * @throws Exception if a problem occurs.
182      */

183     @Test
184     public void test08() throws Exception JavaDoc {
185         checker.check(MDBEjbRef.class.getName(), ON_MESSAGE, OVERRIDE_INJECTION_METHOD);
186     }
187
188     /**
189      * Clears logs.
190      * @throws Exception if a problem occurs.
191      */

192     @AfterClass
193     public void tearDownClass() throws Exception JavaDoc {
194         jmsQueue.close();
195         checker.deleteAll();
196     }
197 }
198
Popular Tags