KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > messagedriven > beanmanaged > access > TestMDBBeanManagedListenerMethodAccess


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

25 package org.objectweb.easybeans.tests.messagedriven.beanmanaged.access;
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.USER_TRANSACTION;
29
30 import org.objectweb.easybeans.tests.common.ejbs.mdb.beanmanaged.access.MDBBeanManagedListenerMethodAccess;
31 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.OperationChecker;
32 import org.objectweb.easybeans.tests.common.jms.JMSManager;
33 import org.testng.annotations.AfterClass;
34 import org.testng.annotations.AfterMethod;
35 import org.testng.annotations.BeforeClass;
36 import org.testng.annotations.BeforeMethod;
37 import org.testng.annotations.Test;
38
39 /**
40  * Verifies if a message listener method can perform the operations allowed by the specification(Table 3).
41  * @reference JSR 220-PROPOSED FINAL - Message-Driven Bean Component Contract
42  * @requirement Application Server must be running.<br>
43  * MDB:<li>org.objectweb.easybeans.tests.common.ejbs.mdb.beanmanaged.access.MDBBeanManagedListenerMethodAccess</li>
44  * (Ant task: install.jar.tests.messagedriven.contract)
45  * @author Eduardo Studzinski Estima de Castro
46  * @author Gisele Pinheiro Souza
47  */

48 public class TestMDBBeanManagedListenerMethodAccess {
49
50     /**
51      * JMS Manager.
52      */

53     private JMSManager jmsQueue;
54
55     /**
56      * Log checker.
57      */

58     private OperationChecker checker;
59
60     /**
61      * Creates the JMS manager.
62      * @throws Exception if there is a problem.
63      */

64    @BeforeClass
65     public void startUp00() throws Exception JavaDoc {
66         jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
67         checker = new OperationChecker();
68     }
69
70     /**
71      * Gets the bean logger instance and clears previous tests information.
72      * @throws Exception if there is a problem with the bean initialization.
73      */

74     @BeforeMethod
75     public void startUp01() throws Exception JavaDoc {
76         checker.deleteAll();
77     }
78
79     /**
80      * Verifies if a message listener method can access the UserTransaction.
81      * @input a message
82      * @output a logged onMessage() event
83      * @throws Exception if a problem occurs.
84      */

85     @Test
86     public void testUserTransaction() throws Exception JavaDoc {
87         jmsQueue.sendControlMessage(MDBBeanManagedListenerMethodAccess.MESSAGE_TYPE, USER_TRANSACTION);
88         checker.check(MDBBeanManagedListenerMethodAccess.class.getName(), ON_MESSAGE, USER_TRANSACTION);
89     }
90
91     /**
92      * Clears logs.
93      * @throws Exception if a problem occurs.
94      */

95     @AfterMethod
96     public void tearDown() throws Exception JavaDoc {
97         checker.deleteAll();
98     }
99
100     /**
101      * Clears logs.
102      * @throws Exception if a problem occurs.
103      */

104     @AfterClass
105     public void tearDownClass() throws Exception JavaDoc {
106         jmsQueue.close();
107     }
108 }
109
Popular Tags