KickJava   Java API By Example, From Geeks To Geeks.

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


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.tests.common.ejbs.entity.callbacklogger.CallbackType;
33 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType;
34
35 /**
36  * This class encapsulates the verification using the bean logger.
37  * @author Eduardo Studzinski Estima de Castro
38  * @author Gisele Pinheiro Souza
39  *
40  */

41 public class OperationChecker {
42
43     /**
44      * Logger bean.
45      */

46     private ItfOperationLoggerAccess opLog;
47
48
49     /**
50      * Creates a logger checker.
51      * @throws Exception if a problem occurs.
52      */

53     public OperationChecker() throws Exception JavaDoc{
54         opLog = getBeanRemoteInstance(SLSBOperationLoggerAccess.class, ItfOperationLoggerAccess.class);
55     }
56
57     /**
58      * Verifies if the specified operation type occured.
59      * @param className the bean class.
60      * @param event the event type.
61      * @param operationType the operation type.
62      */

63     public void check(final String JavaDoc className, final CallbackType event, final OperationType operationType) {
64
65         // Verifies if the message was received
66
List JavaDoc<String JavaDoc> arEvent = new ArrayList JavaDoc<String JavaDoc>();
67
68         arEvent.add(className);
69
70         this.check(className, event, arEvent, operationType);
71     }
72
73     /**
74      * Verifies if the events for an operation were called and if the invocation
75      * order is correct.
76      * @param className the bean class.
77      * @param event the event type.
78      * @param eventClassNames the list of where the event methods are defined in
79      * the correct invocation order.
80      * @param operationType the operation type.
81      */

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

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