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