1 22 package org.jboss.test.aop.implementz; 23 24 import org.jboss.test.aop.AOPTestWithSetup; 25 26 31 public class ImplementsTester extends AOPTestWithSetup 32 { 33 34 38 public ImplementsTester(String arg0) 39 { 40 super(arg0); 41 } 42 43 public void testImplements() throws Exception 44 { 45 System.out.println("RUNNING TEST $IMPLEMENTS"); 46 47 ImplementsPOJO pojo = new ImplementsPOJO(); 48 49 CallerInterceptor.called = false; 50 pojo.method2(); 51 assertFalse(CallerInterceptor.called); 52 53 CallerInterceptor.called = false; 54 pojo.method3(); 55 assertFalse(CallerInterceptor.called); 56 57 CallerInterceptor.called = false; 58 pojo.method3("x"); 59 assertTrue(CallerInterceptor.called); 60 61 CallerInterceptor.called = false; 62 pojo.method4(); 63 assertFalse(CallerInterceptor.called); 64 65 CallerInterceptor.called = false; 66 pojo.pojoMethod(); 67 assertFalse(CallerInterceptor.called); 68 69 ImplementsPOJOChild child = new ImplementsPOJOChild(); 70 CallerInterceptor.called = false; 71 child.method1(); 72 assertTrue(CallerInterceptor.called); 73 74 CallerInterceptor.called = false; 75 child.method1("s"); 76 assertTrue(CallerInterceptor.called); 77 78 CallerInterceptor.called = false; 79 child.method2(); 80 assertFalse(CallerInterceptor.called); 81 82 CallerInterceptor.called = false; 83 child.method3(); 84 assertFalse(CallerInterceptor.called); 85 86 CallerInterceptor.called = false; 87 child.method3("c"); 88 assertTrue(CallerInterceptor.called); 89 90 CallerInterceptor.called = false; 91 child.method4(); 92 assertFalse(CallerInterceptor.called); 93 94 CallerInterceptor.called = false; 95 child.method4("x"); 96 assertFalse(CallerInterceptor.called); 97 98 CallerInterceptor.called = false; 99 child.notImplemented(); 100 assertFalse(CallerInterceptor.called); 101 102 CallerInterceptor.called = false; 103 child.matchedUsingHas(); 104 assertTrue(CallerInterceptor.called); 105 106 CallerInterceptor.called = false; 107 child.pojoMethod(); 108 assertFalse(CallerInterceptor.called); 109 110 CallerInterceptor.called = false; 111 child.pojoChildMethod(); 112 assertFalse(CallerInterceptor.called); 113 114 CallerInterceptor.called = false; 115 child.methodAnnotated(); 116 assertTrue(CallerInterceptor.called); 117 118 ImplementsPOJOGrandChild grandChild = new ImplementsPOJOGrandChild(); 119 CallerInterceptor.called = false; 120 grandChild.pojoMethod(); 121 assertFalse(CallerInterceptor.called); 122 123 CallerInterceptor.called = false; 124 grandChild.pojoChildMethod(); 125 assertTrue(CallerInterceptor.called); 126 127 } 128 129 public void testImplementing() throws Exception 130 { 131 System.out.println("RUNNING TEST $IMPLEMENTING"); 132 133 ImplementingPOJO pojo = new ImplementingPOJO(); 134 135 CallerInterceptor.called = false; 136 pojo.method2(); 137 assertFalse(CallerInterceptor.called); 138 139 CallerInterceptor.called = false; 140 pojo.method3(); 141 assertFalse(CallerInterceptor.called); 142 143 CallerInterceptor.called = false; 144 pojo.method3("x"); 145 assertTrue(CallerInterceptor.called); 146 147 CallerInterceptor.called = false; 148 pojo.method4(); 149 assertFalse(CallerInterceptor.called); 150 151 CallerInterceptor.called = false; 152 pojo.method4("x"); 153 assertTrue(CallerInterceptor.called); 154 155 CallerInterceptor.called = false; 156 pojo.pojoMethod(); 157 assertFalse(CallerInterceptor.called); 158 159 ImplementingPOJOChild child = new ImplementingPOJOChild(); 160 CallerInterceptor.called = false; 161 child.method1(); 162 assertTrue(CallerInterceptor.called); 163 164 CallerInterceptor.called = false; 165 child.method1("s"); 166 assertTrue(CallerInterceptor.called); 167 168 CallerInterceptor.called = false; 169 child.method2(); 170 assertFalse(CallerInterceptor.called); 171 172 CallerInterceptor.called = false; 173 child.method3(); 174 assertFalse(CallerInterceptor.called); 175 176 CallerInterceptor.called = false; 177 child.method3("c"); 178 assertTrue(CallerInterceptor.called); 179 180 CallerInterceptor.called = false; 181 child.method4(); 182 assertFalse(CallerInterceptor.called); 183 184 CallerInterceptor.called = false; 185 child.method4("x"); 186 assertTrue(CallerInterceptor.called); 187 188 CallerInterceptor.called = false; 189 child.notImplemented(); 190 assertFalse(CallerInterceptor.called); 191 192 CallerInterceptor.called = false; 193 child.pojoMethod(); 194 assertFalse(CallerInterceptor.called); 195 196 CallerInterceptor.called = false; 197 child.pojoChildMethod(); 198 assertFalse(CallerInterceptor.called); 199 200 CallerInterceptor.called = false; 201 child.methodAnnotated(); 202 assertTrue(CallerInterceptor.called); 203 204 ImplementingPOJOGrandChild grandChild = new ImplementingPOJOGrandChild(); 205 CallerInterceptor.called = false; 206 grandChild.pojoMethod(); 207 assertTrue(CallerInterceptor.called); 208 209 CallerInterceptor.called = false; 210 grandChild.pojoChildMethod(); 211 assertTrue(CallerInterceptor.called); 212 213 } 214 215 } 216 | Popular Tags |