KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > messagedriven > containermanaged > mdbinterface > TestMDBInterface


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: TestMDBInterface.java 979 2006-07-28 13:19:50Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.messagedriven.containermanaged.mdbinterface;
26
27 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.UNDEFINED;
28 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.MESSAGE_DRIVEN_CONTEXT;
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.entity.callbacklogger.OperationType;
35 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.mdbinterface.MDBInterface00;
36 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfOperationLoggerAccess;
37 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.SLSBOperationLoggerAccess;
38 import org.objectweb.easybeans.tests.common.jms.JMSManager;
39 import org.testng.annotations.AfterClass;
40 import org.testng.annotations.AfterMethod;
41 import org.testng.annotations.BeforeClass;
42 import org.testng.annotations.Test;
43
44 /**
45  * Verifies if a mdb that implements the MessageDrivenBean interface works
46  * properly.
47  * @reference JSR 220 - EJB 3.0 Core - 5.4.6
48  * @requirement Application Server must be running.<br>
49  * MDB:<li>org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.mdbinterface.MDBInterface00</li>
50  * (Ant task: install.jar.tests.messagedriven.interface)
51  * @author Eduardo Studzinski Estima de Castro
52  * @author Gisele Pinheiro Souza
53  */

54 public class TestMDBInterface {
55
56     /**
57      * JMS Manager.
58      */

59     private JMSManager jmsQueue;
60
61     /**
62      * Logger bean.
63      */

64     private ItfOperationLoggerAccess beanLogger;
65
66     /**
67      * Creates the JMS manager.
68      * @throws Exception if there is a problem.
69      */

70     @BeforeClass
71     public void startUp00() throws Exception JavaDoc {
72         jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
73         beanLogger = getBeanRemoteInstance(SLSBOperationLoggerAccess.class, ItfOperationLoggerAccess.class);
74     }
75
76     /**
77      * Verifies if the container initiliazes the MessageDrivenContext object.
78      * @input a message
79      * @output a logged onMessage() event
80      * @throws Exception if a problem occurs.
81      */

82     @Test
83     public void testInterface00() throws Exception JavaDoc {
84         jmsQueue.sendControlMessage(MDBInterface00.MESSAGE_TYPE, OperationType.MESSAGE_DRIVEN_CONTEXT);
85
86         // Verifies if the message was received
87
List JavaDoc<String JavaDoc> arEvent = new ArrayList JavaDoc<String JavaDoc>();
88
89         arEvent.add(MDBInterface00.class.getName());
90
91         beanLogger.verifyOperation(MDBInterface00.class, UNDEFINED, arEvent
92                 .toArray(new String JavaDoc[0]), MESSAGE_DRIVEN_CONTEXT);
93     }
94
95     /**
96      * Clears logs.
97      * @throws Exception if a problem occurs.
98      */

99     @AfterMethod
100     public void tearDown() throws Exception JavaDoc {
101         beanLogger.deleteAll();
102     }
103
104     /**
105      * Clears logs.
106      * @throws Exception if a problem occurs.
107      */

108     @AfterClass
109     public void tearDownClass() throws Exception JavaDoc {
110         jmsQueue.close();
111     }
112 }
113
Popular Tags