KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateless > containermanaged > callbacklogger > CallbackChecker


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$
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger;
26
27 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
28
29 import java.util.ArrayList JavaDoc;
30 import java.util.List JavaDoc;
31
32 import org.objectweb.easybeans.log.JLog;
33 import org.objectweb.easybeans.log.JLogFactory;
34 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType;
35
36 /**
37  * This class encapsulates the verification using the bean logger.
38  * @author Eduardo Studzinski Estima de Castro
39  * @author Gisele Pinheiro Souza
40  *
41  */

42 public class CallbackChecker {
43
44     /**
45      * Logger bean.
46      */

47     private ItfCallbackLoggerAccess opLog;
48
49
50     /**
51      * Creates a logger checker.
52      */

53     public CallbackChecker(){
54         try {
55             opLog = getBeanRemoteInstance(SLSBCallbackLoggerAccess.class, ItfCallbackLoggerAccess.class);
56         } catch (Exception JavaDoc e) {
57             e.printStackTrace();
58             throw new IllegalStateException JavaDoc("Bean instance not found.");
59         }
60     }
61
62     /**
63      * Verifies if the specified callback was invoked.
64      * @param className the bean class.
65      * @param event the event type.
66      */

67     public void check(final String JavaDoc className, final CallbackType event) {
68
69         // Verifies if the message was received
70
List JavaDoc<String JavaDoc> arEvent = new ArrayList JavaDoc<String JavaDoc>();
71
72         arEvent.add(className);
73
74         this.check(className, event, arEvent);
75     }
76
77     /**
78      * Verifies if the specified callback was invoked.
79      * @param className the bean class.
80      * @param event the event type.
81      * @param eventClassNames the list of where the event methods are defined in
82      * the correct invocation order.
83      */

84     public void check(final String JavaDoc className, final CallbackType event, final List JavaDoc<String JavaDoc> eventClassNames) {
85         opLog.verifyCallbackOrder(className, event, eventClassNames.toArray(new String JavaDoc[0]));
86     }
87
88     /**
89      * Clears logs.
90      * @throws Exception if a problem occurs.
91      */

92     public void deleteAll() throws Exception JavaDoc {
93         opLog.deleteAll();
94     }
95 }
96
Popular Tags