KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > messagedriven > containermanaged > access > TestMDBListenerMethodAccess


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: TestMDBListenerMethodAccess.java 649 2006-06-13 12:52:04Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.messagedriven.containermanaged.access;
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.ENTERPRISE_BEAN;
29 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ENTITY_MANAGER;
30 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ENTITY_MANAGER_FACTORY;
31 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.RESOURCE_MANAGER;
32 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.TIMER;
33 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.USER_TRANSACTION;
34
35 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.access.MDBListenerMethodAccess;
36 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.OperationChecker;
37 import org.objectweb.easybeans.tests.common.jms.JMSManager;
38 import org.testng.annotations.AfterClass;
39 import org.testng.annotations.AfterMethod;
40 import org.testng.annotations.BeforeClass;
41 import org.testng.annotations.Test;
42
43 /**
44  * Verifies if a message listener method can perform the operations allowed by the specification.
45  * @reference JSR 220-PROPOSED FINAL - Message-Driven Bean Component Contract - Table 3
46  * @requirement Application Server must be running.<br>
47  * MDB:<li>org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.access.MDBListenerMethodAccess</li>
48  * (Ant task: install.jar.tests.messagedriven.contract)
49  * @author Eduardo Studzinski Estima de Castro
50  * @author Gisele Pinheiro Souza
51  */

52 public class TestMDBListenerMethodAccess {
53
54     /**
55      * Log checker.
56      */

57     private OperationChecker checker;
58
59     /**
60      * JMS Manager.
61      */

62     private JMSManager jmsQueue;
63
64     /**
65      * Creates the JMS manager.
66      * @throws Exception if there is a problem.
67      */

68    @BeforeClass
69     public void startUp00() throws Exception JavaDoc {
70         jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
71         checker = new OperationChecker();
72     }
73
74     /**
75      * Verifies if a message listener method can access a resource manager.
76      * @input a message
77      * @output a logged onMessage() event
78      * @throws Exception if a problem occurs.
79      */

80     @Test
81     public void testResourceManager() throws Exception JavaDoc {
82         jmsQueue.sendControlMessage(MDBListenerMethodAccess.MESSAGE_TYPE, RESOURCE_MANAGER);
83         checker.check(MDBListenerMethodAccess.class.getName(), ON_MESSAGE, RESOURCE_MANAGER);
84     }
85
86     /**
87      * Verifies if a message listener method can access an enterprise bean.
88      * @input a message
89      * @output a logged onMessage() event
90      * @throws Exception if a problem occurs.
91      */

92     @Test
93     public void testEnterpriseBean() throws Exception JavaDoc {
94         jmsQueue.sendControlMessage(MDBListenerMethodAccess.MESSAGE_TYPE, ENTERPRISE_BEAN);
95         checker.check(MDBListenerMethodAccess.class.getName(), ON_MESSAGE, ENTERPRISE_BEAN);
96     }
97
98     /**
99      * Verifies if a message listener method can access an entity manager factory.
100      * @input a message
101      * @output a logged onMessage() event
102      * @throws Exception if a problem occurs.
103      */

104     @Test
105     public void testEntityManagerFactory() throws Exception JavaDoc {
106         jmsQueue.sendControlMessage(MDBListenerMethodAccess.MESSAGE_TYPE, ENTITY_MANAGER_FACTORY);
107         checker.check(MDBListenerMethodAccess.class.getName(), ON_MESSAGE, ENTITY_MANAGER_FACTORY);
108     }
109
110     /**
111      * Verifies if a message listener method can access an entity manager.
112      * @input a message
113      * @output a logged onMessage() event
114      * @throws Exception if a problem occurs.
115      */

116     @Test
117     public void testEntityManager() throws Exception JavaDoc {
118         jmsQueue.sendControlMessage(MDBListenerMethodAccess.MESSAGE_TYPE, ENTITY_MANAGER);
119         checker.check(MDBListenerMethodAccess.class.getName(), ON_MESSAGE, ENTITY_MANAGER);
120     }
121
122     /**
123      * Verifies if a message listener method can access the timer service.
124      * @input a message
125      * @output a logged onMessage() event
126      * @throws Exception if a problem occurs.
127      */

128     @Test
129     public void testTimerService() throws Exception JavaDoc {
130         jmsQueue.sendControlMessage(MDBListenerMethodAccess.MESSAGE_TYPE, TIMER);
131         checker.check(MDBListenerMethodAccess.class.getName(), ON_MESSAGE, TIMER);
132     }
133
134     /**
135      * Verifies if a message listener method can not access the UserTransaction.
136      * @input a message
137      * @output a logged onMessage() event
138      * @throws Exception if a problem occurs.
139      */

140     @Test
141     public void testUserTransaction() throws Exception JavaDoc {
142         jmsQueue.sendControlMessage(MDBListenerMethodAccess.MESSAGE_TYPE, USER_TRANSACTION);
143         checker.check(MDBListenerMethodAccess.class.getName(), ON_MESSAGE, USER_TRANSACTION);
144     }
145
146     /**
147      * Clears logs.
148      * @throws Exception if a problem occurs.
149      */

150     @AfterMethod
151     public void tearDown() throws Exception JavaDoc {
152         checker.deleteAll();
153     }
154
155     /**
156      * Clears logs.
157      * @throws Exception if a problem occurs.
158      */

159     @AfterClass
160     public void tearDownClass() throws Exception JavaDoc {
161         jmsQueue.close();
162     }
163 }
164
Popular Tags