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: TestMDBInterface.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.messagedriven.containermanaged.mdbinterface;
025:
026: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.UNDEFINED;
027: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.MESSAGE_DRIVEN_CONTEXT;
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.entity.callbacklogger.OperationType;
034: import org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.mdbinterface.MDBInterface00;
035: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfOperationLoggerAccess;
036: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.SLSBOperationLoggerAccess;
037: import org.ow2.easybeans.tests.common.jms.JMSManager;
038: import org.testng.annotations.AfterClass;
039: import org.testng.annotations.AfterMethod;
040: import org.testng.annotations.BeforeClass;
041: import org.testng.annotations.Test;
042:
043: /**
044: * Verifies if a mdb that implements the MessageDrivenBean interface works
045: * properly.
046: * @reference JSR 220 - EJB 3.0 Core - 5.4.6
047: * @requirement Application Server must be running.<br>
048: * MDB:<li>org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.mdbinterface.MDBInterface00</li>
049: * (Ant task: install.jar.tests.messagedriven.interface)
050: * @author Eduardo Studzinski Estima de Castro
051: * @author Gisele Pinheiro Souza
052: */
053: public class TestMDBInterface {
054:
055: /**
056: * JMS Manager.
057: */
058: private JMSManager jmsQueue;
059:
060: /**
061: * Logger bean.
062: */
063: private ItfOperationLoggerAccess beanLogger;
064:
065: /**
066: * Creates the JMS manager.
067: * @throws Exception if there is a problem.
068: */
069: @BeforeClass
070: public void startUp00() throws Exception {
071: jmsQueue = new JMSManager(
072: JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY,
073: JMSManager.DEFAULT_QUEUE);
074: beanLogger = getBeanRemoteInstance(
075: SLSBOperationLoggerAccess.class,
076: ItfOperationLoggerAccess.class);
077: }
078:
079: /**
080: * Verifies if the container initiliazes the MessageDrivenContext object.
081: * @input a message
082: * @output a logged onMessage() event
083: * @throws Exception if a problem occurs.
084: */
085: @Test
086: public void testInterface00() throws Exception {
087: jmsQueue.sendControlMessage(MDBInterface00.MESSAGE_TYPE,
088: OperationType.MESSAGE_DRIVEN_CONTEXT);
089:
090: // Verifies if the message was received
091: List<String> arEvent = new ArrayList<String>();
092:
093: arEvent.add(MDBInterface00.class.getName());
094:
095: beanLogger.verifyOperation(MDBInterface00.class, UNDEFINED,
096: arEvent.toArray(new String[0]), MESSAGE_DRIVEN_CONTEXT);
097: }
098:
099: /**
100: * Clears logs.
101: * @throws Exception if a problem occurs.
102: */
103: @AfterMethod
104: public void tearDown() throws Exception {
105: beanLogger.deleteAll();
106: }
107:
108: /**
109: * Clears logs.
110: * @throws Exception if a problem occurs.
111: */
112: @AfterClass
113: public void tearDownClass() throws Exception {
114: jmsQueue.close();
115: }
116: }
|