Clover coverage report -
Coverage timestamp: Thu Jun 22 2006 14:24:50 CEST
file stats: LOC: 305   Methods: 8
NCLOC: 116   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BaseMiscInterceptor00.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: BaseMiscInterceptor00.java 556 2006-06-02 06:55:45Z studzine $
 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.ItfSimpleBean;
 33    import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSBSimpleInterceptorTest00;
 34    import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSBSimpleInterceptorTest01;
 35    import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSBSimpleInterceptorTest02;
 36    import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSBSimpleInterceptorTest03;
 37    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder01Interceptor;
 38    import org.objectweb.easybeans.tests.common.interceptors.business.PrintOrder03Interceptor;
 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 method and callbacks interceptors is
 44    * correct, also verifies the interceptors inheritance.
 45    * @author Eduardo Studzinski Estima de Castro
 46    * @author Gisele Pinheiro Souza
 47    */
 48    public class BaseMiscInterceptor00 {
 49   
 50    /**
 51    * Bean used to implement the test.
 52    */
 53    private ItfSimpleBean<Integer> mtBean00;
 54   
 55    /**
 56    * Bean used to implement the test.
 57    */
 58    private ItfSimpleBean<Integer> mtBean01;
 59   
 60    /**
 61    * Bean used to implement the test.
 62    */
 63    private ItfSimpleBean<Integer> mtBean02;
 64   
 65    /**
 66    * Bean used to implement the test.
 67    */
 68    private ItfSimpleBean<Integer> mtBean03;
 69   
 70    /**
 71    * Verifies if the interceptors are following the order of declaration.
 72    * There is an interceptor inside the bean class that has public modifier
 73    * access.
 74    * @input List with no values inside
 75    * @output List with 4 values, the value inserted by the method and value
 76    * inserted by the interceptors.
 77    */
 78  1 @Test(groups = {"withInterceptor"})
 79    public void testMiscPublicInterCallOrder() {
 80    // The arrays used to know what is the interceptor order
 81  1 List<Integer> arResult = new ArrayList<Integer>();
 82  1 List<Integer> arExpected = new ArrayList<Integer>();
 83   
 84    // insert the value of interceptor
 85  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 86    // insert the value of interceptor
 87  1 arExpected.add(PrintOrder01Interceptor.ORDER);
 88    // insert the value of interceptor
 89  1 arExpected.add(ItfSimpleBean.EMBEDDED_INTERCEPTOR);
 90    // insert the value of the method
 91  1 arExpected.add(SLSBSimpleInterceptorTest00.ORDER);
 92   
 93    // gets the result
 94  1 arResult = mtBean00.withInterceptors(arResult);
 95   
 96  1 assertEquals(arExpected, arResult,
 97    "The method has class interceptors, a method interceptor and a public bean interceptor method"
 98    + " declared inside the bean; however it isn't running in the correct order.");
 99    }
 100   
 101    /**
 102    * Verifies if the interceptors are following the order of declaration.
 103    * There is an interceptor inside the bean class that has protected modifier
 104    * access.
 105    * @input List with no values inside
 106    * @output List with 4 values, the value inserted by the method and value
 107    * inserted by the interceptors.
 108    */
 109  1 @Test(groups = {"withInterceptor"})
 110    public void testMiscProtectedInterCallOrder() {
 111    // The arrays used to know what is the interceptor order
 112  1 List<Integer> arResult = new ArrayList<Integer>();
 113  1 List<Integer> arExpected = new ArrayList<Integer>();
 114   
 115    // insert the value of interceptor
 116  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 117    // insert the value of interceptor
 118  1 arExpected.add(PrintOrder01Interceptor.ORDER);
 119    // insert the value of interceptor
 120  1 arExpected.add(ItfSimpleBean.EMBEDDED_INTERCEPTOR);
 121    // insert the value of the method
 122  1 arExpected.add(SLSBSimpleInterceptorTest01.ORDER);
 123   
 124    // gets the result
 125  1 arResult = mtBean01.withInterceptors(arResult);
 126   
 127    // compares the two values
 128  1 assertEquals(arExpected, arResult,
 129    "The method has class interceptors, a method interceptor and a protected bean interceptor method"
 130    + " declared inside the bean; however it isn't running in the correct order.");
 131    }
 132   
 133    /**
 134    * Verifies if the interceptors are following the order of declaration.
 135    * There is an interceptor inside the bean class that has private modifier
 136    * access.
 137    * @input List with no values inside
 138    * @output List with 4 values, the value inserted by the method and value
 139    * inserted by the interceptors.
 140    */
 141  1 @Test(groups = {"withInterceptor"})
 142    public void testMiscPrivateInterCallOrder() {
 143    // The arrays used to know what is the interceptor order
 144  1 List<Integer> arResult = new ArrayList<Integer>();
 145  1 List<Integer> arExpected = new ArrayList<Integer>();
 146   
 147    // insert the value of interceptor
 148  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 149    // insert the value of interceptor
 150  1 arExpected.add(PrintOrder01Interceptor.ORDER);
 151    // insert the value of interceptor
 152  1 arExpected.add(ItfSimpleBean.EMBEDDED_INTERCEPTOR);
 153    // insert the value of the method
 154  1 arExpected.add(SLSBSimpleInterceptorTest02.ORDER);
 155   
 156    // gets the result
 157  1 arResult = mtBean02.withInterceptors(arResult);
 158   
 159    // compares the two values
 160  1 assertEquals(arExpected, arResult,
 161    "The method has class interceptors, a method interceptor and a protected bean interceptor method"
 162    + " declared inside the bean; however it isn't running in the correct order.");
 163    }
 164   
 165    /**
 166    * Verifies if the interceptors are following the order of declaration.
 167    * There is an interceptor inside the bean class that has public modifier
 168    * access.
 169    * @input List with no values inside
 170    * @output List with 4 values, the value inserted by the method and value
 171    * inserted by the interceptors.
 172    */
 173  1 @Test(groups = {"withInterceptor", "withInheritance"})
 174    public void testMiscInheritanceInterCallOrder00() {
 175    // The arrays used to know what is the interceptor order
 176  1 List<Integer> arResult = new ArrayList<Integer>();
 177  1 List<Integer> arExpected = new ArrayList<Integer>();
 178   
 179    // insert the value of interceptor
 180  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 181    // insert the value of interceptor
 182  1 arExpected.add(PrintOrder03Interceptor.ORDER);
 183    // insert the value of interceptor
 184  1 arExpected.add(ItfSimpleBean.EMBEDDED_INTERCEPTOR);
 185    // insert the value of the method
 186  1 arExpected.add(SLSBSimpleInterceptorTest00.ORDER);
 187   
 188    // gets the result
 189  1 arResult = mtBean00.withInterceptorsInheritance(arResult);
 190   
 191    // compares the two values
 192  1 assertEquals(arExpected, arResult,
 193    "The method has class interceptors, a method interceptor with inheritance and a public bean interceptor method"
 194    + " declared inside the bean; however it isn't running in the correct order.");
 195    }
 196   
 197    /**
 198    * Verifies if the interceptors are following the order of declaration.
 199    * There is an interceptor inside the bean class that has protected modifier
 200    * access.
 201    * @input List with no values inside
 202    * @output List with 4 values, the value inserted by the method and value
 203    * inserted by the interceptors.
 204    */
 205  1 @Test(groups = {"withInterceptor", "withInheritance"})
 206    public void testMiscInheritanceInterCallOrder01() {
 207    // The arrays used to know what is the interceptor order
 208  1 List<Integer> arResult = new ArrayList<Integer>();
 209  1 List<Integer> arExpected = new ArrayList<Integer>();
 210   
 211    // insert the value of interceptor
 212  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 213    // insert the value of interceptor
 214  1 arExpected.add(PrintOrder03Interceptor.ORDER);
 215    // insert the value of interceptor
 216  1 arExpected.add(ItfSimpleBean.EMBEDDED_INTERCEPTOR);
 217    // insert the value of the method
 218  1 arExpected.add(SLSBSimpleInterceptorTest01.ORDER);
 219   
 220    // gets the result
 221  1 arResult = mtBean01.withInterceptorsInheritance(arResult);
 222   
 223    // compares the two values
 224  1 assertEquals(arExpected, arResult,
 225    "The method has class interceptors, a method interceptor with inheritance and a protected bean interceptor method"
 226    + " declared inside the bean; however it isn't running in the correct order.");
 227    }
 228   
 229    /**
 230    * Verifies if the interceptors are following the order of declaration.
 231    * There is an interceptor inside the bean class that has private modifier
 232    * access.
 233    * @input List with no values inside
 234    * @output List with 4 values, the value inserted by the method and value
 235    * inserted by the interceptors.
 236    */
 237  1 @Test(groups = {"withInterceptor", "withInheritance"})
 238    public void testMiscInheritanceInterCallOrder02() {
 239    // The arrays used to know what is the interceptor order
 240  1 List<Integer> arResult = new ArrayList<Integer>();
 241  1 List<Integer> arExpected = new ArrayList<Integer>();
 242   
 243    // insert the value of interceptor
 244  1 arExpected.add(PrintOrder06Interceptor.ORDER);
 245    // insert the value of interceptor
 246  1 arExpected.add(PrintOrder03Interceptor.ORDER);
 247    // insert the value of interceptor
 248  1 arExpected.add(ItfSimpleBean.EMBEDDED_INTERCEPTOR);
 249    // insert the value of the method
 250  1 arExpected.add(SLSBSimpleInterceptorTest02.ORDER);
 251   
 252    // gets the result
 253  1 arResult = mtBean02.withInterceptorsInheritance(arResult);
 254   
 255    // compares the two values
 256  1 assertEquals(arExpected, arResult,
 257    "The method has class interceptors, a method interceptor with inheritance and a private bean interceptor method"
 258    + " declared inside the bean; however it isn't running in the correct order.");
 259    }
 260   
 261    /**
 262    * Verifies if the interceptors are following the order of declaration.
 263    * There is an interceptor inside the bean class that has package modifier
 264    * access.
 265    * @input List with no values inside
 266    * @output List with 3 values, the value inserted by the method and value
 267    * inserted by the interceptors.
 268    */
 269  1 @Test(groups = {"withInterceptor"})
 270    public void testMiscPackageInterCallOrder() {
 271    // The arrays used to know what is the interceptor order
 272  1 List<Integer> arResult = new ArrayList<Integer>();
 273  1 List<Integer> arExpected = new ArrayList<Integer>();
 274   
 275    // insert the value of interceptor
 276  1 arExpected.add(PrintOrder03Interceptor.ORDER);
 277    // insert the value of interceptor
 278  1 arExpected.add(ItfSimpleBean.EMBEDDED_INTERCEPTOR);
 279    // insert the value of the method
 280  1 arExpected.add(SLSBSimpleInterceptorTest03.ORDER);
 281   
 282    // gets the result
 283  1 arResult = mtBean03.withInterceptorsInheritance(arResult);
 284   
 285    // compares the two values
 286  1 assertEquals(arExpected, arResult,
 287    "The method has a method interceptor and a package level bean interceptor method"
 288    + " declared inside the bean; however it isn't running in the correct order.");
 289    }
 290   
 291    /**
 292    * Sets bean used in the tests.
 293    * @param bean00 The bean to set.
 294    * @param bean01 The bean to set.
 295    * @param bean02 The bean to set.
 296    * @param bean03 The bean to set.
 297    */
 298  7 public void setBeans(final ItfSimpleBean<Integer> bean00, final ItfSimpleBean<Integer> bean01,
 299    final ItfSimpleBean<Integer> bean02, final ItfSimpleBean<Integer> bean03) {
 300  7 this.mtBean00 = bean00;
 301  7 this.mtBean01 = bean01;
 302  7 this.mtBean02 = bean02;
 303  7 this.mtBean03 = bean03;
 304    }
 305    }