1 22 package org.jboss.test.aop.jdk15.dynamic.prepareField; 23 24 import org.jboss.test.aop.AOPTestDelegate; 25 import org.jboss.test.aop.AOPTestWithSetup; 26 import org.jboss.test.aop.jdk15.dynamic.common.BindingInterceptor; 27 import org.jboss.test.aop.jdk15.dynamic.common.InstanceInterceptor; 28 import org.jboss.test.aop.jdk15.dynamic.common.InterceptionsCount; 29 import org.jboss.test.aop.jdk15.dynamic.common.POJOWrappingInfo; 30 import org.jboss.test.aop.jdk15.dynamic.common.ScenarioLoader; 31 import org.jboss.test.aop.jdk15.dynamic.common.scenario.ScenarioRunner; 32 33 39 public class HotSwapDisabledTester extends AOPTestWithSetup 40 { 41 private ScenarioLoader scenarioLoader; 42 43 public HotSwapDisabledTester(String name) 44 { 45 super(name); 46 } 47 48 51 public void setUp() throws Exception 52 { 53 super.setUp(); 54 this.scenarioLoader = new ScenarioLoader(((AOPTestDelegate)getDelegate()).getSystemProperties()); 55 } 56 57 61 private void assertOnlyFieldWrapped(POJOWrappingInfo[] wrappingInfos) throws Exception 62 { 63 for (int i = 0; i < wrappingInfos.length; i++) 64 { 65 assertFalse(wrappingInfos[i].isConstructorWrapped()); 66 assertTrue(wrappingInfos[i].isFieldReadWrapped()); 67 assertTrue(wrappingInfos[i].isFieldWriteWrapped()); 68 assertFalse(wrappingInfos[i].isMethodWrapped()); 69 } 70 } 71 72 78 public void testPerClassLoadAfterInterception() throws Throwable 79 { 80 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerClassLoadAfter(); 82 if (((AOPTestDelegate)getDelegate()).getSystemProperties().getProperty("java5Agent") != null) 84 { 85 for (int i = 0; i < wrappingInfos.length; i++) 87 { 88 assertTrue(wrappingInfos[i].isConstructorWrapped()); 89 assertTrue(wrappingInfos[i].isFieldReadWrapped()); 90 assertTrue(wrappingInfos[i].isFieldWriteWrapped()); 91 assertTrue(wrappingInfos[i].isMethodWrapped()); 92 } 93 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 95 assertEquals(0, instance.total); 96 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 97 assertEquals(6, binding.total); 98 assertEquals(0, binding.constructor); 99 assertEquals(2, binding.fieldRead); 100 assertEquals(2, binding.fieldWrite); 101 assertEquals(2, binding.method); 102 return; 103 } 104 assertOnlyFieldWrapped(wrappingInfos); 106 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 108 assertEquals(0, instance.total); 109 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 110 assertEquals(4, binding.total); 111 assertEquals(0, binding.constructor); 112 assertEquals(2, binding.fieldRead); 113 assertEquals(2, binding.fieldWrite); 114 assertEquals(0, binding.method); 115 } 116 117 123 public void testPerClassLoadBeforeInterception() throws Throwable 124 { 125 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerClassLoadBefore(); 127 assertOnlyFieldWrapped(wrappingInfos); 129 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 131 assertEquals(0, instance.total); 132 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 133 assertEquals(2, binding.total); 134 assertEquals(0, binding.constructor); 135 assertEquals(1, binding.fieldRead); 136 assertEquals(1, binding.fieldWrite); 137 assertEquals(0, binding.method); 138 } 139 140 146 public void testAddAndRemoveBindingTwice() throws Throwable 147 { 148 POJOWrappingInfo[] wrappingInfos = scenarioLoader.addAndRemoveBindingTwice(); 150 assertOnlyFieldWrapped(wrappingInfos); 152 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 154 assertEquals(0, instance.total); 155 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 156 assertEquals(4, binding.total); 157 assertEquals(0, binding.constructor); 158 assertEquals(2, binding.fieldRead); 159 assertEquals(2, binding.fieldWrite); 160 assertEquals(0, binding.method); 161 } 162 163 169 public void testPerInstanceInterception() throws Throwable 170 { 171 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerInstance(); 173 assertOnlyFieldWrapped(wrappingInfos); 175 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 177 assertEquals(0, binding.total); 178 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 179 assertEquals(4, instance.total); 180 assertEquals(0, binding.constructor); 181 assertEquals(2, instance.fieldRead); 182 assertEquals(2, instance.fieldWrite); 183 assertEquals(0, binding.method); 184 } 185 186 192 public void testPerInstanceGcInterception() throws Throwable 193 { 194 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerInstanceGC(); 196 assertOnlyFieldWrapped(wrappingInfos); 198 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 200 assertEquals(0, binding.total); 201 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 202 assertEquals(4, instance.total); 203 assertEquals(0, instance.constructor); 204 assertEquals(2, instance.fieldRead); 205 assertEquals(2, instance.fieldWrite); 206 assertEquals(0, instance.method); 207 } 208 209 215 public void testPerClassPerInstanceInterception() throws Throwable 216 { 217 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerClassPerInstance(); 219 assertOnlyFieldWrapped(wrappingInfos); 221 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 223 assertEquals(2, binding.total); 224 assertEquals(0, binding.constructor); 225 assertEquals(1, binding.fieldRead); 226 assertEquals(1, binding.fieldWrite); 227 assertEquals(0, binding.method); 228 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 229 assertEquals(2, instance.total); 230 assertEquals(0, instance.constructor); 231 assertEquals(1, instance.fieldRead); 232 assertEquals(1, instance.fieldWrite); 233 assertEquals(0, instance.method); 234 } 235 236 242 public void testPerInstancePerClassInterception() throws Throwable 243 { 244 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerInstancePerClass(); 246 assertOnlyFieldWrapped(wrappingInfos); 248 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 250 assertEquals(2, binding.total); 251 assertEquals(0, binding.constructor); 252 assertEquals(1, binding.fieldRead); 253 assertEquals(1, binding.fieldWrite); 254 assertEquals(0, binding.method); 255 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 256 assertEquals(6, instance.total); 257 assertEquals(0, instance.constructor); 258 assertEquals(3, instance.fieldRead); 259 assertEquals(3, instance.fieldWrite); 260 assertEquals(0, instance.method); 261 } 262 263 269 public void testAfterBindingRemovalExecution() throws Throwable 270 { 271 POJOWrappingInfo[] wrappingInfos = scenarioLoader.executeAfterBindingRemoval(); 273 assertOnlyFieldWrapped(wrappingInfos); 275 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 277 assertEquals(0, binding.total); 278 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 279 assertEquals(0, instance.total); 280 } 281 } | Popular Tags |