1 22 package org.jboss.test.aop.override; 23 24 import org.jboss.test.aop.AOPTestWithSetup; 25 26 import junit.framework.Test; 27 import junit.framework.TestSuite; 28 import junit.textui.TestRunner; 29 30 37 public class OverrideTestCase extends AOPTestWithSetup 38 { 39 POJO pojo = new POJO(); 40 SubPOJO subPojo = new SubPOJO(); 41 SubSubPOJO subSubPojo = new SubSubPOJO(); 42 43 public OverrideTestCase(String name) 44 { 45 super(name); 46 } 47 48 public static Test suite() 49 { 50 TestSuite suite = new TestSuite("OverrideTestCase"); 51 suite.addTestSuite(OverrideTestCase.class); 52 return suite; 53 } 54 55 58 public void testPOJOSuperOnlyMetadata() throws Exception 59 { 60 System.out.println("TEST POJO SUPERONLY METADATA"); 61 MetadataInterceptor.metadata = null; 62 pojo.superOnly(); 63 64 assertEquals("pojo.superOnly", MetadataInterceptor.metadata); 65 } 66 67 70 public void testPOJOSuperOnlyChain() throws Exception 71 { 72 System.out.println("TEST POJO SUPERONLY CHAIN"); 73 CountingInterceptor.reset(); 74 CountingAspect.reset(); 75 pojo.superOnly(); 76 77 assertEquals(4, CountingInterceptor.interceptions); 78 assertEquals(2, CountingAspect.interceptions); 79 } 80 81 84 public void testPOJOSuperOnlyNoSubMetadata() throws Exception 85 { 86 System.out.println("TEST POJO SUPERONLYNOSUB METADATA"); 87 MetadataInterceptor.metadata = null; 88 pojo.superOnlyNoSub(); 89 90 assertEquals("pojo.superOnlyNoSub", MetadataInterceptor.metadata); 91 } 92 93 96 public void testPOJOSuperOnlyNoSubChain() throws Exception 97 { 98 System.out.println("TEST POJO SUPERONLYNOSUB CHAIN"); 99 CountingInterceptor.reset(); 100 CountingAspect.reset(); 101 pojo.superOnlyNoSub(); 102 103 assertEquals(2, CountingInterceptor.interceptions); 104 assertEquals(1, CountingAspect.interceptions); 105 } 106 107 110 public void testSubSuperOnlyNoSubMetadata() throws Exception 111 { 112 System.out.println("TEST SUB SUPERONLYNOSUB METADATA"); 113 MetadataInterceptor.metadata = null; 114 subPojo.superOnlyNoSub(); 115 116 assertEquals("pojo.superOnlyNoSub", MetadataInterceptor.metadata); 117 } 118 119 122 public void testSubSubSuperOnlyNoSubMetadata() throws Exception 123 { 124 System.out.println("TEST SUB SUB SUPERONLYNOSUB METADATA"); 125 MetadataInterceptor.metadata = null; 126 subSubPojo.superOnlyNoSub(); 127 128 assertEquals("pojo.superOnlyNoSub", MetadataInterceptor.metadata); 129 } 130 131 134 public void testSubSuperOnlyNoSubChain() throws Exception 135 { 136 System.out.println("TEST SUB SUPERONLYNOSUB CHAIN"); 137 CountingInterceptor.reset(); 138 CountingAspect.reset(); 139 subPojo.superOnlyNoSub(); 140 141 assertEquals(2, CountingInterceptor.interceptions); 142 assertEquals(1, CountingAspect.interceptions); 143 } 144 145 148 public void testSubSubSuperOnlyNoSubChain() throws Exception 149 { 150 System.out.println("TEST SUB SUB SUPERONLYNOSUB CHAIN"); 151 CountingInterceptor.reset(); 152 CountingAspect.reset(); 153 subPojo.superOnlyNoSub(); 154 155 assertEquals(2, CountingInterceptor.interceptions); 156 assertEquals(1, CountingAspect.interceptions); 157 } 158 159 162 public void testPOJOOverriddenMetadata() throws Exception 163 { 164 System.out.println("TEST POJO OVERRIDDEN METADATA"); 165 MetadataInterceptor.metadata = null; 166 pojo.overridden(); 167 168 assertEquals("pojo.overridden", MetadataInterceptor.metadata); 169 } 170 171 174 public void testPOJOOverriddenChain() throws Exception 175 { 176 System.out.println("TEST POJO OVERRIDDEN CHAIN"); 177 CountingInterceptor.reset(); 178 CountingAspect.reset(); 179 pojo.overridden(); 180 181 assertEquals(2, CountingInterceptor.interceptions); 182 assertEquals(3, CountingAspect.interceptions); 183 } 184 185 188 public void testSubOverriddenMetadata() throws Exception 189 { 190 System.out.println("TEST SUB OVERRIDDEN METADATA"); 191 MetadataInterceptor.metadata = null; 192 subPojo.overridden(); 193 194 assertEquals("subpojo.overridden", MetadataInterceptor.metadata); 195 } 196 197 200 public void testSubSubOverriddenMetadata() throws Exception 201 { 202 System.out.println("TEST SUB SUB OVERRIDDEN METADATA"); 203 MetadataInterceptor.metadata = null; 204 subSubPojo.overridden(); 205 206 assertEquals("subsubpojo.overridden", MetadataInterceptor.metadata); 207 } 208 209 210 213 public void testSubOverriddenChain() throws Exception 214 { 215 System.out.println("TEST SUB OVERRIDDEN CHAIN"); 216 CountingInterceptor.reset(); 217 CountingAspect.reset(); 218 subPojo.overridden(); 219 220 assertEquals(1, CountingInterceptor.interceptions); 221 assertEquals(1, CountingAspect.interceptions); 222 } 223 224 227 public void testSubSubOverriddenChain() throws Exception 228 { 229 System.out.println("TEST SUB SUB OVERRIDDEN CHAIN"); 230 CountingInterceptor.reset(); 231 CountingAspect.reset(); 232 subSubPojo.overridden(); 233 234 assertEquals(2, CountingInterceptor.interceptions); 235 assertEquals(1, CountingAspect.interceptions); 236 } 237 238 241 public void testPOJOOverriddenNoSubMetadata() throws Exception 242 { 243 System.out.println("TEST POJO OVERRIDDEN NO SUB METADATA"); 244 MetadataInterceptor.metadata = null; 245 pojo.overriddenNoSub(); 246 247 assertEquals("pojo.overriddenNoSub", MetadataInterceptor.metadata); 248 } 249 250 253 public void testPOJOOverriddenNoSubChain() throws Exception 254 { 255 System.out.println("TEST POJO OVERRIDDEN NO SUB CHAIN"); 256 CountingInterceptor.reset(); 257 CountingAspect.reset(); 258 pojo.overriddenNoSub(); 259 260 assertEquals(5, CountingInterceptor.interceptions); 261 assertEquals(3, CountingAspect.interceptions); 262 } 263 264 267 public void testSubOverriddenNoSubMetadata() throws Exception 268 { 269 System.out.println("TEST SUB OVERRIDDEN NO SUB METADATA"); 270 MetadataInterceptor.metadata = null; 271 subPojo.overriddenNoSub(); 272 273 assertEquals(null, MetadataInterceptor.metadata); 274 } 275 276 279 public void testSubSubOverriddenNoSubMetadata() throws Exception 280 { 281 System.out.println("TEST SUB SUB OVERRIDDEN NO SUB METADATA"); 282 MetadataInterceptor.metadata = null; 283 subSubPojo.overriddenNoSub(); 284 285 assertEquals(null, MetadataInterceptor.metadata); 286 } 287 288 291 public void testSubOverriddenNoSubChain() throws Exception 292 { 293 System.out.println("TEST SUB OVERRIDDEN NO SUB CHAIN"); 294 CountingInterceptor.reset(); 295 CountingAspect.reset(); 296 subPojo.overriddenNoSub(); 297 298 assertEquals(0, CountingInterceptor.interceptions); 299 assertEquals(0, CountingAspect.interceptions); 300 } 301 302 305 public void testSubSubOverriddenNoSubChain() throws Exception 306 { 307 System.out.println("TEST SUB SUB OVERRIDDEN NO SUB CHAIN"); 308 CountingInterceptor.reset(); 309 CountingAspect.reset(); 310 subSubPojo.overriddenNoSub(); 311 312 assertEquals(0, CountingInterceptor.interceptions); 313 assertEquals(0, CountingAspect.interceptions); 314 } 315 316 317 320 public void testSubSubOnlyChain() throws Exception 321 { 322 System.out.println("TEST SUB SUB ONLY CHAIN"); 323 CountingInterceptor.reset(); 324 CountingAspect.reset(); 325 subPojo.subOnly(); 326 327 assertEquals(3, CountingInterceptor.interceptions); 328 assertEquals(2, CountingAspect.interceptions); 329 } 330 331 public static void main(String [] args) 332 { 333 TestRunner.run(suite()); 334 } 335 } 336 | Popular Tags |