001    package com.mockrunner.ejb;
002    
003    import javax.jms.ConnectionFactory;
004    import javax.jms.Destination;
005    
006    import junit.framework.TestCase;
007    
008    import org.mockejb.BasicEjbDescriptor;
009    import org.mockejb.TransactionPolicy;
010    
011    import com.mockrunner.mock.ejb.EJBMockObjectFactory;
012    
013    /**
014     * Delegator for {@link com.mockrunner.ejb.EJBTestModule}. You can
015     * subclass this adapter or use {@link com.mockrunner.ejb.EJBTestModule}
016     * directly (so your test case can use another base class).
017     * This basic adapter can be used if you don't need any other modules. It
018     * does not extend {@link com.mockrunner.base.BaseTestCase}. If you want
019     * to use several modules in conjunction, consider subclassing
020     * {@link com.mockrunner.ejb.EJBTestCaseAdapter}.
021     * <b>This class is generated from the {@link com.mockrunner.ejb.EJBTestModule}
022     * and should not be edited directly</b>.
023     */
024    public abstract class BasicEJBTestCaseAdapter extends TestCase
025    {
026        private EJBTestModule ejbTestModule;
027        private EJBMockObjectFactory ejbMockObjectFactory;
028    
029        public BasicEJBTestCaseAdapter()
030        {
031    
032        }
033    
034        public BasicEJBTestCaseAdapter(String name)
035        {
036            super(name);
037        }
038    
039        protected void tearDown() throws Exception
040        {
041            super.tearDown();
042            if(null != ejbMockObjectFactory)
043            {
044                ejbMockObjectFactory.resetMockContextFactory();
045            }
046            ejbTestModule = null;
047            ejbMockObjectFactory = null;
048        }
049    
050        /**
051         * Creates the {@link com.mockrunner.ejb.EJBTestModule}. If you
052         * overwrite this method, you must call <code>super.setUp()</code>.
053         */
054        protected void setUp() throws Exception
055        {
056            super.setUp();
057            ejbTestModule = createEJBTestModule(getEJBMockObjectFactory());
058        }
059    
060        /**
061         * Creates a {@link com.mockrunner.mock.ejb.EJBMockObjectFactory}.
062         * @return the created {@link com.mockrunner.mock.ejb.EJBMockObjectFactory}
063         */
064        protected EJBMockObjectFactory createEJBMockObjectFactory()
065        {
066            return new EJBMockObjectFactory();
067        }
068    
069        /**
070         * Gets the {@link com.mockrunner.mock.ejb.EJBMockObjectFactory}.
071         * @return the {@link com.mockrunner.mock.ejb.EJBMockObjectFactory}
072         */
073        protected EJBMockObjectFactory getEJBMockObjectFactory()
074        {
075            synchronized(EJBMockObjectFactory.class)
076            {
077                if(ejbMockObjectFactory == null)
078                {
079                    ejbMockObjectFactory = createEJBMockObjectFactory();
080                }
081            }
082            return ejbMockObjectFactory;
083        }
084    
085        /**
086         * Sets the {@link com.mockrunner.mock.ejb.EJBMockObjectFactory}.
087         * @param ejbMockObjectFactory the {@link com.mockrunner.mock.ejb.EJBMockObjectFactory}
088         */
089        protected void setEJBMockObjectFactory(EJBMockObjectFactory ejbMockObjectFactory)
090        {
091            this.ejbMockObjectFactory = ejbMockObjectFactory;
092        }
093    
094        /**
095         * Creates a {@link com.mockrunner.ejb.EJBTestModule} based on the current
096         * {@link com.mockrunner.mock.ejb.EJBMockObjectFactory}.
097         * Same as <code>createEJBTestModule(getEJBMockObjectFactory())</code>.
098         * @return the created {@link com.mockrunner.ejb.EJBTestModule}
099         */
100        protected EJBTestModule createEJBTestModule()
101        {
102            return new EJBTestModule(getEJBMockObjectFactory());
103        }
104    
105        /**
106         * Creates a {@link com.mockrunner.ejb.EJBTestModule} with the specified
107         * {@link com.mockrunner.mock.ejb.EJBMockObjectFactory}.
108         * @return the created {@link com.mockrunner.ejb.EJBTestModule}
109         */
110        protected EJBTestModule createEJBTestModule(EJBMockObjectFactory mockFactory)
111        {
112            return new EJBTestModule(mockFactory);
113        }
114    
115        /**
116         * Gets the {@link com.mockrunner.ejb.EJBTestModule}.
117         * @return the {@link com.mockrunner.ejb.EJBTestModule}
118         */
119        protected EJBTestModule getEJBTestModule()
120        {
121            return ejbTestModule;
122        }
123    
124        /**
125         * Sets the {@link com.mockrunner.ejb.EJBTestModule}.
126         * @param ejbTestModule the {@link com.mockrunner.ejb.EJBTestModule}
127         */
128        protected void setEJBTestModule(EJBTestModule ejbTestModule)
129        {
130            this.ejbTestModule = ejbTestModule;
131        }
132    
133        /**
134         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#setImplementationSuffix(String)}
135         */
136        protected void setImplementationSuffix(String impSuffix)
137        {
138            ejbTestModule.setImplementationSuffix(impSuffix);
139        }
140    
141        /**
142         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#setBusinessInterfaceSuffix(String)}
143         */
144        protected void setBusinessInterfaceSuffix(String businessInterfaceSuffix)
145        {
146            ejbTestModule.setBusinessInterfaceSuffix(businessInterfaceSuffix);
147        }
148    
149        /**
150         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#setHomeInterfaceSuffix(String)}
151         */
152        protected void setHomeInterfaceSuffix(String homeInterfaceSuffix)
153        {
154            ejbTestModule.setHomeInterfaceSuffix(homeInterfaceSuffix);
155        }
156    
157        /**
158         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#setInterfacePackage(String)}
159         */
160        protected void setInterfacePackage(String interfacePackage)
161        {
162            ejbTestModule.setInterfacePackage(interfacePackage);
163        }
164    
165        /**
166         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#setHomeInterfacePackage(String)}
167         */
168        protected void setHomeInterfacePackage(String homeInterfacePackage)
169        {
170            ejbTestModule.setHomeInterfacePackage(homeInterfacePackage);
171        }
172    
173        /**
174         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#setBusinessInterfacePackage(String)}
175         */
176        protected void setBusinessInterfacePackage(String businessInterfacePackage)
177        {
178            ejbTestModule.setBusinessInterfacePackage(businessInterfacePackage);
179        }
180    
181        /**
182         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploy(BasicEjbDescriptor)}
183         */
184        protected void deploy(BasicEjbDescriptor descriptor)
185        {
186            ejbTestModule.deploy(descriptor);
187        }
188    
189        /**
190         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploy(BasicEjbDescriptor, TransactionPolicy)}
191         */
192        protected void deploy(BasicEjbDescriptor descriptor, TransactionPolicy policy)
193        {
194            ejbTestModule.deploy(descriptor, policy);
195        }
196    
197        /**
198         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploySessionBean(String, Class, TransactionPolicy)}
199         */
200        protected void deploySessionBean(String jndiName, Class beanClass, TransactionPolicy policy)
201        {
202            ejbTestModule.deploySessionBean(jndiName, beanClass, policy);
203        }
204    
205        /**
206         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploySessionBean(String, Class)}
207         */
208        protected void deploySessionBean(String jndiName, Class beanClass)
209        {
210            ejbTestModule.deploySessionBean(jndiName, beanClass);
211        }
212    
213        /**
214         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploySessionBean(String, Class, boolean)}
215         */
216        protected void deploySessionBean(String jndiName, Class beanClass, boolean stateful)
217        {
218            ejbTestModule.deploySessionBean(jndiName, beanClass, stateful);
219        }
220    
221        /**
222         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploySessionBean(String, Object, TransactionPolicy)}
223         */
224        protected void deploySessionBean(String jndiName, Object bean, TransactionPolicy policy)
225        {
226            ejbTestModule.deploySessionBean(jndiName, bean, policy);
227        }
228    
229        /**
230         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploySessionBean(String, Class, boolean, TransactionPolicy)}
231         */
232        protected void deploySessionBean(String jndiName, Class beanClass, boolean stateful, TransactionPolicy policy)
233        {
234            ejbTestModule.deploySessionBean(jndiName, beanClass, stateful, policy);
235        }
236    
237        /**
238         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploySessionBean(String, Object)}
239         */
240        protected void deploySessionBean(String jndiName, Object bean)
241        {
242            ejbTestModule.deploySessionBean(jndiName, bean);
243        }
244    
245        /**
246         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploySessionBean(String, Object, boolean)}
247         */
248        protected void deploySessionBean(String jndiName, Object bean, boolean stateful)
249        {
250            ejbTestModule.deploySessionBean(jndiName, bean, stateful);
251        }
252    
253        /**
254         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deploySessionBean(String, Object, boolean, TransactionPolicy)}
255         */
256        protected void deploySessionBean(String jndiName, Object bean, boolean stateful, TransactionPolicy policy)
257        {
258            ejbTestModule.deploySessionBean(jndiName, bean, stateful, policy);
259        }
260    
261        /**
262         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deployEntityBean(String, Class, TransactionPolicy)}
263         */
264        protected void deployEntityBean(String jndiName, Class beanClass, TransactionPolicy policy)
265        {
266            ejbTestModule.deployEntityBean(jndiName, beanClass, policy);
267        }
268    
269        /**
270         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deployEntityBean(String, Class)}
271         */
272        protected void deployEntityBean(String jndiName, Class beanClass)
273        {
274            ejbTestModule.deployEntityBean(jndiName, beanClass);
275        }
276    
277        /**
278         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deployMessageBean(String, String, ConnectionFactory, Destination, Object, TransactionPolicy)}
279         */
280        protected void deployMessageBean(String connectionFactoryJndiName, String destinationJndiName, ConnectionFactory connectionFactory, Destination destination, Object bean, TransactionPolicy policy)
281        {
282            ejbTestModule.deployMessageBean(connectionFactoryJndiName, destinationJndiName, connectionFactory, destination, bean, policy);
283        }
284    
285        /**
286         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#deployMessageBean(String, String, ConnectionFactory, Destination, Object)}
287         */
288        protected void deployMessageBean(String connectionFactoryJndiName, String destinationJndiName, ConnectionFactory connectionFactory, Destination destination, Object bean)
289        {
290            ejbTestModule.deployMessageBean(connectionFactoryJndiName, destinationJndiName, connectionFactory, destination, bean);
291        }
292    
293        /**
294         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#bindToContext(String, Object)}
295         */
296        protected void bindToContext(String name, Object object)
297        {
298            ejbTestModule.bindToContext(name, object);
299        }
300    
301        /**
302         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#lookupBean(String)}
303         * @deprecated
304         */
305        protected Object lookupBean(String name)
306        {
307            return ejbTestModule.lookupBean(name);
308        }
309    
310        /**
311         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#lookupBean(String, String, Object[])}
312         * @deprecated
313         */
314        protected Object lookupBean(String name, String createMethod, Object[] parameters)
315        {
316            return ejbTestModule.lookupBean(name, createMethod, parameters);
317        }
318    
319        /**
320         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#lookupBean(String, Object[])}
321         * @deprecated
322         */
323        protected Object lookupBean(String name, Object[] parameters)
324        {
325            return ejbTestModule.lookupBean(name, parameters);
326        }
327    
328        /**
329         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#createBean(String)}
330         */
331        protected Object createBean(String name)
332        {
333            return ejbTestModule.createBean(name);
334        }
335    
336        /**
337         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#createBean(String, String, Object[])}
338         */
339        protected Object createBean(String name, String createMethod, Object[] parameters)
340        {
341            return ejbTestModule.createBean(name, createMethod, parameters);
342        }
343    
344        /**
345         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#createBean(String, String, Object[], Class[])}
346         */
347        protected Object createBean(String name, String createMethod, Object[] parameters, Class[] parameterTypes)
348        {
349            return ejbTestModule.createBean(name, createMethod, parameters, parameterTypes);
350        }
351    
352        /**
353         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#createBean(String, Object[])}
354         */
355        protected Object createBean(String name, Object[] parameters)
356        {
357            return ejbTestModule.createBean(name, parameters);
358        }
359    
360        /**
361         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#createEntityBean(String, String, Object[], Class[], Object)}
362         */
363        protected Object createEntityBean(String name, String createMethod, Object[] parameters, Class[] parameterTypes, Object primaryKey)
364        {
365            return ejbTestModule.createEntityBean(name, createMethod, parameters, parameterTypes, primaryKey);
366        }
367    
368        /**
369         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#createEntityBean(String, String, Object[], Object)}
370         */
371        protected Object createEntityBean(String name, String createMethod, Object[] parameters, Object primaryKey)
372        {
373            return ejbTestModule.createEntityBean(name, createMethod, parameters, primaryKey);
374        }
375    
376        /**
377         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#createEntityBean(String, Object)}
378         */
379        protected Object createEntityBean(String name, Object primaryKey)
380        {
381            return ejbTestModule.createEntityBean(name, primaryKey);
382        }
383    
384        /**
385         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#createEntityBean(String, Object[], Object)}
386         */
387        protected Object createEntityBean(String name, Object[] parameters, Object primaryKey)
388        {
389            return ejbTestModule.createEntityBean(name, parameters, primaryKey);
390        }
391    
392        /**
393         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#findByPrimaryKey(String, Object)}
394         */
395        protected Object findByPrimaryKey(String name, Object primaryKey)
396        {
397            return ejbTestModule.findByPrimaryKey(name, primaryKey);
398        }
399    
400        /**
401         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#resetUserTransaction}
402         */
403        protected void resetUserTransaction()
404        {
405            ejbTestModule.resetUserTransaction();
406        }
407    
408        /**
409         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#verifyCommitted}
410         */
411        protected void verifyCommitted()
412        {
413            ejbTestModule.verifyCommitted();
414        }
415    
416        /**
417         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#verifyNotCommitted}
418         */
419        protected void verifyNotCommitted()
420        {
421            ejbTestModule.verifyNotCommitted();
422        }
423    
424        /**
425         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#verifyRolledBack}
426         */
427        protected void verifyRolledBack()
428        {
429            ejbTestModule.verifyRolledBack();
430        }
431    
432        /**
433         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#verifyNotRolledBack}
434         */
435        protected void verifyNotRolledBack()
436        {
437            ejbTestModule.verifyNotRolledBack();
438        }
439    
440        /**
441         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#verifyMarkedForRollback}
442         */
443        protected void verifyMarkedForRollback()
444        {
445            ejbTestModule.verifyMarkedForRollback();
446        }
447    
448        /**
449         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#verifyNotMarkedForRollback}
450         */
451        protected void verifyNotMarkedForRollback()
452        {
453            ejbTestModule.verifyNotMarkedForRollback();
454        }
455    
456        /**
457         * Delegates to {@link com.mockrunner.ejb.EJBTestModule#lookup(String)}
458         */
459        protected Object lookup(String name)
460        {
461            return ejbTestModule.lookup(name);
462        }
463    }