KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > interceptors > lifecycle > stateful > containermanaged > TestSFAllCallbackOrder00


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: TestSFAllCallbackOrder00.java 978 2006-07-28 13:19:14Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.interceptors.lifecycle.stateful.containermanaged;
26
27 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.POST_CONSTRUCT;
28 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.PRE_DESTROY;
29 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
30
31 import java.util.ArrayList JavaDoc;
32 import java.util.List JavaDoc;
33
34 import org.objectweb.easybeans.tests.common.ejbs.base.ItfCheck02;
35 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.lifecallback.BasePostConstructAllOrder00;
36 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.lifecallback.BasePreDestroyAllOrder00;
37 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.lifecallback.SFSBPostConstructAllOrder;
38 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.lifecallback.SFSBPreDestroyAllOrder;
39 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess;
40 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.SLSBCallbackLoggerAccess;
41 import org.objectweb.easybeans.tests.common.interceptors.lifecycle.postconstruct.PostConstructLogger00;
42 import org.objectweb.easybeans.tests.common.interceptors.lifecycle.postconstruct.PostConstructLogger01;
43 import org.objectweb.easybeans.tests.common.interceptors.lifecycle.predestroy.PreDestroyLogger00;
44 import org.objectweb.easybeans.tests.common.interceptors.lifecycle.predestroy.PreDestroyLogger01;
45 import org.testng.annotations.AfterMethod;
46 import org.testng.annotations.BeforeClass;
47 import org.testng.annotations.BeforeMethod;
48 import org.testng.annotations.Test;
49
50 /**
51  * Verifies if interceptors invocation order.
52  * @reference JSR 220 - EJB 3.0 Core - 12.4.1
53  * @requirement Application Server must be running; the beans
54  * org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.lifecallback.*
55  * must be deployed.
56  * (Ant task: install.jar.tests.interceptor.lifecycle)
57  * @author Eduardo Studzinski Estima de Castro
58  * @author Gisele Pinheiro Souza
59  */

60 public class TestSFAllCallbackOrder00 {
61
62     /**
63      * Bean.
64      */

65     private ItfCheck02 beanPostConstructAllOrder;
66
67     /**
68      * Bean.
69      */

70     private ItfCheck02 beanPreDestroyAllOrder;
71
72     /**
73      * Logger bean.
74      */

75     private ItfCallbackLoggerAccess beanLogger;
76
77     /**
78      * Gets bean instances used in the tests.
79      * @throws Exception if there is a problem with the bean initialization.
80      */

81     @BeforeClass
82     public void startBeans() throws Exception JavaDoc {
83         beanPostConstructAllOrder = getBeanRemoteInstance(SFSBPostConstructAllOrder.class, ItfCheck02.class);
84         beanPreDestroyAllOrder = getBeanRemoteInstance(SFSBPreDestroyAllOrder.class, ItfCheck02.class);
85     }
86
87     /**
88      * Gets bean instances used in the tests.
89      * @throws Exception if there is a problem with the bean initialization.
90      */

91     @BeforeMethod
92     public void startLog() throws Exception JavaDoc {
93         beanLogger = getBeanRemoteInstance(SLSBCallbackLoggerAccess.class, ItfCallbackLoggerAccess.class);
94         beanLogger.deleteAll();
95     }
96
97     /**
98      * Verifies if the PostConstruct callback in invoked in the correct order.
99      * @input -
100      * @output -
101      * @throws Exception if a problem occurs.
102      */

103     @Test
104     public void testPostConstruct() throws Exception JavaDoc {
105         beanPostConstructAllOrder.check();
106
107         // Interceptors list
108
List JavaDoc<String JavaDoc> arLife = new ArrayList JavaDoc<String JavaDoc>();
109
110         arLife.add(PostConstructLogger00.class.getName());
111         arLife.add(PostConstructLogger01.class.getName());
112         arLife.add(BasePostConstructAllOrder00.class.getName());
113         arLife.add(SFSBPostConstructAllOrder.class.getName());
114
115         beanLogger.verifyCallbackOrder(SFSBPostConstructAllOrder.class, POST_CONSTRUCT, arLife.toArray(new String JavaDoc[0]));
116     }
117
118     /**
119      * Verifies if the PreDestroy callback in invoked in the correct order.
120      * @input -
121      * @output -
122      * @throws Exception if a problem occurs.
123      */

124     @Test
125     public void testPreDestroy() throws Exception JavaDoc {
126         /* TODO: review after PreDestroy implementation. */
127
128         beanPreDestroyAllOrder.check();
129         beanPreDestroyAllOrder.remove();
130
131         // Interceptors list
132
List JavaDoc<String JavaDoc> arLife = new ArrayList JavaDoc<String JavaDoc>();
133
134         arLife.add(PreDestroyLogger00.class.getName());
135         arLife.add(PreDestroyLogger01.class.getName());
136         arLife.add(BasePreDestroyAllOrder00.class.getName());
137         arLife.add(SFSBPreDestroyAllOrder.class.getName());
138
139         beanLogger.verifyCallbackOrder(SFSBPreDestroyAllOrder.class, PRE_DESTROY, arLife.toArray(new String JavaDoc[0]));
140     }
141
142     /* TODO: tests for PrePassivate and PostActivate. */
143
144     /**
145      * Clears callback event log.
146      */

147     @AfterMethod
148     public void tearDown() {
149         beanLogger.deleteAll();
150     }
151 }
152
Popular Tags