KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > messagedriven > beanmanaged > context > TestMDBBeanManagedContext


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: TestMDBBeanManagedContext.java 979 2006-07-28 13:19:50Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.messagedriven.beanmanaged.context;
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.GET_CALLER_PRINCIPAL;
29 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.GET_ROLLBACK_ONLY;
30 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.SET_ROLLBACK_ONLY;
31 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.TIMER;
32 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.USER_TRANSACTION;
33
34 import org.objectweb.easybeans.tests.common.ejbs.mdb.beanmanaged.context.MDBBeanManagedContext;
35 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.OperationChecker;
36 import org.objectweb.easybeans.tests.common.jms.JMSManager;
37 import org.testng.annotations.AfterClass;
38 import org.testng.annotations.AfterMethod;
39 import org.testng.annotations.BeforeClass;
40 import org.testng.annotations.BeforeMethod;
41 import org.testng.annotations.Test;
42
43 /**
44  * Verifies if the MessageDrivenContext is working properly.
45  * @reference JSR 220-PROPOSED FINAL - Message-Driven Bean Component Contract
46  * @requirement Application Server must be running.<br>
47  * MDB:<li>org.objectweb.easybeans.tests.common.ejbs.mdb.beanmanaged.context.MDBBeanManagedContext</li>
48  * (Ant task: install.jar.tests.messagedrivencontext)
49  * @author Eduardo Studzinski Estima de Castro
50  * @author Gisele Pinheiro Souza
51  */

52 public class TestMDBBeanManagedContext {
53
54     /**
55      * JMS Manager.
56      */

57     private JMSManager jmsQueue;
58
59     /**
60      * Log checker.
61      */

62     private OperationChecker checker;
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      * Gets the bean logger instance and clears previous tests information.
76      * @throws Exception if there is a problem with the bean initialization.
77      */

78     @BeforeMethod
79     public void startUp01() throws Exception JavaDoc {
80         checker.deleteAll();
81     }
82
83     /**
84      * Verifies if the getCallerPrincipal() is working properly.
85      * @input a message
86      * @output a logged onMessage() event
87      * @throws Exception if a problem occurs.
88      */

89     @Test
90     public void testCallerPrincipal() throws Exception JavaDoc {
91         jmsQueue.sendControlMessage(MDBBeanManagedContext.MESSAGE_TYPE, GET_CALLER_PRINCIPAL);
92         checker.check(MDBBeanManagedContext.class.getName(), ON_MESSAGE, GET_CALLER_PRINCIPAL);
93     }
94
95     /**
96      * Verifies if the getRollbackOnly() is working properly.
97      * @input a message
98      * @output a logged onMessage() event
99      * @throws Exception if a problem occurs.
100      */

101     @Test
102     public void testGetRollbackOnly() throws Exception JavaDoc {
103         jmsQueue.sendControlMessage(MDBBeanManagedContext.MESSAGE_TYPE, GET_ROLLBACK_ONLY);
104         checker.check(MDBBeanManagedContext.class.getName(), ON_MESSAGE, GET_ROLLBACK_ONLY);
105     }
106
107     /**
108      * Verifies if the getRollbackOnly() is working properly.
109      * @input a message
110      * @output a logged onMessage() event
111      * @throws Exception if a problem occurs.
112      */

113     @Test
114     public void testSetRollbackOnly() throws Exception JavaDoc {
115         jmsQueue.sendControlMessage(MDBBeanManagedContext.MESSAGE_TYPE, SET_ROLLBACK_ONLY);
116         checker.check(MDBBeanManagedContext.class.getName(), ON_MESSAGE, SET_ROLLBACK_ONLY);
117     }
118
119     /**
120      * Verifies if the getTimerService() is working properly.
121      * @input a message
122      * @output a logged onMessage() event
123      * @throws Exception if a problem occurs.
124      */

125     @Test
126     public void testGetTimerService() throws Exception JavaDoc {
127         jmsQueue.sendControlMessage(MDBBeanManagedContext.MESSAGE_TYPE, TIMER);
128         checker.check(MDBBeanManagedContext.class.getName(), ON_MESSAGE, TIMER);
129     }
130
131     /**
132      * Verifies if the getUserTransaction() is working properly.
133      * @input a message
134      * @output a logged onMessage() event
135      * @throws Exception if a problem occurs.
136      */

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

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

156     @AfterClass
157     public void tearDownClass() throws Exception JavaDoc {
158         jmsQueue.close();
159     }
160 }
161
Popular Tags