1 22 package org.jboss.test.aop.jdk15.dynamic.prepareConstructor; 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 32 38 public class HotSwapEnabledTester extends AOPTestWithSetup 39 { 40 private ScenarioLoader scenarioLoader; 41 42 43 public HotSwapEnabledTester(String name) 44 { 45 super(name); 46 } 47 48 51 public void setUp() throws Exception ![JavaDoc](../../../../../../../../cmn/javadoc.gif) 52 { 53 super.setUp(); 54 this.scenarioLoader = new ScenarioLoader(((AOPTestDelegate)getDelegate()).getSystemProperties()); 55 } 56 57 61 private void assertUnwrapped(POJOWrappingInfo wrappingInfo) 62 { 63 assertFalse(wrappingInfo.isConstructorWrapped()); 64 assertFalse(wrappingInfo.isFieldReadWrapped()); 65 assertFalse(wrappingInfo.isFieldWriteWrapped()); 66 assertFalse(wrappingInfo.isMethodWrapped()); 67 } 68 69 73 private void assertFullyWrapped(POJOWrappingInfo wrappingInfo) 74 { 75 assertTrue(wrappingInfo.isConstructorWrapped()); 76 assertTrue(wrappingInfo.isFieldReadWrapped()); 77 assertTrue(wrappingInfo.isFieldWriteWrapped()); 78 assertTrue(wrappingInfo.isMethodWrapped()); 79 } 80 81 85 private void assertOnlyConstructorWrapped(POJOWrappingInfo wrappingInfo) 86 { 87 assertTrue(wrappingInfo.isConstructorWrapped()); 88 assertFalse(wrappingInfo.isFieldReadWrapped()); 89 assertFalse(wrappingInfo.isFieldWriteWrapped()); 90 assertFalse(wrappingInfo.isMethodWrapped()); 91 } 92 93 99 public void testPerClassLoadAfterInterception() throws Throwable ![JavaDoc](../../../../../../../../cmn/javadoc.gif) 100 { 101 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerClassLoadAfter(); 103 assertFullyWrapped(wrappingInfos[0]); 105 assertUnwrapped(wrappingInfos[1]); 106 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 108 assertEquals(0, instance.total); 109 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 110 assertTrue(binding.total >= 5 && binding.total <= 8); 111 assertTrue(binding.constructor >= 1 && binding.constructor <= 2); 112 assertTrue(binding.fieldRead >= 1 && binding.fieldRead <= 2); 113 assertTrue(binding.fieldWrite >= 1 && binding.fieldWrite <= 2); 114 assertEquals(2, binding.method); 115 } 116 117 123 public void testPerClassLoadBeforeInterception() throws Throwable ![JavaDoc](../../../../../../../../cmn/javadoc.gif) 124 { 125 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerClassLoadBefore(); 127 assertUnwrapped(wrappingInfos[0]); 129 assertOnlyConstructorWrapped(wrappingInfos[1]); 130 assertUnwrapped(wrappingInfos[2]); 131 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 133 assertEquals(0, instance.total); 134 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 135 assertTrue(binding.total >= 1 && binding.total <= 2); 136 assertTrue(binding.constructor >= 1 && binding.constructor <=2); 137 assertEquals(0, binding.fieldRead); 138 assertEquals(0, binding.fieldWrite); 139 assertEquals(0, binding.method); 140 } 141 142 148 public void testAddAndRemoveBindingTwice() throws Throwable ![JavaDoc](../../../../../../../../cmn/javadoc.gif) 149 { 150 POJOWrappingInfo[] wrappingInfos = scenarioLoader.addAndRemoveBindingTwice(); 152 assertUnwrapped(wrappingInfos[0]); 154 assertOnlyConstructorWrapped(wrappingInfos[1]); 155 assertUnwrapped(wrappingInfos[2]); 156 assertOnlyConstructorWrapped(wrappingInfos[3]); 157 assertUnwrapped(wrappingInfos[4]); 158 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 160 assertEquals(0, instance.total); 161 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 162 assertEquals(2, binding.total); 163 assertEquals(2, binding.constructor); 164 assertEquals(0, binding.fieldRead); 165 assertEquals(0, binding.fieldWrite); 166 assertEquals(0, binding.method); 167 } 168 169 175 public void testPerInstanceInterception() throws Throwable ![JavaDoc](../../../../../../../../cmn/javadoc.gif) 176 { 177 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerInstance(); 179 assertUnwrapped(wrappingInfos[0]); 181 assertOnlyConstructorWrapped(wrappingInfos[1]); 182 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 184 assertEquals(0, binding.total); 185 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 186 assertEquals(0, instance.total); 187 } 188 189 190 196 public void testPerInstanceGcInterception() throws Throwable ![JavaDoc](../../../../../../../../cmn/javadoc.gif) 197 { 198 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerInstanceGC(); 200 assertUnwrapped(wrappingInfos[0]); 202 assertOnlyConstructorWrapped(wrappingInfos[1]); 203 assertUnwrapped(wrappingInfos[2]); 204 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 206 assertEquals(0, binding.total); 207 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 209 assertEquals(0, instance.total); 210 } 211 212 218 public void testPerClassPerInstanceInterception() throws Throwable ![JavaDoc](../../../../../../../../cmn/javadoc.gif) 219 { 220 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerClassPerInstance(); 222 assertUnwrapped(wrappingInfos[0]); 224 assertOnlyConstructorWrapped(wrappingInfos[1]); 225 assertOnlyConstructorWrapped(wrappingInfos[2]); 226 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 228 assertEquals(1, binding.total); 229 assertEquals(1, binding.constructor); 230 assertEquals(0, binding.fieldRead); 231 assertEquals(0, binding.fieldWrite); 232 assertEquals(0, binding.method); 233 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 234 assertEquals(0, instance.total); 235 } 236 237 243 public void testPerInstancePerClassInterception() throws Throwable ![JavaDoc](../../../../../../../../cmn/javadoc.gif) 244 { 245 POJOWrappingInfo[] wrappingInfos = scenarioLoader.interceptPerInstancePerClass(); 247 assertOnlyConstructorWrapped(wrappingInfos[0]); 249 assertOnlyConstructorWrapped(wrappingInfos[1]); 250 assertOnlyConstructorWrapped(wrappingInfos[2]); 251 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 253 assertEquals(1, binding.total); 254 assertEquals(1, binding.constructor); 255 assertEquals(0, binding.fieldRead); 256 assertEquals(0, binding.fieldWrite); 257 assertEquals(0, binding.method); 258 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 259 assertEquals(0, instance.total); 260 assertEquals(0, instance.constructor); 261 } 262 263 269 public void testAfterBindingRemovalExecution() throws Throwable ![JavaDoc](../../../../../../../../cmn/javadoc.gif) 270 { 271 POJOWrappingInfo[] wrappingInfos = scenarioLoader.executeAfterBindingRemoval(); 272 assertUnwrapped(wrappingInfos[0]); 273 InterceptionsCount binding = BindingInterceptor.getInterceptionsCount(); 274 assertEquals(0, binding.total); 275 InterceptionsCount instance = InstanceInterceptor.getInterceptionsCount(); 276 assertEquals(0, instance.total); 277 } 278 } | Popular Tags |