Clover coverage report -
Coverage timestamp: Thu Jun 22 2006 14:24:50 CEST
file stats: LOC: 280   Methods: 8
NCLOC: 109   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BaseClassInterceptor02.java - 100% 100% 100%
coverage
 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: BaseClassInterceptor02.java 316 2006-04-04 11:21:20Z pinheirg $
 23    * --------------------------------------------------------------------------
 24    */
 25    package org.objectweb.easybeans.tests.interceptors.business.base;
 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.SLSBClassInterceptorTest00;
 34    import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSBClassInterceptorTest02;
 35    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder01Interceptor;
 36    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder02Interceptor;
 37    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder03Interceptor;
 38    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder04Interceptor;
 39    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder06Interceptor;
 40    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder07Interceptor;
 41    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder08Interceptor;
 42    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder09Interceptor;
 43    import org.testng.annotations.Test;
 44   
 45    /**
 46    * Verifies if the order to execute the class and method interceptors is
 47    * correct.
 48    * @author Eduardo Studzinski Estima de Castro
 49    * @author Gisele Pinheiro Souza
 50    */
 51    public class BaseClassInterceptor02 {
 52   
 53    /**
 54    * Bean used to implement the test.
 55    */
 56    private ItfClassInterceptor<Integer> clBean;
 57   
 58    /**
 59    * Verifies if the interceptors are not executed.
 60    * @input List with no values inside.
 61    * @output List with five values, the value inserted by the method and the
 62    * value inserted by the interceptors.
 63    */
 64  1 @Test(groups = {"onlyClassInterceptor", "withInheritance"})
 65    public void testClassInterCallOrder00() {
 66    // The arrays used to know what is the interceptor order
 67  1 List<Integer> arResult = new ArrayList<Integer>();
 68  1 List<Integer> arExpected = new ArrayList<Integer>();
 69   
 70    // insert the value of interceptor class
 71  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 72    // insert the value of interceptor class
 73  1 arExpected.add(PrintOrder07Interceptor.ORDER);
 74    // insert the value of interceptor class
 75  1 arExpected.add(PrintOrder08Interceptor.ORDER);
 76    // insert the value of interceptor class
 77  1 arExpected.add(PrintOrder09Interceptor.ORDER);
 78    // insert the value of method
 79  1 arExpected.add(SLSBClassInterceptorTest02.ORDER);
 80   
 81    // gets the result
 82  1 arResult = clBean.withoutMethodInterceptor(arResult);
 83   
 84    // compares the two values
 85  1 assertEquals(arExpected, arResult,
 86    "The class interceptors are not called or they are called in the incorrect order.");
 87    }
 88   
 89    /**
 90    * Verifies if the interceptors are not executed.
 91    * @input List with no values inside.
 92    * @output List with five values, the value inserted by the method and the
 93    * value inserted by the interceptors.
 94    */
 95  1 @Test(groups = {"excludeDefaultInterceptor", "onlyClassInterceptor", "withInheritance"})
 96    public void testClassInterCallOrder01() {
 97    // The arrays used to know what is the interceptor order
 98  1 List<Integer> arResult = new ArrayList<Integer>();
 99  1 List<Integer> arExpected = new ArrayList<Integer>();
 100   
 101    // insert the value of interceptor class
 102  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 103    // insert the value of interceptor class
 104  1 arExpected.add(PrintOrder07Interceptor.ORDER);
 105    // insert the value of interceptor class
 106  1 arExpected.add(PrintOrder08Interceptor.ORDER);
 107    // insert the value of interceptor class
 108  1 arExpected.add(PrintOrder09Interceptor.ORDER);
 109    // insert the value of method
 110  1 arExpected.add(SLSBClassInterceptorTest02.ORDER);
 111    // gets the result
 112  1 arResult = clBean.withExcludeDefaultInterceptor(arResult);
 113   
 114    // compares the two values
 115  1 assertEquals(arExpected, arResult,
 116    "The class interceptors are not called or they are called in the incorrect order.");
 117    }
 118   
 119    /**
 120    * Verifies if the interceptor classes are not executed with the annotation
 121    * excludeClassInterceptor.
 122    * @input List with no values inside.
 123    * @output List with only one value, the value inserted by the method.
 124    */
 125  1 @Test(groups = {"excludeClassInterceptor", "onlyClassInterceptor"})
 126    public void testClassInterCallOrder02() {
 127    // The arrays used to know what is the interceptor order
 128  1 List<Integer> arResult = new ArrayList<Integer>();
 129  1 List<Integer> arExpected = new ArrayList<Integer>();
 130   
 131    // insert the value of the method
 132  1 arExpected.add(SLSBClassInterceptorTest02.ORDER);
 133   
 134    // gets the result
 135  1 arResult = clBean.withExcludeClassInterceptor(arResult);
 136   
 137    // compares the two values
 138  1 assertEquals(arExpected, arResult,
 139    "The method has excludeClassInterceptor annotation, but it is calling the interceptor.");
 140    }
 141   
 142    /**
 143    * Verifies if the interceptor classes are not executed with the annotation
 144    * excludeClassInterceptor. Also, this test verifies if the annotation doesn't
 145    * modify the interceptor method execution.
 146    * @input List with no values inside.
 147    * @output List with two values, the value inserted by the method
 148    * interceptor and the value inserted by the method.
 149    */
 150  1 @Test(groups = {"methodInterceptor", "excludeClassInterceptor"})
 151    public void testClassInterCallOrder03() {
 152    // The arrays used to know what is the interceptor order
 153  1 List<Integer> arResult = new ArrayList<Integer>();
 154  1 List<Integer> arExpected = new ArrayList<Integer>();
 155   
 156    // insert the value of the interceptor
 157  1 arExpected.add(PrintOrder01Interceptor.ORDER);
 158    // insert the value of the method
 159  1 arExpected.add(SLSBClassInterceptorTest02.ORDER);
 160   
 161    // gets the result
 162  1 arResult = clBean.withExcludeClassInterAndOneMethodInter(arResult);
 163   
 164    // compares the two values
 165  1 assertEquals(arExpected, arResult,
 166    "This method has the excludeClassInterceptor, but it is not executing the method interceptor correctly.");
 167    }
 168   
 169    /**
 170    * Verifies if the interceptor classes are not executed with the annotation
 171    * excludeClassInterceptor. Also, this test verifies if the annotation doesn't
 172    * modify many interceptor method executions.
 173    * @input List with no values inside.
 174    * @output List with two values, the value inserted by the method
 175    * interceptor and the value inserted by the method.
 176    */
 177  1 @Test(groups = {"excludeDefaultInterceptor", "excludeClassInterceptor", "methodInterceptor", "withInheritance"})
 178    public void testClassInterCallOrder04() {
 179    // The arrays used to know what is the interceptor order
 180  1 List<Integer> arResult = new ArrayList<Integer>();
 181  1 List<Integer> arExpected = new ArrayList<Integer>();
 182   
 183    // insert the value of the interceptor
 184  1 arExpected.add(PrintOrder01Interceptor.ORDER);
 185    // insert the value of the interceptor
 186  1 arExpected.add(PrintOrder02Interceptor.ORDER);
 187    // insert the value of the interceptor
 188  1 arExpected.add(PrintOrder03Interceptor.ORDER);
 189    // insert the value of the interceptor
 190  1 arExpected.add(PrintOrder04Interceptor.ORDER);
 191    // insert the value of the method
 192  1 arExpected.add(SLSBClassInterceptorTest02.ORDER);
 193   
 194    // gets the result
 195  1 arResult = clBean.withExcludeClassDefInterAndFourMethodInter(arResult);
 196   
 197    // compares the two values
 198  1 assertEquals(arExpected, arResult,
 199    "This method has the excludeClassInterceptor, but it is not executing the method interceptors correctly.");
 200    }
 201   
 202    /**
 203    * Verifies if the interceptor classes and the interceptor methods work well
 204    * together, i.e., if they respect the order.
 205    * @input List with no values inside.
 206    * @output List with eight values, the values inserted by the method
 207    * interceptor and the value inserted by the method.
 208    */
 209  1 @Test(groups = {"methodInterceptor", "withInheritance"})
 210    public void testClassInterCallOrder05() {
 211    // The arrays used to know what is the interceptor order
 212  1 List<Integer> arResult = new ArrayList<Integer>();
 213  1 List<Integer> arExpected = new ArrayList<Integer>();
 214   
 215    // insert the value of interceptor class
 216  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 217    // insert the value of interceptor class
 218  1 arExpected.add(PrintOrder07Interceptor.ORDER);
 219    // insert the value of interceptor class
 220  1 arExpected.add(PrintOrder08Interceptor.ORDER);
 221    // insert the value of interceptor class
 222  1 arExpected.add(PrintOrder09Interceptor.ORDER);
 223    // insert the value of the interceptor
 224  1 arExpected.add(PrintOrder01Interceptor.ORDER);
 225    // insert the value of the interceptor
 226  1 arExpected.add(PrintOrder02Interceptor.ORDER);
 227    // insert the value of the interceptor
 228  1 arExpected.add(PrintOrder03Interceptor.ORDER);
 229    // insert the value of the method
 230  1 arExpected.add(SLSBClassInterceptorTest02.ORDER);
 231   
 232    // gets the result
 233  1 arResult = clBean.withThreeMethodInterceptor(arResult);
 234   
 235    // compares the two values
 236  1 assertEquals(arExpected, arResult,
 237    "The class and the method interceptors are not running in the correct order.");
 238    }
 239   
 240    /**
 241    * Verifies if the interceptor classes and the interceptor methods work well
 242    * together, i.e., if they respect the order.
 243    * @input List with no values inside.
 244    * @output List with two values, the values inserted by the method
 245    * interceptor and the value inserted by the method.
 246    */
 247  1 @Test(groups = {"methodInterceptor", "withInheritance"})
 248    public void testClassInterCallOrder06() {
 249    // The arrays used to know what is the interceptor order
 250  1 List<Integer> arResult = new ArrayList<Integer>();
 251  1 List<Integer> arExpected = new ArrayList<Integer>();
 252   
 253    // insert the value of interceptor class
 254  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 255    // insert the value of interceptor class
 256  1 arExpected.add(PrintOrder07Interceptor.ORDER);
 257    // insert the value of interceptor class
 258  1 arExpected.add(PrintOrder08Interceptor.ORDER);
 259    // insert the value of interceptor class
 260  1 arExpected.add(PrintOrder09Interceptor.ORDER);
 261    // insert the value of the interceptor
 262  1 arExpected.add(PrintOrder01Interceptor.ORDER);
 263    // insert the value of the method
 264  1 arExpected.add(SLSBClassInterceptorTest00.ORDER);
 265   
 266    // gets the result
 267  1 arResult = clBean.withOneMethodInterceptor(arResult);
 268   
 269    // compares the two values
 270  1 assertEquals(arExpected, arResult, "The method interceptor are running in the incorrect order.");
 271    }
 272   
 273    /**
 274    * Sets bean used in the tests.
 275    * @param bean The bean to set.
 276    */
 277  7 public void setBean(final ItfClassInterceptor<Integer> bean){
 278  7 this.clBean = bean;
 279    }
 280    }