1 25 package org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.interceptorxml; 26 27 import static org.objectweb.easybeans.tests.common.asserts.Assert.assertEquals; 28 import static org.testng.Assert.assertTrue; 29 30 import java.util.ArrayList ; 31 import java.util.List ; 32 33 import javax.ejb.EJB ; 34 import javax.ejb.Remote ; 35 import javax.ejb.Stateful ; 36 37 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType; 38 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess; 39 import org.objectweb.easybeans.tests.common.interceptors.business.base.PrintOrderWithAllCallbackMethods; 40 import org.objectweb.easybeans.tests.common.interceptors.business.base.PrintOrderWithoutAnnotationInterc; 41 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder03Interceptor; 42 43 44 50 @Stateful 51 @Remote (ItfInterceptorTester02.class) 52 public class SFSBInterceptorTester02 implements ItfInterceptorTester02 { 53 54 57 @EJB (beanName = "SFSBInterceptorXMLRemote02") 58 private ItfInterceptorXML sfsbInterceptorXML; 59 60 63 @EJB (beanName = "SLSBCallbackLoggerAccess") 64 private ItfCallbackLoggerAccess clBean; 65 66 71 private void verifyMethodOrder(final List <Integer > lstResult){ 72 List <Integer > lstExpected = new ArrayList <Integer >(); 73 74 lstExpected.add(PrintOrder03Interceptor.ORDER); 76 lstExpected.add(PrintOrderWithoutAnnotationInterc.ORDER); 78 lstExpected.add(SFSBInterceptorXML.ORDER); 80 lstExpected.add(PrintOrderWithAllCallbackMethods.ORDER); 82 83 assertEquals(lstResult, lstExpected, 84 "The interceptors defined in the xml descriptor does not run in the order defined by the interceptors-order element."); 85 86 } 87 88 89 93 public void testInterceptorOrder01(){ 94 List <Integer > lstResult = sfsbInterceptorXML.insertOrder1(new ArrayList <Integer >()); 95 List <Integer > lstExpected = new ArrayList <Integer >(); 96 97 lstExpected.add(PrintOrderWithoutAnnotationInterc.ORDER); 99 lstExpected.add(SFSBInterceptorXML.ORDER); 101 lstExpected.add(PrintOrderWithAllCallbackMethods.ORDER); 103 104 assertEquals(lstResult, lstExpected, 105 "The interceptors defined in the xml descriptor does not run in the order defined by the interceptors-order element."); 106 } 107 108 112 public void testInterceptorOrder02(){ 113 verifyMethodOrder(sfsbInterceptorXML.insertOrder2(new ArrayList <Integer >())); 114 verifyMethodOrder(sfsbInterceptorXML.insertOrder2(new ArrayList <Integer >(), 1)); 115 } 116 117 120 public void testPostConstruct() { 121 assertTrue(sfsbInterceptorXML.calledPostConstruct(), "The postConstruct defined by XML was not called."); 122 List <String > arLife = new ArrayList <String >(); 124 125 arLife.add(PrintOrderWithAllCallbackMethods.class.getName()); 126 127 clBean.verifyCallbackOrder(SFSBInterceptorXML.class.getName(), CallbackType.PRE_DESTROY, arLife 128 .toArray(new String [arLife.size()])); 129 } 130 131 134 public void testPreDestroy() { 135 sfsbInterceptorXML.remove(); 136 137 List <String > arLife = new ArrayList <String >(); 139 140 arLife.add(SFSBInterceptorXML.class.getName()); 141 arLife.add(PrintOrderWithAllCallbackMethods.class.getName()); 142 143 clBean.verifyCallbackOrder(SFSBInterceptorXML.class.getName(), CallbackType.PRE_DESTROY, arLife 144 .toArray(new String [arLife.size()])); 145 } 146 147 150 public void testPrePassivate() { 151 } 153 154 157 public void testPostActivate() { 158 } 160 161 } 162 | Popular Tags |