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