congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ClassInstrumenter.isByteCodeAdded
Code IndexAdd Tabnine to your IDE (free)

How to use
isByteCodeAdded
method
in
rocks.inspectit.agent.java.instrumentation.asm.ClassInstrumenter

Best Java code snippets using rocks.inspectit.agent.java.instrumentation.asm.ClassInstrumenter.isByteCodeAdded (Showing top 20 results out of 315)

origin: inspectIT/inspectIT

@Test
public void staticConstructor() throws Exception {
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockConstructor(config, InstrumentationTestClass.class, true);
  doAnswer(CONSTRUCTOR_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // create instance
  this.createInstance(TEST_CLASS_FQN, b);
  verify(hookDispatcher).dispatchConstructorBeforeBody(methodId, new Object[0]);
  verify(hookDispatcher).dispatchConstructorAfterBody(methodId, null, new Object[0]);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void constructorStringOneParameter() throws Exception {
  Object[] parameters = { "java.lang.String" };
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockConstructor(config, InstrumentationTestClass.class, false, String.class);
  doAnswer(CONSTRUCTOR_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  Class<?> clazz = createClass(TEST_CLASS_FQN, b);
  Constructor<?> constructor = clazz.getConstructor(new Class[] { String.class });
  Object instance = constructor.newInstance(parameters);
  verify(hookDispatcher).dispatchConstructorBeforeBody(methodId, parameters);
  verify(hookDispatcher).dispatchConstructorAfterBody(methodId, instance, parameters);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void constructorExceptionHandledResultReturned() throws Exception {
  Object[] parameters = { 11L };
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockConstructor(config, InstrumentationTestClass.class, false, long.class);
  doAnswer(CONSTRUCTOR_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  Class<?> clazz = createClass(TEST_CLASS_FQN, b);
  Constructor<?> constructor = clazz.getConstructor(new Class[] { long.class });
  Object instance = constructor.newInstance(parameters);
  verify(hookDispatcher).dispatchConstructorBeforeBody(methodId, parameters);
  verify(hookDispatcher).dispatchConstructorAfterBody(methodId, instance, parameters);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void constructorNullParameter() throws Exception {
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockConstructor(config, InstrumentationTestClass.class, false);
  doAnswer(CONSTRUCTOR_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // create instance
  Object instance = this.createInstance(TEST_CLASS_FQN, b);
  verify(hookDispatcher).dispatchConstructorBeforeBody(methodId, new Object[0]);
  verify(hookDispatcher).dispatchConstructorAfterBody(methodId, instance, new Object[0]);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void doubleNullParameter() throws Exception {
  String methodName = "doubleNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(SPECIAL_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  Object result = this.callMethod(testClass, methodName, null);
  assertThat(result, is((Object) Double.valueOf(5.3D)));
  verify(hookDispatcher).dispatchSpecialMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchSpecialMethodAfterBody(methodId, testClass, new Object[0], 5.3D);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void exceptionHandledResultReturned() throws Exception {
  String methodName = "exceptionHandledResultReturned";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(SPECIAL_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  Object result = this.callMethod(testClass, methodName, null);
  assertThat(result, is((Object) 3));
  verify(hookDispatcher).dispatchSpecialMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchSpecialMethodAfterBody(methodId, testClass, new Object[0], 3);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void stringNullParameterStatic() throws Exception {
  String methodName = "stringNullParameterStatic";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(SPECIAL_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  Object result = this.callMethod(testClass, methodName, null);
  assertThat(result, is((Object) methodName));
  verify(hookDispatcher).dispatchSpecialMethodBeforeBody(methodId, null, new Object[0]);
  verify(hookDispatcher).dispatchSpecialMethodAfterBody(methodId, null, new Object[0], methodName);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void stringArrayNullParameter() throws Exception {
  String methodName = "stringArrayNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(SPECIAL_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  Object result = this.callMethod(testClass, methodName, null);
  assertThat(result, is((Object) new String[] { "test123", "bla" }));
  verify(hookDispatcher).dispatchSpecialMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchSpecialMethodAfterBody(methodId, testClass, new Object[0], new String[] { "test123", "bla" });
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void stringOneParameter() throws Exception {
  String methodName = "stringOneParameter";
  Object[] parameters = { "java.lang.String" };
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName, String.class);
  doAnswer(SPECIAL_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, parameters);
  verify(hookDispatcher).dispatchSpecialMethodBeforeBody(methodId, testClass, parameters);
  verify(hookDispatcher).dispatchSpecialMethodAfterBody(methodId, testClass, parameters, "stringOneParameter");
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void doubleNullParameter() throws Exception {
  String methodName = "doubleNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, testClass, new Object[0], 5.3D, false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, testClass, new Object[0], 5.3D, false);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void shortNullParameter() throws Exception {
  String methodName = "shortNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, testClass, new Object[0], (short) 16345, false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, testClass, new Object[0], (short) 16345, false);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void intArrayNullParameter() throws Exception {
  String methodName = "intArrayNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, testClass, new Object[0], new int[] { 1, 2, 3 }, false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, testClass, new Object[0], new int[] { 1, 2, 3 }, false);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void stringArrayNullParameter() throws Exception {
  String methodName = "stringArrayNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, testClass, new Object[0], new String[] { "test123", "bla" }, false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, testClass, new Object[0], new String[] { "test123", "bla" }, false);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void floatNullParameter() throws Exception {
  String methodName = "floatNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, testClass, new Object[0], Float.MAX_VALUE, false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, testClass, new Object[0], Float.MAX_VALUE, false);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void booleanNullParameter() throws Exception {
  String methodName = "booleanNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, testClass, new Object[0], false, false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, testClass, new Object[0], false, false);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void charNullParameter() throws Exception {
  String methodName = "charNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, testClass, new Object[0], '\u1234', false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, testClass, new Object[0], '\u1234', false);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void noInstrumenatation() throws Exception {
  String methodName = "stringNullParameter";
  long methodId = 3L;
  when(sip.getId()).thenReturn(methodId);
  when(config.getTargetMethodName()).thenReturn("nonExistingMethod");
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(false));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  // call this method via reflection as we would get a class cast
  // exception by casting to the concrete class.
  this.callMethod(testClass, methodName, null);
  verifyZeroInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void byteNullParameter() throws Exception {
  String methodName = "byteNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, testClass, new Object[0], (byte) 127, false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, testClass, new Object[0], (byte) 127, false);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void voidNullParameterStatic() throws Exception {
  String methodName = "voidNullParameterStatic";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, null, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, null, new Object[0], null, false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, null, new Object[0], null, false);
  verifyNoMoreInteractions(hookDispatcher);
}
origin: inspectIT/inspectIT

@Test
public void intNullParameter() throws Exception {
  String methodName = "intNullParameter";
  long methodId = 9L;
  when(sip.getId()).thenReturn(methodId);
  prepareConfigurationMockMethod(config, InstrumentationTestClass.class, methodName);
  doAnswer(METHOD_INSTRUMENTER_ANSWER).when(instrumenterFactory).getMethodVisitor(eq(sip), Matchers.<MethodVisitor> any(), anyInt(), anyString(), anyString(), anyBoolean());
  when(config.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(sip));
  ClassReader cr = new ClassReader(TEST_CLASS_FQN);
  prepareWriter(cr, null, false, config);
  cr.accept(classInstrumenter, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
  assertThat(classInstrumenter.isByteCodeAdded(), is(true));
  byte b[] = classWriter.toByteArray();
  // now call this method
  Object testClass = this.createInstance(TEST_CLASS_FQN, b);
  this.callMethod(testClass, methodName, null);
  verify(hookDispatcher).dispatchMethodBeforeBody(methodId, testClass, new Object[0]);
  verify(hookDispatcher).dispatchFirstMethodAfterBody(methodId, testClass, new Object[0], 3, false);
  verify(hookDispatcher).dispatchSecondMethodAfterBody(methodId, testClass, new Object[0], 3, false);
  verifyNoMoreInteractions(hookDispatcher);
}
rocks.inspectit.agent.java.instrumentation.asmClassInstrumenterisByteCodeAdded

Javadoc

Returns if the byte code was added. This effectively checks if the #appliedInstrumentationConfigs is not empty.

Popular methods of ClassInstrumenter

  • <init>
    Default constructor.
  • getAppliedInstrumentationConfigs
    Gets #appliedInstrumentationConfigs.
  • matches
    If method name and description matches the MethodInstrumentationConfig.
  • shouldInstrument
    If method should be instrumented. If there is appropriate MethodInstrumentationConfigthat denotes th

Popular in Java

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • putExtra (Intent)
  • requestLocationUpdates (LocationManager)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Kernel (java.awt.image)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • JComboBox (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now