@Test public void constructorEnchancedExceptionSensor() { long id = 7L; String name = "method"; String desc = "()V"; boolean enhancedExceptionSensor = true; when(sensorInstrumentationPoint.isConstructor()).thenReturn(true); when(sensorInstrumentationPoint.getId()).thenReturn(id); MethodVisitor methodVisitor = factory.getMethodVisitor(sensorInstrumentationPoint, superMethodVisitor, 0, name, desc, enhancedExceptionSensor); assertThat(methodVisitor, is(instanceOf(ConstructorInstrumenter.class))); ConstructorInstrumenter methodInstrumenter = (ConstructorInstrumenter) methodVisitor; assertThat(methodInstrumenter.getMethodId(), is(id)); assertThat(methodInstrumenter.isEnhancedExceptionSensor(), is(enhancedExceptionSensor)); }
@Test public void method() { long id = 7L; String name = "method"; String desc = "()V"; boolean enhancedExceptionSensor = false; when(sensorInstrumentationPoint.isConstructor()).thenReturn(false); when(sensorInstrumentationPoint.getId()).thenReturn(id); MethodVisitor methodVisitor = factory.getMethodVisitor(sensorInstrumentationPoint, superMethodVisitor, 0, name, desc, enhancedExceptionSensor); assertThat(methodVisitor, is(instanceOf(MethodInstrumenter.class))); MethodInstrumenter methodInstrumenter = (MethodInstrumenter) methodVisitor; assertThat(methodInstrumenter.getMethodId(), is(id)); assertThat(methodInstrumenter.isEnhancedExceptionSensor(), is(enhancedExceptionSensor)); }
@Test public void methodEnchancedExceptionSensor() { long id = 7L; String name = "method"; String desc = "()V"; boolean enhancedExceptionSensor = true; when(sensorInstrumentationPoint.isConstructor()).thenReturn(false); when(sensorInstrumentationPoint.getId()).thenReturn(id); MethodVisitor methodVisitor = factory.getMethodVisitor(sensorInstrumentationPoint, superMethodVisitor, 0, name, desc, enhancedExceptionSensor); assertThat(methodVisitor, is(instanceOf(MethodInstrumenter.class))); MethodInstrumenter methodInstrumenter = (MethodInstrumenter) methodVisitor; assertThat(methodInstrumenter.getMethodId(), is(id)); assertThat(methodInstrumenter.isEnhancedExceptionSensor(), is(enhancedExceptionSensor)); }
@Test public void constructor() { long id = 7L; String name = "method"; String desc = "()V"; boolean enhancedExceptionSensor = false; when(sensorInstrumentationPoint.isConstructor()).thenReturn(true); when(sensorInstrumentationPoint.getId()).thenReturn(id); MethodVisitor methodVisitor = factory.getMethodVisitor(sensorInstrumentationPoint, superMethodVisitor, 0, name, desc, enhancedExceptionSensor); assertThat(methodVisitor, is(instanceOf(ConstructorInstrumenter.class))); ConstructorInstrumenter methodInstrumenter = (ConstructorInstrumenter) methodVisitor; assertThat(methodInstrumenter.getMethodId(), is(id)); assertThat(methodInstrumenter.isEnhancedExceptionSensor(), is(enhancedExceptionSensor)); }
if (sensorInstrumentationPoint.isConstructor()) { return new ConstructorInstrumenter(superMethodVisitor, access, name, desc, sensorInstrumentationPoint.getId(), enhancedExceptionSensor); } else {
assertThat(rsc.getId(), is(methodId)); assertThat(rsc.getSensorIds().length, is(0)); assertThat(rsc.isConstructor(), is(false)); SpecialInstrumentationPoint ssc = instrumentationConfig.getSpecialInstrumentationPoint(); assertThat(ssc.getId(), is(methodId));
assertThat(rsc.getId(), is(methodId)); assertThat(rsc.getSensorIds().length, is(0)); assertThat(rsc.isConstructor(), is(true)); SpecialInstrumentationPoint ssc = instrumentationConfig.getSpecialInstrumentationPoint(); assertThat(ssc.getId(), is(methodId));