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.PrintOrderWithoutAnnotationInterc; 40 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder02Interceptor; 41 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder03Interceptor; 42 43 48 @Stateful 49 @Remote (ItfInterceptorTester00.class) 50 public class SFSBInterceptorTester00 implements ItfInterceptorTester00 { 51 52 55 @EJB (beanName = "SFSBInterceptorXMLRemote00") 56 private ItfInterceptorXML sfsbInterceptorXML; 57 58 61 @EJB (beanName = "SLSBCallbackLoggerAccess") 62 private ItfCallbackLoggerAccess clBean; 63 64 69 private void verifyMethodInterceptor(final List <Integer > lstResult) { 70 List <Integer > lstExpected = new ArrayList <Integer >(); 71 72 lstExpected.add(PrintOrderWithoutAnnotationInterc.ORDER); 74 lstExpected.add(PrintOrder02Interceptor.ORDER); 76 lstExpected.add(SFSBInterceptorXML.ORDER); 77 lstExpected.add(PrintOrder03Interceptor.ORDER); 79 80 assertEquals(lstResult, lstExpected, 81 "The interceptors defined in the xml descriptor does not run in the correct order."); 82 83 } 84 85 89 public void testInterceptorOrder01() { 90 List <Integer > lstResult = sfsbInterceptorXML.insertOrder1(new ArrayList <Integer >()); 91 List <Integer > lstExpected = new ArrayList <Integer >(); 92 93 lstExpected.add(PrintOrderWithoutAnnotationInterc.ORDER); 95 lstExpected.add(PrintOrder02Interceptor.ORDER); 97 lstExpected.add(SFSBInterceptorXML.ORDER); 98 99 assertEquals(lstResult, lstExpected, 100 "The interceptors defined in the xml descriptor does not run in the correct order."); 101 } 102 103 108 public void testInterceptorOrder02() { 109 verifyMethodInterceptor(sfsbInterceptorXML.insertOrder2(new ArrayList <Integer >())); 110 verifyMethodInterceptor(sfsbInterceptorXML.insertOrder2(new ArrayList <Integer >(), 1)); 111 } 112 113 116 public void testInterceptorOrder03() { 117 List <Integer > lstResult = sfsbInterceptorXML.insertOrder3(new ArrayList <Integer >()); 118 List <Integer > lstExpected = new ArrayList <Integer >(); 119 120 lstExpected.add(PrintOrderWithoutAnnotationInterc.ORDER); 122 123 assertEquals(lstResult, lstExpected, 124 "The interceptors defined in the xml descriptor does not run in the correct order."); 125 } 126 127 130 public void testPostConstruct() { 131 assertTrue(sfsbInterceptorXML.calledPostConstruct(), "The postConstruct defined by XML was not called."); 132 } 133 134 137 public void testPreDestroy() { 138 sfsbInterceptorXML.remove(); 139 140 List <String > arLife = new ArrayList <String >(); 142 143 arLife.add(SFSBInterceptorXML.class.getName()); 144 145 clBean.verifyCallbackOrder(SFSBInterceptorXML.class.getName(), CallbackType.PRE_DESTROY, arLife 146 .toArray(new String [arLife.size()])); 147 } 148 149 152 public void testPrePassivate() { 153 } 155 156 159 public void testPostActivate() { 160 } 162 } 163 | Popular Tags |