001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: TestMDBElements.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.deploymentdesc;
025:
026: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.ON_MESSAGE;
027: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.UNDEFINED;
028: import static org.ow2.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
029:
030: import java.util.ArrayList;
031: import java.util.List;
032:
033: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess;
034: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.SLSBCallbackLoggerAccess;
035: import org.ow2.easybeans.tests.common.jms.JMSManager;
036: import org.testng.annotations.AfterClass;
037: import org.testng.annotations.AfterMethod;
038: import org.testng.annotations.BeforeClass;
039: import org.testng.annotations.BeforeMethod;
040: import org.testng.annotations.Test;
041:
042: /**
043: * Verifies if the container can deploy a message-driven bean with the parameters defined in
044: * the deployment descriptor.
045: * @reference JSR 220 - FINAL RELEASE - 5.4.1
046: * @requirement The BasicMDBBean with the deployment
047: * descriptors must be deployed.
048: * (Ant task: install.jar.tests.xmldescriptor.ejb-jar.mdb)
049: * @author Eduardo Studzinski Estima de Castro
050: * @author Gisele Pinheiro Souza
051: *
052: */
053: public class TestMDBElements {
054:
055: /**
056: * Expected MDB Topic name.
057: */
058: private static final String MDB_TOPIC_MESSAGE_TYPE = "org.ow2.easybeans.tests.common.ejbs.base.xmldescriptor.MDBBasicTopicXML";
059:
060: /**
061: * Expected MDB Queue name.
062: */
063: private static final String MDB_QUEUE_MESSAGE_TYPE = "org.ow2.easybeans.tests.common.ejbs.base.xmldescriptor.MDBBasicQueueXML";
064:
065: /**
066: * JMS Manager.
067: */
068: private JMSManager jmsTopic;
069:
070: /**
071: * JMS Manager.
072: */
073: private JMSManager jmsQueue;
074:
075: /**
076: * Logger bean.
077: */
078: private ItfCallbackLoggerAccess beanLogger;
079:
080: /**
081: * Creates the JMS manager.
082: * @throws Exception if there is a problem.
083: */
084: @BeforeClass
085: public void startUp00() throws Exception {
086: jmsQueue = new JMSManager(
087: JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY,
088: JMSManager.DEFAULT_QUEUE);
089: jmsTopic = new JMSManager(
090: JMSManager.DEFAULT_TOPIC_CONNECTION_FACTORY,
091: JMSManager.DEFAULT_TOPIC);
092: beanLogger = getBeanRemoteInstance(
093: SLSBCallbackLoggerAccess.class,
094: ItfCallbackLoggerAccess.class);
095: }
096:
097: /**
098: * Gets the bean logger instance and clears previous tests information.
099: * @throws Exception if there is a problem with the bean initialization.
100: */
101: @BeforeMethod
102: public void startUp01() throws Exception {
103: beanLogger.deleteAll();
104: }
105:
106: /**
107: * Verifies if a message-driven bean defined using XML is working properly.
108: * @input a message
109: * @output a logged onMessage() event
110: * @throws Exception if a problem occurs.
111: */
112: @Test
113: public void testTopic00() throws Exception {
114: jmsTopic.sendControlMessage(MDB_TOPIC_MESSAGE_TYPE, UNDEFINED);
115:
116: // Verifies if the message was received
117: List<String> arEvent = new ArrayList<String>();
118:
119: arEvent.add(MDB_TOPIC_MESSAGE_TYPE);
120:
121: beanLogger.verifyCallbackOrder(MDB_TOPIC_MESSAGE_TYPE,
122: ON_MESSAGE, arEvent.toArray(new String[0]));
123: }
124:
125: /**
126: * Verifies if a message-driven bean defined using XML is working properly.
127: * @input a message
128: * @output a logged onMessage() event
129: * @throws Exception if a problem occurs.
130: */
131: @Test
132: public void testQueue00() throws Exception {
133: jmsQueue.sendControlMessage(MDB_QUEUE_MESSAGE_TYPE, UNDEFINED);
134:
135: // Verifies if the message was received
136: List<String> arEvent = new ArrayList<String>();
137:
138: arEvent.add(MDB_QUEUE_MESSAGE_TYPE);
139:
140: beanLogger.verifyCallbackOrder(MDB_QUEUE_MESSAGE_TYPE,
141: ON_MESSAGE, arEvent.toArray(new String[0]));
142: }
143:
144: /**
145: * Clears logs.
146: * @throws Exception if a problem occurs.
147: */
148: @AfterMethod
149: public void tearDown() throws Exception {
150: beanLogger.deleteAll();
151: }
152:
153: /**
154: * Clears logs.
155: * @throws Exception if a problem occurs.
156: */
157: @AfterClass
158: public void tearDownClass() throws Exception {
159: jmsQueue.close();
160: jmsTopic.close();
161: }
162: }
|