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.ItfClassInterceptor; 33 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.interceptororder.SLSBClassInterceptorTest00; 34 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.interceptororder.SLSBClassInterceptorTest02; 35 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder01Interceptor; 36 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder02Interceptor; 37 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder03Interceptor; 38 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder04Interceptor; 39 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder06Interceptor; 40 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder07Interceptor; 41 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder08Interceptor; 42 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder09Interceptor; 43 import org.testng.annotations.Test; 44 45 51 public class BaseClassInterceptor02 { 52 53 56 private ItfClassInterceptor<Integer > clBean; 57 58 64 @Test(groups = {"onlyClassInterceptor", "withInheritance"}) 65 public void testClassInterCallOrder00() { 66 List <Integer > arResult = new ArrayList <Integer >(); 68 List <Integer > arExpected = new ArrayList <Integer >(); 69 70 arExpected.add(PrintOrder06Interceptor.ORDER); 72 arExpected.add(PrintOrder07Interceptor.ORDER); 74 arExpected.add(PrintOrder08Interceptor.ORDER); 76 arExpected.add(PrintOrder09Interceptor.ORDER); 78 arExpected.add(SLSBClassInterceptorTest02.ORDER); 80 81 arResult = clBean.withoutMethodInterceptor(arResult); 83 84 assertEquals(arExpected, arResult, 86 "The class interceptors are not called or they are called in the incorrect order."); 87 } 88 89 95 @Test(groups = {"excludeDefaultInterceptor", "onlyClassInterceptor", "withInheritance"}) 96 public void testClassInterCallOrder01() { 97 List <Integer > arResult = new ArrayList <Integer >(); 99 List <Integer > arExpected = new ArrayList <Integer >(); 100 101 arExpected.add(PrintOrder06Interceptor.ORDER); 103 arExpected.add(PrintOrder07Interceptor.ORDER); 105 arExpected.add(PrintOrder08Interceptor.ORDER); 107 arExpected.add(PrintOrder09Interceptor.ORDER); 109 arExpected.add(SLSBClassInterceptorTest02.ORDER); 111 arResult = clBean.withExcludeDefaultInterceptor(arResult); 113 114 assertEquals(arExpected, arResult, 116 "The class interceptors are not called or they are called in the incorrect order."); 117 } 118 119 125 @Test(groups = {"excludeClassInterceptor", "onlyClassInterceptor"}) 126 public void testClassInterCallOrder02() { 127 List <Integer > arResult = new ArrayList <Integer >(); 129 List <Integer > arExpected = new ArrayList <Integer >(); 130 131 arExpected.add(SLSBClassInterceptorTest02.ORDER); 133 134 arResult = clBean.withExcludeClassInterceptor(arResult); 136 137 assertEquals(arExpected, arResult, 139 "The method has excludeClassInterceptor annotation, but it is calling the interceptor."); 140 } 141 142 150 @Test(groups = {"methodInterceptor", "excludeClassInterceptor"}) 151 public void testClassInterCallOrder03() { 152 List <Integer > arResult = new ArrayList <Integer >(); 154 List <Integer > arExpected = new ArrayList <Integer >(); 155 156 arExpected.add(PrintOrder01Interceptor.ORDER); 158 arExpected.add(SLSBClassInterceptorTest02.ORDER); 160 161 arResult = clBean.excludeClassAndOneMtd(arResult); 163 164 assertEquals(arExpected, arResult, 166 "This method has the excludeClassInterceptor, but it is not executing the method interceptor correctly."); 167 } 168 169 177 @Test(groups = {"excludeDefaultInterceptor", "excludeClassInterceptor", "methodInterceptor", "withInheritance"}) 178 public void testClassInterCallOrder04() { 179 List <Integer > arResult = new ArrayList <Integer >(); 181 List <Integer > arExpected = new ArrayList <Integer >(); 182 183 arExpected.add(PrintOrder01Interceptor.ORDER); 185 arExpected.add(PrintOrder02Interceptor.ORDER); 187 arExpected.add(PrintOrder03Interceptor.ORDER); 189 arExpected.add(PrintOrder04Interceptor.ORDER); 191 arExpected.add(SLSBClassInterceptorTest02.ORDER); 193 194 arResult = clBean.excludeClassDefAndFourMtd(arResult); 196 197 assertEquals(arExpected, arResult, 199 "This method has the excludeClassInterceptor, but it is not executing the method interceptors correctly."); 200 } 201 202 209 @Test(groups = {"methodInterceptor", "withInheritance"}) 210 public void testClassInterCallOrder05() { 211 List <Integer > arResult = new ArrayList <Integer >(); 213 List <Integer > arExpected = new ArrayList <Integer >(); 214 215 arExpected.add(PrintOrder06Interceptor.ORDER); 217 arExpected.add(PrintOrder07Interceptor.ORDER); 219 arExpected.add(PrintOrder08Interceptor.ORDER); 221 arExpected.add(PrintOrder09Interceptor.ORDER); 223 arExpected.add(PrintOrder01Interceptor.ORDER); 225 arExpected.add(PrintOrder02Interceptor.ORDER); 227 arExpected.add(PrintOrder03Interceptor.ORDER); 229 arExpected.add(SLSBClassInterceptorTest02.ORDER); 231 232 arResult = clBean.withThreeMethodInterceptor(arResult); 234 235 assertEquals(arExpected, arResult, 237 "The class and the method interceptors are not running in the correct order."); 238 } 239 240 247 @Test(groups = {"methodInterceptor", "withInheritance"}) 248 public void testClassInterCallOrder06() { 249 List <Integer > arResult = new ArrayList <Integer >(); 251 List <Integer > arExpected = new ArrayList <Integer >(); 252 253 arExpected.add(PrintOrder06Interceptor.ORDER); 255 arExpected.add(PrintOrder07Interceptor.ORDER); 257 arExpected.add(PrintOrder08Interceptor.ORDER); 259 arExpected.add(PrintOrder09Interceptor.ORDER); 261 arExpected.add(PrintOrder01Interceptor.ORDER); 263 arExpected.add(SLSBClassInterceptorTest00.ORDER); 265 266 arResult = clBean.withOneMethodInterceptor(arResult); 268 269 assertEquals(arExpected, arResult, "The method interceptor are running in the incorrect order."); 271 } 272 273 277 public void setBean(final ItfClassInterceptor<Integer > bean){ 278 this.clBean = bean; 279 } 280 } 281 | Popular Tags |