Codota Logo
ClassInstrumenter.isByteCodeAdded
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • setContentView (Activity)
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • JList (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Runner (org.openjdk.jmh.runner)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now