Package org.ow2.easybeans.tests.transaction.beanmanaged

Source Code of org.ow2.easybeans.tests.transaction.beanmanaged.TestTransactionMDB

/**
* EasyBeans
* Copyright (C) 2006 Bull S.A.S.
* Contact: easybeans@ow2.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
* USA
*
* --------------------------------------------------------------------------
* $Id: TestTransactionMDB.java 5369 2010-02-24 14:58:19Z benoitf $
* --------------------------------------------------------------------------
*/
package org.ow2.easybeans.tests.transaction.beanmanaged;

import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.ON_MESSAGE;
import static org.ow2.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;

import java.util.ArrayList;
import java.util.List;

import org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType;
import org.ow2.easybeans.tests.common.ejbs.mdb.beanmanaged.transaction.MDBBMTransaction;
import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess;
import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.SLSBCallbackLoggerAccess;
import org.ow2.easybeans.tests.common.jms.JMSManager;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;


/**
* Verifies if message-driven bean with bean-managed transaction is
* following the JSR 220. The items covered in this test are: 5.4.12
* @reference JSR 220-PROPOSED FINAL
* @requirement Application Server must be running.<br>
*              MDB:<li>org.ow2.easybeans.tests.common.ejbs.mdb.beanmanaged.transaction.MDBBMTransaction</li>
*              SLSB: <li>org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.inheritance.SLSBCMTInheritance</li>
*              (Ant task: install.jar.tests.transaction)
* @author Eduardo Studzinski Estima de Castro
* @author Gisele Pinheiro Souza
*
*/
public class TestTransactionMDB {

    /**
     * JMS Manager.
     */
    private JMSManager jmsQueue;

    /**
     * Logger bean.
     */
    private ItfCallbackLoggerAccess beanLogger;

    /**
     * Creates the JMS manager.
     * @throws Exception if there is a problem.
     */
    @BeforeClass
    public void startUp00() throws Exception {
        jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
        beanLogger = getBeanRemoteInstance(SLSBCallbackLoggerAccess.class, ItfCallbackLoggerAccess.class);
    }

    /**
     * Verifies if the bean-managed transaction with
     * message-driven bean is working properly.
     * @input a message
     * @output a logged onMessage() event
     * @throws Exception if a problem occurs.
     */
    @Test
    public void testBeanManaged00() throws Exception {
        jmsQueue.sendControlMessage(MDBBMTransaction.MESSAGE_TYPE, OperationType.UNDEFINED);

        // Verifies if the message was received
        List<String> arEvent = new ArrayList<String>();

        arEvent.add(MDBBMTransaction.class.getName());

        beanLogger.verifyCallbackOrder(MDBBMTransaction.class, ON_MESSAGE, arEvent
                .toArray(new String[0]));
    }

    /**
     * Clears logs.
     * @throws Exception if a problem occurs.
     */
    @AfterMethod
    public void tearDown() throws Exception {
        beanLogger.deleteAll();
    }

    /**
     * Clears logs.
     * @throws Exception if a problem occurs.
     */
    @AfterClass
    public void tearDownClass() throws Exception {
        jmsQueue.close();
    }
}
TOP

Related Classes of org.ow2.easybeans.tests.transaction.beanmanaged.TestTransactionMDB

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.