KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateful > containermanaged > interceptorxml > SFSBInterceptorTester01


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: SFSBInterceptorTester01.java 820 2006-07-04 12:37:48Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.interceptorxml;
26
27 import static org.objectweb.easybeans.tests.common.asserts.Assert.assertEquals;
28
29 import java.util.ArrayList JavaDoc;
30 import java.util.List JavaDoc;
31
32 import javax.ejb.EJB JavaDoc;
33 import javax.ejb.Remote JavaDoc;
34 import javax.ejb.Stateful JavaDoc;
35
36 import org.objectweb.easybeans.tests.common.interceptors.business.base.PrintOrderWithoutAnnotationInterc;
37 import org.objectweb.easybeans.tests.common.interceptors.business.order.PrintOrder02Interceptor;
38
39 /**
40  * Verifies the interceptors defined by deployment descriptor.
41  * @author Gisele Pinheiro Souza
42  * @author Eduardo Studzinski Estima de Castro
43  *
44  */

45 @Stateful JavaDoc
46 @Remote JavaDoc(ItfInterceptorTester01.class)
47 public class SFSBInterceptorTester01 implements ItfInterceptorTester01 {
48
49     /**
50      * Bean defined by deployment descriptor used to test the interceptors.
51      */

52     @EJB JavaDoc(beanName = "SFSBInterceptorXMLRemote01")
53     private ItfInterceptorXML sfsbInterceptorXML;
54
55     /**
56      * Verifies if the default interceptor was called.
57      * @param lstResult the list that was returned by the bean method.
58      */

59     private void verifyDefaultInterceptor(final List JavaDoc<Integer JavaDoc> lstResult){
60           List JavaDoc<Integer JavaDoc> lstExpected = new ArrayList JavaDoc<Integer JavaDoc>();
61
62         // the default interceptor in first place
63
lstExpected.add(PrintOrderWithoutAnnotationInterc.ORDER);
64
65         assertEquals(lstResult, lstExpected,
66                 "The interceptors defined in the xml descriptor does not run in the correct order.");
67     }
68
69     /**
70      * Verifies if the default method is called for a bean.
71      *
72      */

73     public void testInterceptorOrder01(){
74         verifyDefaultInterceptor(sfsbInterceptorXML.insertOrder1(new ArrayList JavaDoc<Integer JavaDoc>()));
75     }
76
77     /**
78      * Verifies if the interceptor defined for a method specific(defined by name
79      * and parameters) is called only for this method.
80      */

81     public void testInterceptorOrder02(){
82         List JavaDoc<Integer JavaDoc> lstResult = sfsbInterceptorXML.insertOrder2(new ArrayList JavaDoc<Integer JavaDoc>());
83         List JavaDoc<Integer JavaDoc> lstExpected = new ArrayList JavaDoc<Integer JavaDoc>();
84
85         // the default interceptor in first place
86
lstExpected.add(PrintOrderWithoutAnnotationInterc.ORDER);
87         // the method interceptor
88
lstExpected.add(PrintOrder02Interceptor.ORDER);
89
90         assertEquals(lstResult, lstExpected,
91                 "The interceptors defined in the xml descriptor does not run in the correct order.");
92
93         verifyDefaultInterceptor(sfsbInterceptorXML.insertOrder2(new ArrayList JavaDoc<Integer JavaDoc>(), 1));
94     }
95
96     /**
97      * Verifies the element exclude default interceptor.
98      *
99      */

100     public void testInterceptorOrder03(){
101         List JavaDoc<Integer JavaDoc> lstResult = sfsbInterceptorXML.insertOrder3(new ArrayList JavaDoc<Integer JavaDoc>());
102         List JavaDoc<Integer JavaDoc> lstExpected = new ArrayList JavaDoc<Integer JavaDoc>();
103
104         assertEquals(lstResult, lstExpected,
105                 "The interceptors defined in the xml descriptor does not run in the correct order.");
106     }
107
108 }
109
Popular Tags