KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > interceptors > lifecycle > messagedriven > containermanaged > TestMDBAllCallback


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: TestMDBAllCallback.java 978 2006-07-28 13:19:14Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.interceptors.lifecycle.messagedriven.containermanaged;
26
27 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.POST_CONSTRUCT;
28 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.PRE_DESTROY;
29 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.UNDEFINED;
30 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
31
32 import java.util.ArrayList JavaDoc;
33 import java.util.List JavaDoc;
34
35 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.lifecallback.MDBLifecycle00;
36 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.lifecallback.PostConstructMDB;
37 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess;
38 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.SLSBCallbackLoggerAccess;
39 import org.objectweb.easybeans.tests.common.interceptors.lifecycle.predestroy.PreDestroyLogger00;
40 import org.objectweb.easybeans.tests.common.jms.JMSManager;
41 import org.testng.annotations.AfterClass;
42 import org.testng.annotations.BeforeClass;
43 import org.testng.annotations.Test;
44
45
46 /**
47  * Verifies if lifecycle callback interceptors are invoked.
48  * @reference JSR 220 - EJB 3.0 Core - 12.4
49  * @requirement Application Server must be running.<br>
50  * MDB:<li>org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.lifecallback.MDBLifecycle00</li>
51  * (Ant task: install.jar.tests.interceptor.lifecycle)
52  * @author Eduardo Studzinski Estima de Castro
53  * @author Gisele Pinheiro Souza
54  */

55 public class TestMDBAllCallback {
56
57     /**
58      * JMS Manager.
59      */

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

65     private ItfCallbackLoggerAccess beanLogger;
66
67     /**
68      * Creates the JMS manager and the bean logger.
69      * @throws Exception if there is a problem.
70      */

71     @BeforeClass
72     public void startUp00() throws Exception JavaDoc {
73         jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
74         beanLogger = getBeanRemoteInstance(SLSBCallbackLoggerAccess.class, ItfCallbackLoggerAccess.class);
75         jmsQueue.sendControlMessage(MDBLifecycle00.MESSAGE_TYPE, UNDEFINED);
76     }
77
78     /**
79      * Verifies if the PostConstruct callback in invoked in the correct order.
80      * @input -
81      * @output -
82      * @throws Exception if a problem occurs.
83      */

84     @Test
85     public void testPostConstruct() throws Exception JavaDoc {
86         //Interceptors list
87
List JavaDoc<String JavaDoc> arLife = new ArrayList JavaDoc<String JavaDoc>();
88
89         arLife.add(PostConstructMDB.class.getName());
90         arLife.add(MDBLifecycle00.class.getName());
91
92         beanLogger.verifyCallbackOrder(MDBLifecycle00.class, POST_CONSTRUCT,
93                 arLife.toArray(new String JavaDoc[0]));
94     }
95
96     /**
97      * Verifies if the PreDestroy callback in invoked in the correct order.
98      * @input -
99      * @output -
100      * @throws Exception if a problem occurs.
101      */

102     //@Test
103
public void testPreDestroy() throws Exception JavaDoc {
104         /*TODO: test, it's necessary to force a mdb destruction.*/
105
106         //Interceptors list
107
List JavaDoc<String JavaDoc> arLife = new ArrayList JavaDoc<String JavaDoc>();
108
109         arLife.add(PreDestroyLogger00.class.getName());
110         arLife.add(MDBLifecycle00.class.getName());
111
112         beanLogger.verifyCallbackOrder(MDBLifecycle00.class, PRE_DESTROY,
113                 arLife.toArray(new String JavaDoc[0]));
114     }
115
116     /**
117      * Clears callback event log.
118      * @throws Exception if a problem occurs.
119      */

120     @AfterClass
121     public void tearDown() throws Exception JavaDoc{
122         beanLogger.deleteAll();
123         jmsQueue.close();
124     }
125 }
126
Popular Tags