Source Code Cross Referenced for BaseClassInterceptor02.java in  » J2EE » ow2-easybeans » org » ow2 » easybeans » tests » interceptors » business » base » invocationorder » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » ow2 easybeans » org.ow2.easybeans.tests.interceptors.business.base.invocationorder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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: BaseClassInterceptor02.java 1970 2007-10-16 11:49:25Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.ow2.easybeans.tests.interceptors.business.base.invocationorder;
025:
026:        import static org.ow2.easybeans.tests.common.asserts.Assert.assertEquals;
027:
028:        import java.util.ArrayList;
029:        import java.util.List;
030:
031:        import org.ow2.easybeans.tests.common.ejbs.base.ItfClassInterceptor;
032:        import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.interceptororder.SLSBClassInterceptorTest00;
033:        import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.interceptororder.SLSBClassInterceptorTest02;
034:        import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder01Interceptor;
035:        import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder02Interceptor;
036:        import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder03Interceptor;
037:        import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder04Interceptor;
038:        import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder06Interceptor;
039:        import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder07Interceptor;
040:        import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder08Interceptor;
041:        import org.ow2.easybeans.tests.common.interceptors.business.order.PrintOrder09Interceptor;
042:        import org.testng.annotations.Test;
043:
044:        /**
045:         * Verifies if the order to execute the class and method interceptors is
046:         * correct.
047:         * @author Eduardo Studzinski Estima de Castro
048:         * @author Gisele Pinheiro Souza
049:         */
050:        public class BaseClassInterceptor02 {
051:
052:            /**
053:             * Bean used to implement the test.
054:             */
055:            private ItfClassInterceptor<Integer> clBean;
056:
057:            /**
058:             * Verifies if the interceptors are not executed.
059:             * @input List with no values inside.
060:             * @output List with five values, the value inserted by the method and the
061:             *         value inserted by the interceptors.
062:             */
063:            @Test(groups={"onlyClassInterceptor","withInheritance"})
064:            public void testClassInterCallOrder00() {
065:                // The arrays used to know what is the interceptor order
066:                List<Integer> arResult = new ArrayList<Integer>();
067:                List<Integer> arExpected = new ArrayList<Integer>();
068:
069:                // insert the value of interceptor class
070:                arExpected.add(PrintOrder06Interceptor.ORDER);
071:                // insert the value of interceptor class
072:                arExpected.add(PrintOrder07Interceptor.ORDER);
073:                // insert the value of interceptor class
074:                arExpected.add(PrintOrder08Interceptor.ORDER);
075:                // insert the value of interceptor class
076:                arExpected.add(PrintOrder09Interceptor.ORDER);
077:                // insert the value of method
078:                arExpected.add(SLSBClassInterceptorTest02.ORDER);
079:
080:                // gets the result
081:                arResult = clBean.withoutMethodInterceptor(arResult);
082:
083:                // compares the two values
084:                assertEquals(
085:                        arExpected,
086:                        arResult,
087:                        "The class interceptors are not called or they are called in the incorrect order.");
088:            }
089:
090:            /**
091:             * Verifies if the interceptors are not executed.
092:             * @input List with no values inside.
093:             * @output List with five values, the value inserted by the method and the
094:             *         value inserted by the interceptors.
095:             */
096:            @Test(groups={"excludeDefaultInterceptor","onlyClassInterceptor","withInheritance"})
097:            public void testClassInterCallOrder01() {
098:                // The arrays used to know what is the interceptor order
099:                List<Integer> arResult = new ArrayList<Integer>();
100:                List<Integer> arExpected = new ArrayList<Integer>();
101:
102:                // insert the value of interceptor class
103:                arExpected.add(PrintOrder06Interceptor.ORDER);
104:                // insert the value of interceptor class
105:                arExpected.add(PrintOrder07Interceptor.ORDER);
106:                // insert the value of interceptor class
107:                arExpected.add(PrintOrder08Interceptor.ORDER);
108:                // insert the value of interceptor class
109:                arExpected.add(PrintOrder09Interceptor.ORDER);
110:                // insert the value of method
111:                arExpected.add(SLSBClassInterceptorTest02.ORDER);
112:                // gets the result
113:                arResult = clBean.withExcludeDefaultInterceptor(arResult);
114:
115:                // compares the two values
116:                assertEquals(
117:                        arExpected,
118:                        arResult,
119:                        "The class interceptors are not called or they are called in the incorrect order.");
120:            }
121:
122:            /**
123:             * Verifies if the interceptor classes are not executed with the annotation
124:             * excludeClassInterceptor.
125:             * @input List with no values inside.
126:             * @output List with only one value, the value inserted by the method.
127:             */
128:            @Test(groups={"excludeClassInterceptor","onlyClassInterceptor"})
129:            public void testClassInterCallOrder02() {
130:                // The arrays used to know what is the interceptor order
131:                List<Integer> arResult = new ArrayList<Integer>();
132:                List<Integer> arExpected = new ArrayList<Integer>();
133:
134:                // insert the value of the method
135:                arExpected.add(SLSBClassInterceptorTest02.ORDER);
136:
137:                // gets the result
138:                arResult = clBean.withExcludeClassInterceptor(arResult);
139:
140:                // compares the two values
141:                assertEquals(
142:                        arExpected,
143:                        arResult,
144:                        "The method has excludeClassInterceptor annotation, but it is calling the interceptor.");
145:            }
146:
147:            /**
148:             * Verifies if the interceptor classes are not executed with the annotation
149:             * excludeClassInterceptor. Also, this test verifies if the annotation doesn't
150:             * modify the interceptor method execution.
151:             * @input List with no values inside.
152:             * @output List with two values, the value inserted by the method
153:             *         interceptor and the value inserted by the method.
154:             */
155:            @Test(groups={"methodInterceptor","excludeClassInterceptor"})
156:            public void testClassInterCallOrder03() {
157:                // The arrays used to know what is the interceptor order
158:                List<Integer> arResult = new ArrayList<Integer>();
159:                List<Integer> arExpected = new ArrayList<Integer>();
160:
161:                // insert the value of the interceptor
162:                arExpected.add(PrintOrder01Interceptor.ORDER);
163:                // insert the value of the method
164:                arExpected.add(SLSBClassInterceptorTest02.ORDER);
165:
166:                // gets the result
167:                arResult = clBean.excludeClassAndOneMtd(arResult);
168:
169:                // compares the two values
170:                assertEquals(
171:                        arExpected,
172:                        arResult,
173:                        "This method has the excludeClassInterceptor, but it is not executing the method interceptor correctly.");
174:            }
175:
176:            /**
177:             * Verifies if the interceptor classes are not executed with the annotation
178:             * excludeClassInterceptor. Also, this test verifies if the annotation doesn't
179:             * modify many interceptor method executions.
180:             * @input List with no values inside.
181:             * @output List with two values, the value inserted by the method
182:             *         interceptor and the value inserted by the method.
183:             */
184:            @Test(groups={"excludeDefaultInterceptor","excludeClassInterceptor","methodInterceptor","withInheritance"})
185:            public void testClassInterCallOrder04() {
186:                // The arrays used to know what is the interceptor order
187:                List<Integer> arResult = new ArrayList<Integer>();
188:                List<Integer> arExpected = new ArrayList<Integer>();
189:
190:                // insert the value of the interceptor
191:                arExpected.add(PrintOrder01Interceptor.ORDER);
192:                // insert the value of the interceptor
193:                arExpected.add(PrintOrder02Interceptor.ORDER);
194:                // insert the value of the interceptor
195:                arExpected.add(PrintOrder03Interceptor.ORDER);
196:                // insert the value of the interceptor
197:                arExpected.add(PrintOrder04Interceptor.ORDER);
198:                // insert the value of the method
199:                arExpected.add(SLSBClassInterceptorTest02.ORDER);
200:
201:                // gets the result
202:                arResult = clBean.excludeClassDefAndFourMtd(arResult);
203:
204:                // compares the two values
205:                assertEquals(
206:                        arExpected,
207:                        arResult,
208:                        "This method has the excludeClassInterceptor, but it is not executing the method interceptors correctly.");
209:            }
210:
211:            /**
212:             * Verifies if the interceptor classes and the interceptor methods work well
213:             * together, i.e., if they respect the order.
214:             * @input List with no values inside.
215:             * @output List with eight values, the values inserted by the method
216:             *         interceptor and the value inserted by the method.
217:             */
218:            @Test(groups={"methodInterceptor","withInheritance"})
219:            public void testClassInterCallOrder05() {
220:                // The arrays used to know what is the interceptor order
221:                List<Integer> arResult = new ArrayList<Integer>();
222:                List<Integer> arExpected = new ArrayList<Integer>();
223:
224:                // insert the value of interceptor class
225:                arExpected.add(PrintOrder06Interceptor.ORDER);
226:                // insert the value of interceptor class
227:                arExpected.add(PrintOrder07Interceptor.ORDER);
228:                // insert the value of interceptor class
229:                arExpected.add(PrintOrder08Interceptor.ORDER);
230:                // insert the value of interceptor class
231:                arExpected.add(PrintOrder09Interceptor.ORDER);
232:                // insert the value of the interceptor
233:                arExpected.add(PrintOrder01Interceptor.ORDER);
234:                // insert the value of the interceptor
235:                arExpected.add(PrintOrder02Interceptor.ORDER);
236:                // insert the value of the interceptor
237:                arExpected.add(PrintOrder03Interceptor.ORDER);
238:                // insert the value of the method
239:                arExpected.add(SLSBClassInterceptorTest02.ORDER);
240:
241:                // gets the result
242:                arResult = clBean.withThreeMethodInterceptor(arResult);
243:
244:                // compares the two values
245:                assertEquals(arExpected, arResult,
246:                        "The class and the method interceptors are not running in the correct order.");
247:            }
248:
249:            /**
250:             * Verifies if the interceptor classes and the interceptor methods work well
251:             * together, i.e., if they respect the order.
252:             * @input List with no values inside.
253:             * @output List with two values, the values inserted by the method
254:             *         interceptor and the value inserted by the method.
255:             */
256:            @Test(groups={"methodInterceptor","withInheritance"})
257:            public void testClassInterCallOrder06() {
258:                // The arrays used to know what is the interceptor order
259:                List<Integer> arResult = new ArrayList<Integer>();
260:                List<Integer> arExpected = new ArrayList<Integer>();
261:
262:                // insert the value of interceptor class
263:                arExpected.add(PrintOrder06Interceptor.ORDER);
264:                // insert the value of interceptor class
265:                arExpected.add(PrintOrder07Interceptor.ORDER);
266:                // insert the value of interceptor class
267:                arExpected.add(PrintOrder08Interceptor.ORDER);
268:                // insert the value of interceptor class
269:                arExpected.add(PrintOrder09Interceptor.ORDER);
270:                // insert the value of the interceptor
271:                arExpected.add(PrintOrder01Interceptor.ORDER);
272:                // insert the value of the method
273:                arExpected.add(SLSBClassInterceptorTest00.ORDER);
274:
275:                // gets the result
276:                arResult = clBean.withOneMethodInterceptor(arResult);
277:
278:                // compares the two values
279:                assertEquals(arExpected, arResult,
280:                        "The method interceptor are running in the incorrect order.");
281:            }
282:
283:            /**
284:             * Sets bean used in the tests.
285:             * @param bean The bean to set.
286:             */
287:            public void setBean(final ItfClassInterceptor<Integer> bean) {
288:                this.clBean = bean;
289:            }
290:        }
w__ww__.___j___a_va2__s_.__c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.