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.SLSBClassInterceptorTest01; 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.testng.annotations.Test; 41 42 48 public class BaseClassInterceptor01 { 49 50 53 private ItfClassInterceptor<Integer > clBean; 54 55 61 @Test(groups = {"onlyClassInterceptor"}) 62 public void testClassInterCallOrder00() { 63 List <Integer > arResult = new ArrayList <Integer >(); 65 List <Integer > arExpected = new ArrayList <Integer >(); 66 67 arExpected.add(PrintOrder06Interceptor.ORDER); 69 arExpected.add(SLSBClassInterceptorTest01.ORDER); 71 72 arResult = clBean.withoutMethodInterceptor(arResult); 74 75 assertEquals(arExpected, arResult, 77 "The class interceptor is not called or it is called in the incorrect order."); 78 } 79 80 86 @Test(groups = {"excludeDefaultInterceptor", "onlyClassInterceptor"}) 87 public void testClassInterCallOrder01() { 88 List <Integer > arResult = new ArrayList <Integer >(); 90 List <Integer > arExpected = new ArrayList <Integer >(); 91 92 arExpected.add(PrintOrder06Interceptor.ORDER); 94 arExpected.add(SLSBClassInterceptorTest01.ORDER); 96 97 arResult = clBean.withExcludeDefaultInterceptor(arResult); 99 100 assertEquals(arExpected, arResult, 102 "The class interceptor is not called or it is called in the incorrect order."); 103 } 104 105 111 @Test(groups = {"excludeClassInterceptor", "onlyClassInterceptor"}) 112 public void testClassInterCallOrder02() { 113 List <Integer > arResult = new ArrayList <Integer >(); 115 List <Integer > arExpected = new ArrayList <Integer >(); 116 117 arExpected.add(SLSBClassInterceptorTest01.ORDER); 119 120 arResult = clBean.withExcludeClassInterceptor(arResult); 122 123 assertEquals(arExpected, arResult, 125 "The method has excludeClassInterceptor annotation, but it is calling the interceptor."); 126 } 127 128 136 @Test(groups = {"methodInterceptor", "excludeClassInterceptor"}) 137 public void testClassInterCallOrder03() { 138 List <Integer > arResult = new ArrayList <Integer >(); 140 List <Integer > arExpected = new ArrayList <Integer >(); 141 142 arExpected.add(PrintOrder01Interceptor.ORDER); 144 arExpected.add(SLSBClassInterceptorTest01.ORDER); 146 147 arResult = clBean.excludeClassAndOneMtd(arResult); 149 150 assertEquals(arExpected, arResult, 152 "This method has the excludeClassInterceptor, but it is not executing the method interceptor correctly."); 153 } 154 155 163 @Test(groups = {"excludeClassInterceptor", "methodInterceptor", "withInheritance"}) 164 public void testClassInterCallOrder04() { 165 List <Integer > arResult = new ArrayList <Integer >(); 167 List <Integer > arExpected = new ArrayList <Integer >(); 168 169 arExpected.add(PrintOrder01Interceptor.ORDER); 171 arExpected.add(PrintOrder02Interceptor.ORDER); 173 arExpected.add(PrintOrder03Interceptor.ORDER); 175 arExpected.add(PrintOrder04Interceptor.ORDER); 177 arExpected.add(SLSBClassInterceptorTest01.ORDER); 179 180 arResult = clBean.excludeClassDefAndFourMtd(arResult); 182 183 assertEquals(arExpected, arResult, 185 "This method has the excludeClassInterceptor, but it is not executing the method interceptors correctly."); 186 } 187 188 195 @Test(groups = {"methodInterceptor", "withInheritance"}) 196 public void testClassInterCallOrder05() { 197 List <Integer > arResult = new ArrayList <Integer >(); 199 List <Integer > arExpected = new ArrayList <Integer >(); 200 201 arExpected.add(PrintOrder06Interceptor.ORDER); 203 arExpected.add(PrintOrder01Interceptor.ORDER); 205 arExpected.add(PrintOrder02Interceptor.ORDER); 207 arExpected.add(PrintOrder03Interceptor.ORDER); 209 arExpected.add(SLSBClassInterceptorTest01.ORDER); 211 212 arResult = clBean.withThreeMethodInterceptor(arResult); 214 215 assertEquals(arExpected, arResult, 217 "The class and the method interceptors are not running in the correct order."); 218 } 219 220 227 @Test(groups = {"methodInterceptor"}) 228 public void testClassInterCallOrder06() { 229 List <Integer > arResult = new ArrayList <Integer >(); 231 List <Integer > arExpected = new ArrayList <Integer >(); 232 233 arExpected.add(PrintOrder06Interceptor.ORDER); 235 arExpected.add(PrintOrder01Interceptor.ORDER); 237 arExpected.add(SLSBClassInterceptorTest00.ORDER); 239 240 arResult = clBean.withOneMethodInterceptor(arResult); 242 243 assertEquals(arExpected, arResult, "The method interceptor are running in the incorrect order."); 245 } 246 247 251 public void setBean(final ItfClassInterceptor<Integer > bean){ 252 this.clBean = bean; 253 } 254 } 255 | Popular Tags |