1 22 package org.jboss.test.aop.invoketarget; 23 24 import junit.framework.Assert; 25 26 31 public class CallingPOJO 32 { 33 public CallingPOJO() 34 { 35 BypassInterceptor.invocations = 0; 36 CountingInterceptor.invocations = 0; 37 CalledPOJO pojo = new CalledPOJO("Test"); 38 Assert.assertEquals("Test", pojo.plain); 40 Assert.assertEquals(1, BypassInterceptor.invocations); 41 Assert.assertEquals(1, CountingInterceptor.invocations); 42 43 BypassInterceptor.invocations = 0; 44 CountingInterceptor.invocations = 0; 45 pojo.test(); 46 Assert.assertEquals(1, BypassInterceptor.invocations); 47 Assert.assertEquals(1, CountingInterceptor.invocations); 48 49 BypassInterceptor.invocations = 0; 50 CountingInterceptor.invocations = 0; 51 String s = pojo.echo("Hello"); 52 Assert.assertEquals("Hello", s); 53 Assert.assertEquals(1, BypassInterceptor.invocations); 54 Assert.assertEquals(1, CountingInterceptor.invocations); 55 56 BypassInterceptor.invocations = 0; 57 CountingInterceptor.invocations = 0; 58 int i = pojo.echo(100); 59 Assert.assertEquals(100, i); 60 Assert.assertEquals(1, BypassInterceptor.invocations); 61 Assert.assertEquals(1, CountingInterceptor.invocations); 62 } 63 64 public static void testStatic() 65 { 66 BypassInterceptor.invocations = 0; 67 CountingInterceptor.invocations = 0; 68 CalledPOJO pojo = new CalledPOJO("Test"); 69 Assert.assertEquals("Test", pojo.plain); 71 Assert.assertEquals(1, BypassInterceptor.invocations); 72 Assert.assertEquals(1, CountingInterceptor.invocations); 73 74 BypassInterceptor.invocations = 0; 75 CountingInterceptor.invocations = 0; 76 pojo.test(); 77 Assert.assertEquals(1, BypassInterceptor.invocations); 78 Assert.assertEquals(1, CountingInterceptor.invocations); 79 80 BypassInterceptor.invocations = 0; 81 CountingInterceptor.invocations = 0; 82 String s = pojo.echo("Hello"); 83 Assert.assertEquals("Hello", s); 84 Assert.assertEquals(1, BypassInterceptor.invocations); 85 Assert.assertEquals(1, CountingInterceptor.invocations); 86 87 BypassInterceptor.invocations = 0; 88 CountingInterceptor.invocations = 0; 89 int i = pojo.echo(100); 90 Assert.assertEquals(100, i); 91 Assert.assertEquals(1, BypassInterceptor.invocations); 92 Assert.assertEquals(1, CountingInterceptor.invocations); 93 } 94 95 public void test() 96 { 97 BypassInterceptor.invocations = 0; 98 CountingInterceptor.invocations = 0; 99 CalledPOJO pojo = new CalledPOJO("Test"); 100 Assert.assertEquals("Test", pojo.plain); 102 Assert.assertEquals(1, BypassInterceptor.invocations); 103 Assert.assertEquals(1, CountingInterceptor.invocations); 104 105 BypassInterceptor.invocations = 0; 106 CountingInterceptor.invocations = 0; 107 pojo.test(); 108 Assert.assertEquals(1, BypassInterceptor.invocations); 109 Assert.assertEquals(1, CountingInterceptor.invocations); 110 111 BypassInterceptor.invocations = 0; 112 CountingInterceptor.invocations = 0; 113 String s = pojo.echo("Hello"); 114 Assert.assertEquals("Hello", s); 115 Assert.assertEquals(1, BypassInterceptor.invocations); 116 Assert.assertEquals(1, CountingInterceptor.invocations); 117 118 BypassInterceptor.invocations = 0; 119 CountingInterceptor.invocations = 0; 120 int i = pojo.echo(100); 121 Assert.assertEquals(100, i); 122 Assert.assertEquals(1, BypassInterceptor.invocations); 123 Assert.assertEquals(1, CountingInterceptor.invocations); 124 } 125 126 } 127 | Popular Tags |