1 25 package org.objectweb.easybeans.tests.interceptors.business.base.invocationorder; 26 27 import static org.objectweb.easybeans.tests.common.asserts.Assert.assertEquals; 28 29 import java.util.ArrayList ; 30 import java.util.List ; 31 32 import org.objectweb.easybeans.tests.common.ejbs.base.ItfMethodInterceptor; 33 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.interceptororder.SLSBMethodInterceptorTest; 34 import org.objectweb.easybeans.tests.common.interceptors.business.basic.PackageInterceptor; 35 import org.objectweb.easybeans.tests.common.interceptors.business.basic.PrivateInterceptor; 36 import org.objectweb.easybeans.tests.common.interceptors.business.basic.ProtectedInterceptor; 37 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder01Interceptor; 38 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder02Interceptor; 39 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder03Interceptor; 40 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder04Interceptor; 41 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder05Interceptor; 42 import org.testng.annotations.Test; 43 44 50 public class BaseMethodInterceptor { 51 52 55 private ItfMethodInterceptor<Integer > mtBean; 56 57 62 @Test(groups = {"withoutInterceptor"}) 63 public void interceptorMethodTest00() { 64 List <Integer > arResult = new ArrayList <Integer >(); 66 List <Integer > arExpected = new ArrayList <Integer >(); 67 68 arExpected.add(SLSBMethodInterceptorTest.ORDER); 70 71 arResult = mtBean.withoutInterceptor(arResult); 73 74 assertEquals(arExpected, arResult, ""); 76 } 77 78 84 @Test(groups = {"withInterceptor"}) 85 public void interceptorMethodTest02() { 86 List <Integer > arResult = new ArrayList <Integer >(); 88 List <Integer > arExpected = new ArrayList <Integer >(); 89 90 arExpected.add(PrintOrder01Interceptor.ORDER); 92 arExpected.add(SLSBMethodInterceptorTest.ORDER); 94 95 arResult = mtBean.withOneMethodInterceptor(arResult); 97 98 assertEquals(arExpected, arResult, "The interceptor is not running or it is running in the incorrect order."); 100 } 101 102 108 @Test(groups = {"withInterceptor"}) 109 public void interceptorMethodTest03() { 110 List <Integer > arResult = new ArrayList <Integer >(); 112 List <Integer > arExpected = new ArrayList <Integer >(); 113 114 arExpected.add(PrintOrder01Interceptor.ORDER); 116 arExpected.add(PrintOrder02Interceptor.ORDER); 118 arExpected.add(SLSBMethodInterceptorTest.ORDER); 120 121 arResult = mtBean.withTwoMethodInterceptors(arResult); 123 124 assertEquals(arExpected, arResult, "The interceptors are not called in the correct order."); 126 } 127 128 134 @Test(groups = {"withInterceptor", "withInheritance"}) 135 public void interceptorMethodTest04() { 136 List <Integer > arResult = new ArrayList <Integer >(); 138 List <Integer > arExpected = new ArrayList <Integer >(); 139 140 arExpected.add(PrintOrder01Interceptor.ORDER); 142 arExpected.add(PrintOrder02Interceptor.ORDER); 144 arExpected.add(PrintOrder03Interceptor.ORDER); 146 arExpected.add(PrintOrder04Interceptor.ORDER); 148 arExpected.add(PrintOrder05Interceptor.ORDER); 150 arExpected.add(SLSBMethodInterceptorTest.ORDER); 152 153 arResult = mtBean.withFiveMethodInterceptors(arResult); 155 156 assertEquals(arExpected, arResult, "The interceptors are not running in the correct order." 158 + " Maybe there is a problem with the interceptors inheritance."); 159 } 160 161 168 @Test(groups = {"withInterceptor", "withInheritance"}) 169 public void interceptorMethodTest05() { 170 List <Integer > arResult = new ArrayList <Integer >(); 172 List <Integer > arExpected = new ArrayList <Integer >(); 173 174 arExpected.add(PrintOrder05Interceptor.ORDER); 176 arExpected.add(PrintOrder04Interceptor.ORDER); 178 arExpected.add(PrintOrder03Interceptor.ORDER); 180 arExpected.add(PrintOrder02Interceptor.ORDER); 182 arExpected.add(PrintOrder01Interceptor.ORDER); 184 arExpected.add(SLSBMethodInterceptorTest.ORDER); 186 187 arResult = mtBean.withFiveMethodInterceptorsInverse(arResult); 189 190 assertEquals(arExpected, arResult, "The interceptors are not running in the correct order." 192 + " Maybe there is a problem with the interceptors inheritance."); 193 } 194 195 202 @Test(groups = {"withInterceptor"}) 203 public void interceptorMethodTest06() { 204 List <Integer > arResult = new ArrayList <Integer >(); 206 List <Integer > arExpected = new ArrayList <Integer >(); 207 208 arExpected.add(PrivateInterceptor.ORDER); 210 arExpected.add(PrivateInterceptor.ORDER); 212 arExpected.add(PrivateInterceptor.ORDER); 214 arExpected.add(SLSBMethodInterceptorTest.ORDER); 216 217 arResult = mtBean.withPrivateInterceptors(arResult); 219 220 assertEquals(arExpected, arResult, "The interceptors with private method are not running in the correct order."); 222 } 223 224 231 @Test(groups = {"withInterceptor"}) 232 public void interceptorMethodTest07() { 233 List <Integer > arResult = new ArrayList <Integer >(); 235 List <Integer > arExpected = new ArrayList <Integer >(); 236 237 arExpected.add(ProtectedInterceptor.ORDER); 239 arExpected.add(ProtectedInterceptor.ORDER); 241 arExpected.add(SLSBMethodInterceptorTest.ORDER); 243 244 arResult = mtBean.withProtectedInterceptors(arResult); 246 247 assertEquals(arExpected, arResult, 249 "The interceptors with protected method are not running in the correct order."); 250 } 251 252 260 @Test(groups = {"withInterceptor", "withInheritance"}) 261 public void interceptorMethodTest08() { 262 List <Integer > arResult = new ArrayList <Integer >(); 264 List <Integer > arExpected = new ArrayList <Integer >(); 265 266 arExpected.add(PrivateInterceptor.ORDER); 268 arExpected.add(ProtectedInterceptor.ORDER); 270 arExpected.add(PrintOrder01Interceptor.ORDER); 272 arExpected.add(PrivateInterceptor.ORDER); 274 arExpected.add(PrintOrder03Interceptor.ORDER); 276 arExpected.add(PrivateInterceptor.ORDER); 278 arExpected.add(ProtectedInterceptor.ORDER); 280 arExpected.add(ProtectedInterceptor.ORDER); 282 arExpected.add(SLSBMethodInterceptorTest.ORDER); 284 285 arResult = mtBean.withPrivateProtectedPublicInterceptors(arResult); 287 288 assertEquals(arExpected, arResult, "The interceptors are not running in the correct order."); 290 } 291 292 299 @Test(groups = {"withInterceptor", "withInheritance"}) 300 public void interceptorMethodTest09() { 301 List <Integer > arResult = new ArrayList <Integer >(); 303 List <Integer > arExpected = new ArrayList <Integer >(); 304 305 arExpected.add(PackageInterceptor.ORDER); 307 arExpected.add(PackageInterceptor.ORDER); 309 arExpected.add(PackageInterceptor.ORDER); 311 arExpected.add(PackageInterceptor.ORDER); 313 314 arExpected.add(SLSBMethodInterceptorTest.ORDER); 316 317 arResult = mtBean.withPackageInterceptors(arResult); 319 320 assertEquals(arExpected, arResult, "The interceptors are not running in the correct order."); 322 } 323 324 328 public void setBean(final ItfMethodInterceptor<Integer > bean){ 329 this.mtBean = bean; 330 } 331 } 332 | Popular Tags |