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: TestMDBBasic00.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.messagedriven.containermanaged.basic;
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:
029: import org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBQueue00;
030: import org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBQueue01;
031: import org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBTopic00;
032: import org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBTopic01;
033: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.CallbackChecker;
034: import org.ow2.easybeans.tests.common.jms.JMSManager;
035: import org.testng.annotations.AfterClass;
036: import org.testng.annotations.AfterMethod;
037: import org.testng.annotations.BeforeClass;
038: import org.testng.annotations.BeforeMethod;
039: import org.testng.annotations.Test;
040:
041: /**
042: * Verifies if simple message-driven beans can be deployed.
043: * @reference JSR 220-PROPOSED FINAL - Message-Driven Bean Component Contract
044: * @requirement Application Server must be running.<br>
045: * MDBs:<li>org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBQueue00</li>
046: * <li>org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBQueue01</li>
047: * <li>org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBTopic00</li>
048: * <li>org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBTopic01</li>
049: * (Ant task: install.jar.tests.messagedriven.contract)
050: * @author Eduardo Studzinski Estima de Castro
051: * @author Gisele Pinheiro Souza
052: */
053: public class TestMDBBasic00 {
054:
055: /**
056: * JMS Manager.
057: */
058: private JMSManager jmsTopic;
059:
060: /**
061: * JMS Manager.
062: */
063: private JMSManager jmsQueue;
064:
065: /**
066: * Log checker.
067: */
068: private CallbackChecker checker;
069:
070: /**
071: * Creates the JMS manager.
072: * @throws Exception if there is a problem.
073: */
074: @BeforeClass
075: public void startUp00() throws Exception {
076: jmsQueue = new JMSManager(
077: JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY,
078: JMSManager.DEFAULT_QUEUE);
079: jmsTopic = new JMSManager(
080: JMSManager.DEFAULT_TOPIC_CONNECTION_FACTORY,
081: JMSManager.DEFAULT_TOPIC);
082: checker = new CallbackChecker();
083: }
084:
085: /**
086: * Gets the bean logger instance and clears previous tests information.
087: * @throws Exception if there is a problem with the bean initialization.
088: */
089: @BeforeMethod
090: public void startUp01() throws Exception {
091: checker.deleteAll();
092: }
093:
094: /**
095: * Verifies if a message-driven bean is invoked when a message is sent to a
096: * topic.
097: * @input a message
098: * @output a logged onMessage() event
099: * @throws Exception if a problem occurs.
100: */
101: @Test
102: public void testTopic00() throws Exception {
103: jmsTopic.sendControlMessage(MDBTopic00.MESSAGE_TYPE, UNDEFINED);
104: checker.check(MDBTopic00.class.getName(), ON_MESSAGE);
105: }
106:
107: /**
108: * Verifies if a message-driven bean is invoked when a message is sent to a
109: * topic.
110: * @input a message
111: * @output a logged onMessage() event
112: * @throws Exception if a problem occurs.
113: */
114: @Test
115: public void testTopic01() throws Exception {
116: jmsTopic.sendControlMessage(MDBTopic01.MESSAGE_TYPE, UNDEFINED);
117: checker.check(MDBTopic01.class.getName(), ON_MESSAGE);
118: }
119:
120: /**
121: * Verifies if a message-driven bean is invoked when a message is sent to a
122: * queue.
123: * @input a message
124: * @output a logged onMessage() event
125: * @throws Exception if a problem occurs.
126: */
127: @Test
128: public void testQueue00() throws Exception {
129: jmsQueue.sendControlMessage(MDBQueue00.MESSAGE_TYPE, UNDEFINED);
130: checker.check(MDBQueue00.class.getName(), ON_MESSAGE);
131: }
132:
133: /**
134: * Verifies if a message-driven bean is invoked when a message is sent to a
135: * queue.
136: * @input a message
137: * @output a logged onMessage() event
138: * @throws Exception if a problem occurs.
139: */
140: @Test
141: public void testQueue01() throws Exception {
142: jmsQueue.sendControlMessage(MDBQueue01.MESSAGE_TYPE, UNDEFINED);
143: checker.check(MDBQueue01.class.getName(), ON_MESSAGE);
144: }
145:
146: /**
147: * Clears logs.
148: * @throws Exception if a problem occurs.
149: */
150: @AfterMethod
151: public void tearDown() throws Exception {
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 {
161: jmsQueue.close();
162: jmsTopic.close();
163: }
164: }
|