KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > messagedriven > containermanaged > basic > TestMDBBasic00


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

25 package org.objectweb.easybeans.tests.messagedriven.containermanaged.basic;
26
27 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.ON_MESSAGE;
28 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.UNDEFINED;
29
30 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBQueue00;
31 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBQueue01;
32 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBTopic00;
33 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBTopic01;
34 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.CallbackChecker;
35 import org.objectweb.easybeans.tests.common.jms.JMSManager;
36 import org.testng.annotations.AfterClass;
37 import org.testng.annotations.AfterMethod;
38 import org.testng.annotations.BeforeClass;
39 import org.testng.annotations.BeforeMethod;
40 import org.testng.annotations.Test;
41
42 /**
43  * Verifies if simple message-driven beans can be deployed.
44  * @reference JSR 220-PROPOSED FINAL - Message-Driven Bean Component Contract
45  * @requirement Application Server must be running.<br>
46  * MDBs:<li>org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBQueue00</li>
47  * <li>org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBQueue01</li>
48  * <li>org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBTopic00</li>
49  * <li>org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.basic.MDBTopic01</li>
50 * (Ant task: install.jar.tests.messagedriven.contract)
51  * @author Eduardo Studzinski Estima de Castro
52  * @author Gisele Pinheiro Souza
53  */

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

59     private JMSManager jmsTopic;
60
61     /**
62      * JMS Manager.
63      */

64     private JMSManager jmsQueue;
65
66     /**
67      * Log checker.
68      */

69     private CallbackChecker checker;
70
71     /**
72      * Creates the JMS manager.
73      * @throws Exception if there is a problem.
74      */

75     @BeforeClass
76     public void startUp00() throws Exception JavaDoc {
77         jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
78         jmsTopic = new JMSManager(JMSManager.DEFAULT_TOPIC_CONNECTION_FACTORY, JMSManager.DEFAULT_TOPIC);
79         checker = new CallbackChecker();
80     }
81
82     /**
83      * Gets the bean logger instance and clears previous tests information.
84      * @throws Exception if there is a problem with the bean initialization.
85      */

86     @BeforeMethod
87     public void startUp01() throws Exception JavaDoc {
88         checker.deleteAll();
89     }
90
91     /**
92      * Verifies if a message-driven bean is invoked when a message is sent to a
93      * topic.
94      * @input a message
95      * @output a logged onMessage() event
96      * @throws Exception if a problem occurs.
97      */

98     @Test
99     public void testTopic00() throws Exception JavaDoc {
100         jmsTopic.sendControlMessage(MDBTopic00.MESSAGE_TYPE, UNDEFINED);
101         checker.check(MDBTopic00.class.getName(), ON_MESSAGE);
102     }
103
104     /**
105      * Verifies if a message-driven bean is invoked when a message is sent to a
106      * topic.
107      * @input a message
108      * @output a logged onMessage() event
109      * @throws Exception if a problem occurs.
110      */

111     @Test
112     public void testTopic01() throws Exception JavaDoc {
113         jmsTopic.sendControlMessage(MDBTopic01.MESSAGE_TYPE, UNDEFINED);
114         checker.check(MDBTopic01.class.getName(), ON_MESSAGE);
115     }
116
117     /**
118      * Verifies if a message-driven bean is invoked when a message is sent to a
119      * queue.
120      * @input a message
121      * @output a logged onMessage() event
122      * @throws Exception if a problem occurs.
123      */

124     @Test
125     public void testQueue00() throws Exception JavaDoc {
126         jmsQueue.sendControlMessage(MDBQueue00.MESSAGE_TYPE, UNDEFINED);
127         checker.check(MDBQueue00.class.getName(), ON_MESSAGE);
128     }
129
130     /**
131      * Verifies if a message-driven bean is invoked when a message is sent to a
132      * queue.
133      * @input a message
134      * @output a logged onMessage() event
135      * @throws Exception if a problem occurs.
136      */

137     @Test
138     public void testQueue01() throws Exception JavaDoc {
139         jmsQueue.sendControlMessage(MDBQueue01.MESSAGE_TYPE, UNDEFINED);
140         checker.check(MDBQueue01.class.getName(), ON_MESSAGE);
141     }
142
143     /**
144      * Clears logs.
145      * @throws Exception if a problem occurs.
146      */

147     @AfterMethod
148     public void tearDown() throws Exception JavaDoc {
149         //checker.deleteAll();
150
}
151
152     /**
153      * Clears logs.
154      * @throws Exception if a problem occurs.
155      */

156     @AfterClass
157     public void tearDownClass() throws Exception JavaDoc {
158         jmsQueue.close();
159         jmsTopic.close();
160     }
161 }
162
Popular Tags