001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: BaseTestTimeout.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.timerservice.timeout.base;
025:
026: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.TIMEOUT;
027: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ENTERPRISE_BEAN;
028: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ENTITY_MANAGER;
029: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ENTITY_MANAGER_FACTORY;
030: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.RESOURCE_MANAGER;
031: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.TIMER;
032: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.USER_TRANSACTION;
033:
034: import org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType;
035: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.OperationChecker;
036:
037: /**
038: * @author Eduardo Studzinski Estima de Castro
039: * @author Gisele Pinheiro Souza
040: *
041: */
042: public abstract class BaseTestTimeout {
043:
044: /**
045: * Log checker.
046: */
047: private OperationChecker checker;
048:
049: /**
050: * Gets the name of the bean which should perform the operation.
051: * @return name
052: */
053: public abstract String getBeanName();
054:
055: /**
056: * Creates the log checker.
057: * @throws Exception if there is a problem.
058: */
059: public void startUp() throws Exception {
060: checker = new OperationChecker();
061: }
062:
063: /**
064: * Tests if a timeout callback method is allowed to access an EJB.
065: * @throws Exception if a problem occurs.
066: */
067: public void testAccessEJB00() throws Exception {
068: check(ENTERPRISE_BEAN);
069: }
070:
071: /**
072: * Tests if a timeout callback method is allowed to access the Resource
073: * Manager.
074: * @throws Exception if a problem occurs.
075: */
076: public void testAccessResourceManager00() throws Exception {
077: check(RESOURCE_MANAGER);
078: }
079:
080: /**
081: * Tests if a timeout callback method is allowed to access the Entity
082: * Manager.
083: * @throws Exception if a problem occurs.
084: */
085: public void testAccessEntityManager00() throws Exception {
086: check(ENTITY_MANAGER);
087: }
088:
089: /**
090: * Tests if a timeout callback method is allowed to access the Entity
091: * Manager Factory.
092: * @throws Exception if a problem occurs.
093: */
094: public void testAccessEntityManagerFactory00() throws Exception {
095: check(ENTITY_MANAGER_FACTORY);
096: }
097:
098: /**
099: * Tests if a timeout callback method is allowed to access the Timer
100: * Service.
101: * @throws Exception if a problem occurs.
102: */
103: public void testAccessTimerService00() throws Exception {
104: check(TIMER);
105:
106: }
107:
108: /**
109: * Tests if a timeout callback method is allowed to access the
110: * UserTransaction.
111: * @throws Exception if a problem occurs.
112: */
113: public void testAccessUserTransaction00() throws Exception {
114: check(USER_TRANSACTION);
115: }
116:
117: /**
118: * Requests a timer creation and, after its experation, verifies if the specified operation
119: * occured.
120: * @param type the operation type.
121: * @throws Exception if a problem occurs.
122: */
123: public void check(final OperationType type) throws Exception {
124: requestStartTimer(type);
125: checker.check(getBeanName(), TIMEOUT, type);
126: }
127:
128: /**
129: * Starts the timer.
130: * @param type operation type
131: * @throws Exception if a problem occurs.
132: */
133: public abstract void requestStartTimer(final OperationType type)
134: throws Exception;
135:
136: /**
137: * Clears logs.
138: * @throws Exception if a problem occurs.
139: */
140: public void tearDownMethod() throws Exception {
141: checker.deleteAll();
142: }
143:
144: }
|