01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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: */package org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger;
25:
26: import static org.ow2.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
27:
28: import java.util.ArrayList;
29: import java.util.List;
30:
31: import org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType;
32: import org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType;
33:
34: /**
35: * This class encapsulates the verification using the bean logger.
36: * @author Eduardo Studzinski Estima de Castro
37: * @author Gisele Pinheiro Souza
38: *
39: */
40: public class OperationChecker {
41:
42: /**
43: * Logger bean.
44: */
45: private ItfOperationLoggerAccess opLog;
46:
47: /**
48: * Creates a logger checker.
49: * @throws Exception if a problem occurs.
50: */
51: public OperationChecker() throws Exception {
52: opLog = getBeanRemoteInstance(SLSBOperationLoggerAccess.class,
53: ItfOperationLoggerAccess.class);
54: }
55:
56: /**
57: * Verifies if the specified operation type occured.
58: * @param className the bean class.
59: * @param event the event type.
60: * @param operationType the operation type.
61: */
62: public void check(final String className, final CallbackType event,
63: final OperationType operationType) {
64:
65: // Verifies if the message was received
66: List<String> arEvent = new ArrayList<String>();
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 className, final CallbackType event,
83: final List<String> eventClassNames,
84: final OperationType operationType) {
85: opLog.verifyOperation(className, event, eventClassNames
86: .toArray(new String[0]), operationType);
87: }
88:
89: /**
90: * Clears logs.
91: * @throws Exception if a problem occurs.
92: */
93: public void deleteAll() throws Exception {
94: opLog.deleteAll();
95: }
96: }
|