KickJava   Java API By Example, From Geeks To Geeks.

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


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

25 package org.objectweb.easybeans.tests.deploymentdesc;
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.UNDEFINED;
29 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
30
31 import java.util.ArrayList JavaDoc;
32 import java.util.List JavaDoc;
33
34 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess;
35 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.SLSBCallbackLoggerAccess;
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 /**
45  * Verifies if the container can deploy a message-driven bean with the parameters defined in
46  * the deployment descriptor.
47  * @reference JSR 220 - FINAL RELEASE - 5.4.1
48  * @requirement The BasicMDBBean with the deployment
49  * descriptors must be deployed.
50  * (Ant task: install.jar.tests.xmldescriptor.ejb-jar.mdb)
51  * @author Eduardo Studzinski Estima de Castro
52  * @author Gisele Pinheiro Souza
53  *
54  */

55 public class TestMDBElements {
56
57     /**
58      * Expected MDB Topic name.
59      */

60     private static final String JavaDoc MDB_TOPIC_MESSAGE_TYPE =
61         "org.objectweb.easybeans.tests.common.ejbs.base.xmldescriptor.MDBBasicTopicXML";
62
63     /**
64      * Expected MDB Queue name.
65      */

66     private static final String JavaDoc MDB_QUEUE_MESSAGE_TYPE =
67         "org.objectweb.easybeans.tests.common.ejbs.base.xmldescriptor.MDBBasicQueueXML";
68
69     /**
70      * JMS Manager.
71      */

72     private JMSManager jmsTopic;
73
74     /**
75      * JMS Manager.
76      */

77     private JMSManager jmsQueue;
78
79     /**
80      * Logger bean.
81      */

82     private ItfCallbackLoggerAccess beanLogger;
83
84     /**
85      * Creates the JMS manager.
86      * @throws Exception if there is a problem.
87      */

88     @BeforeClass
89     public void startUp00() throws Exception JavaDoc {
90         jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
91         jmsTopic = new JMSManager(JMSManager.DEFAULT_TOPIC_CONNECTION_FACTORY, JMSManager.DEFAULT_TOPIC);
92         beanLogger = getBeanRemoteInstance(SLSBCallbackLoggerAccess.class, ItfCallbackLoggerAccess.class);
93     }
94
95     /**
96      * Gets the bean logger instance and clears previous tests information.
97      * @throws Exception if there is a problem with the bean initialization.
98      */

99     @BeforeMethod
100     public void startUp01() throws Exception JavaDoc {
101         beanLogger.deleteAll();
102     }
103
104     /**
105      * Verifies if a message-driven bean defined using XML is working properly.
106      * @input a message
107      * @output a logged onMessage() event
108      * @throws Exception if a problem occurs.
109      */

110     @Test
111     public void testTopic00() throws Exception JavaDoc {
112         jmsTopic.sendControlMessage(MDB_TOPIC_MESSAGE_TYPE, UNDEFINED);
113
114         // Verifies if the message was received
115
List JavaDoc<String JavaDoc> arEvent = new ArrayList JavaDoc<String JavaDoc>();
116
117         arEvent.add(MDB_TOPIC_MESSAGE_TYPE);
118
119         beanLogger.verifyCallbackOrder(MDB_TOPIC_MESSAGE_TYPE, ON_MESSAGE, arEvent.toArray(new String JavaDoc[0]));
120     }
121
122     /**
123      * Verifies if a message-driven bean defined using XML is working properly.
124      * @input a message
125      * @output a logged onMessage() event
126      * @throws Exception if a problem occurs.
127      */

128     @Test
129     public void testQueue00() throws Exception JavaDoc {
130         jmsQueue.sendControlMessage(MDB_QUEUE_MESSAGE_TYPE, UNDEFINED);
131
132         // Verifies if the message was received
133
List JavaDoc<String JavaDoc> arEvent = new ArrayList JavaDoc<String JavaDoc>();
134
135         arEvent.add(MDB_QUEUE_MESSAGE_TYPE);
136
137         beanLogger.verifyCallbackOrder(MDB_QUEUE_MESSAGE_TYPE, ON_MESSAGE, arEvent.toArray(new String JavaDoc[0]));
138     }
139
140     /**
141      * Clears logs.
142      * @throws Exception if a problem occurs.
143      */

144     @AfterMethod
145     public void tearDown() throws Exception JavaDoc {
146         beanLogger.deleteAll();
147     }
148
149     /**
150      * Clears logs.
151      * @throws Exception if a problem occurs.
152      */

153     @AfterClass
154     public void tearDownClass() throws Exception JavaDoc {
155         jmsQueue.close();
156         jmsTopic.close();
157     }
158 }
159
Popular Tags