KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > timerservice > timeout > base > BaseTestTimeout


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: BaseTestTimeout.java 827 2006-07-10 14:12:17Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.timerservice.timeout.base;
26
27 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.TIMEOUT;
28 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ENTERPRISE_BEAN;
29 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ENTITY_MANAGER;
30 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ENTITY_MANAGER_FACTORY;
31 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.RESOURCE_MANAGER;
32 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.TIMER;
33 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.USER_TRANSACTION;
34
35 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType;
36 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.OperationChecker;
37
38
39 /**
40  * @author Eduardo Studzinski Estima de Castro
41  * @author Gisele Pinheiro Souza
42  *
43  */

44 public abstract class BaseTestTimeout {
45
46     /**
47      * Log checker.
48      */

49     private OperationChecker checker;
50
51     /**
52      * Gets the name of the bean which should perform the operation.
53      * @return name
54      */

55     public abstract String JavaDoc getBeanName();
56
57     /**
58      * Creates the log checker.
59      * @throws Exception if there is a problem.
60      */

61     public void startUp() throws Exception JavaDoc {
62         checker = new OperationChecker();
63     }
64
65     /**
66      * Tests if a timeout callback method is allowed to access an EJB.
67      * @throws Exception if a problem occurs.
68      */

69     public void testAccessEJB00() throws Exception JavaDoc {
70         check(ENTERPRISE_BEAN);
71     }
72
73     /**
74      * Tests if a timeout callback method is allowed to access the Resource
75      * Manager.
76      * @throws Exception if a problem occurs.
77      */

78     public void testAccessResourceManager00() throws Exception JavaDoc {
79         check(RESOURCE_MANAGER);
80     }
81
82     /**
83      * Tests if a timeout callback method is allowed to access the Entity
84      * Manager.
85      * @throws Exception if a problem occurs.
86      */

87     public void testAccessEntityManager00() throws Exception JavaDoc {
88         check(ENTITY_MANAGER);
89     }
90
91     /**
92      * Tests if a timeout callback method is allowed to access the Entity
93      * Manager Factory.
94      * @throws Exception if a problem occurs.
95      */

96     public void testAccessEntityManagerFactory00() throws Exception JavaDoc {
97         check(ENTITY_MANAGER_FACTORY);
98     }
99
100     /**
101      * Tests if a timeout callback method is allowed to access the Timer
102      * Service.
103      * @throws Exception if a problem occurs.
104      */

105     public void testAccessTimerService00() throws Exception JavaDoc {
106         check(TIMER);
107
108     }
109
110     /**
111      * Tests if a timeout callback method is allowed to access the
112      * UserTransaction.
113      * @throws Exception if a problem occurs.
114      */

115     public void testAccessUserTransaction00() throws Exception JavaDoc {
116         check(USER_TRANSACTION);
117     }
118
119     /**
120      * Requests a timer creation and, after its experation, verifies if the specified operation
121      * occured.
122      * @param type the operation type.
123      * @throws Exception if a problem occurs.
124      */

125     public void check(final OperationType type) throws Exception JavaDoc {
126         requestStartTimer(type);
127         checker.check(getBeanName(), TIMEOUT, type);
128     }
129
130     /**
131      * Starts the timer.
132      * @param type operation type
133      * @throws Exception if a problem occurs.
134      */

135     public abstract void requestStartTimer(final OperationType type) throws Exception JavaDoc;
136
137     /**
138      * Clears logs.
139      * @throws Exception if a problem occurs.
140      */

141     public void tearDownMethod() throws Exception JavaDoc {
142         checker.deleteAll();
143     }
144
145 }
146
Popular Tags