KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > transaction > beanmanaged > TestTransactionMDB


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: TestTransactionMDB.java 980 2006-07-28 13:20:32Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.transaction.beanmanaged;
26
27 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.ON_MESSAGE;
28 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
29
30 import java.util.ArrayList JavaDoc;
31 import java.util.List JavaDoc;
32
33 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType;
34 import org.objectweb.easybeans.tests.common.ejbs.mdb.beanmanaged.transaction.MDBBMTransaction;
35 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess;
36 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.SLSBCallbackLoggerAccess;
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 /**
45  * Verifies if message-driven bean with bean-managed transaction is
46  * following the JSR 220. The items covered in this test are: 5.4.12
47  * @reference JSR 220-PROPOSED FINAL
48  * @requirement Application Server must be running.<br>
49  * MDB:<li>org.objectweb.easybeans.tests.common.ejbs.mdb.beanmanaged.transaction.MDBBMTransaction</li>
50  * SLSB: <li>org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.inheritance.SLSBCMTInheritance</li>
51  * (Ant task: install.jar.tests.transaction)
52  * @author Eduardo Studzinski Estima de Castro
53  * @author Gisele Pinheiro Souza
54  *
55  */

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

61     private JMSManager jmsQueue;
62
63     /**
64      * Logger bean.
65      */

66     private ItfCallbackLoggerAccess beanLogger;
67
68     /**
69      * Creates the JMS manager.
70      * @throws Exception if there is a problem.
71      */

72     @BeforeClass
73     public void startUp00() throws Exception JavaDoc {
74         jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
75         beanLogger = getBeanRemoteInstance(SLSBCallbackLoggerAccess.class, ItfCallbackLoggerAccess.class);
76     }
77
78     /**
79      * Verifies if the bean-managed transaction with
80      * message-driven bean is working properly.
81      * @input a message
82      * @output a logged onMessage() event
83      * @throws Exception if a problem occurs.
84      */

85     @Test
86     public void testBeanManaged00() throws Exception JavaDoc {
87         jmsQueue.sendControlMessage(MDBBMTransaction.MESSAGE_TYPE, OperationType.UNDEFINED);
88
89         // Verifies if the message was received
90
List JavaDoc<String JavaDoc> arEvent = new ArrayList JavaDoc<String JavaDoc>();
91
92         arEvent.add(MDBBMTransaction.class.getName());
93
94         beanLogger.verifyCallbackOrder(MDBBMTransaction.class, ON_MESSAGE, arEvent
95                 .toArray(new String JavaDoc[0]));
96     }
97
98     /**
99      * Clears logs.
100      * @throws Exception if a problem occurs.
101      */

102     @AfterMethod
103     public void tearDown() throws Exception JavaDoc {
104         beanLogger.deleteAll();
105     }
106
107     /**
108      * Clears logs.
109      * @throws Exception if a problem occurs.
110      */

111     @AfterClass
112     public void tearDownClass() throws Exception JavaDoc {
113         jmsQueue.close();
114     }
115 }
116
Popular Tags