KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateful > containermanaged > ejb2view > SFSBEjb2ClientLifecycle


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: SFSBEjb2ClientLifecycle.java 831 2006-07-11 11:23:08Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.ejb2view;
26
27 import static org.testng.Assert.assertEquals;
28
29 import java.rmi.RemoteException JavaDoc;
30 import java.util.List JavaDoc;
31
32 import javax.ejb.CreateException JavaDoc;
33 import javax.ejb.EJB JavaDoc;
34 import javax.ejb.RemoveException JavaDoc;
35 import javax.ejb.Stateful JavaDoc;
36
37 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackLogger;
38 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType;
39 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess;
40
41 /**
42  * Bean used to verify the callback methods chen the interface sessionBean is
43  * used.
44  * @author Gisele Pinheiro Souza
45  * @author Eduardo Studzinski Estima de Castro
46  */

47 @Stateful JavaDoc
48 public class SFSBEjb2ClientLifecycle implements ItfEjb2ClientLifecycle {
49
50     /**
51      * The bean home interface.
52      */

53     @EJB JavaDoc(beanName = "SimpleEjb2LifecycleBean")
54     private SimpleEjb2Home beanHome;
55
56     /**
57      * Bean used to log the callback methods.
58      */

59     @EJB JavaDoc(beanName = "SLSBCallbackLoggerAccess")
60     private ItfCallbackLoggerAccess clBean;
61
62     /**
63      * Verifies if the method ejbPassivate is called.
64      */

65     public void verifyPassivate() {
66         // TODO - How to test the EJB passivate?
67
throw new RuntimeException JavaDoc("Test not implemented yet.");
68     }
69
70     /**
71      * Verifies if the method ejbActivate is called.
72      */

73     public void verifyActivate() {
74         // TODO - How to test the EJB passivate?
75
throw new RuntimeException JavaDoc("Test not implemented yet.");
76     }
77
78     /**
79      * Verifies if the method ejbRemove is called.
80      * @throws RemoveException if an error during the remove occurs.
81      * @throws RemoteException if a system level error occurs.
82      * @throws CreateException if an error during the creation occurs.
83      */

84     public void verifyRemove() throws RemoteException JavaDoc, CreateException JavaDoc, RemoveException JavaDoc {
85         // cleans the log
86
List JavaDoc lstResultDelete = clBean.findCallbackEventByCallbackMethod(SimpleEjb2LifecycleBean.class.getName(),
87                 CallbackType.PRE_DESTROY, SimpleEjb2LifecycleBean.class.getName());
88         for (Object JavaDoc obj : lstResultDelete) {
89             CallbackLogger log = (CallbackLogger) obj;
90             clBean.deleteCallbackEvent(log.getId());
91         }
92         // creates the bean
93
SimpleEjb2 bean = beanHome.create();
94
95         // deletes the bean
96
beanHome.remove(bean);
97
98         // verifies the callback
99
List JavaDoc lstResult = clBean.findCallbackEventByCallbackMethod(SimpleEjb2LifecycleBean.class.getName(),
100                 CallbackType.PRE_DESTROY, SimpleEjb2LifecycleBean.class.getName());
101         assertEquals(1, lstResult.size(), "The lifecycle callback was not called or it was called more then once.");
102     }
103
104 }
105
Popular Tags