Search in sources :

Example 6 with InstrumentEngine

use of com.navercorp.pinpoint.profiler.instrument.InstrumentEngine in project pinpoint by naver.

the class JavassistClassTest method testClassHierarchy.

@Test
public void testClassHierarchy() throws InstrumentException {
    InstrumentEngine engine = newJavassistEngine();
    InstrumentContext instrumentContext = mock(InstrumentContext.class);
    String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
    byte[] testObjectByteCode = readByteCode(testObjectName);
    InstrumentClass testObject = engine.getClass(instrumentContext, null, testObjectName, testObjectByteCode);
    Assert.assertEquals(testObject.getName(), testObjectName);
    String testObjectSuperClass = testObject.getSuperClass();
    Assert.assertEquals("java.lang.Object", testObjectSuperClass);
    String[] testObjectSuperClassInterfaces = testObject.getInterfaces();
    Assert.assertEquals(testObjectSuperClassInterfaces.length, 0);
    final String classHierarchyTestMockName = "com.navercorp.pinpoint.test.javasssit.mock.ClassHierarchyTestMock";
    byte[] classHierarchyTestMockByteCode = readByteCode(classHierarchyTestMockName);
    InstrumentClass classHierarchyObject = engine.getClass(instrumentContext, null, classHierarchyTestMockName, classHierarchyTestMockByteCode);
    String hierarchySuperClass = classHierarchyObject.getSuperClass();
    Assert.assertEquals("java.util.HashMap", hierarchySuperClass);
    String[] hierarchyInterfaces = classHierarchyObject.getInterfaces();
    Assert.assertEquals(hierarchyInterfaces.length, 2);
    Assert.assertEquals(hierarchyInterfaces[0], "java.lang.Runnable");
    Assert.assertEquals(hierarchyInterfaces[1], "java.lang.Comparable");
}
Also used : InstrumentContext(com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentEngine(com.navercorp.pinpoint.profiler.instrument.InstrumentEngine) Test(org.junit.Test)

Example 7 with InstrumentEngine

use of com.navercorp.pinpoint.profiler.instrument.InstrumentEngine in project pinpoint by naver.

the class JavassistClassTest method testDeclaredMethod.

@Test
public void testDeclaredMethod() throws InstrumentException {
    InstrumentEngine engine = newJavassistEngine();
    InstrumentContext instrumentContext = mock(InstrumentContext.class);
    String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
    byte[] testObjectByteCode = readByteCode(testObjectName);
    InstrumentClass testObject = engine.getClass(instrumentContext, null, testObjectName, testObjectByteCode);
    Assert.assertEquals(testObject.getName(), testObjectName);
    InstrumentMethod declaredMethod = testObject.getDeclaredMethod("callA");
    Assert.assertNotNull(declaredMethod);
}
Also used : InstrumentContext(com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod) InstrumentEngine(com.navercorp.pinpoint.profiler.instrument.InstrumentEngine) Test(org.junit.Test)

Aggregations

InstrumentEngine (com.navercorp.pinpoint.profiler.instrument.InstrumentEngine)7 InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)6 InstrumentContext (com.navercorp.pinpoint.bootstrap.instrument.InstrumentContext)6 Test (org.junit.Test)6 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)3 MethodDescriptor (com.navercorp.pinpoint.bootstrap.context.MethodDescriptor)1 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)1 ApplicationContext (com.navercorp.pinpoint.profiler.context.module.ApplicationContext)1 ASMEngine (com.navercorp.pinpoint.profiler.instrument.ASMEngine)1 JavassistEngine (com.navercorp.pinpoint.profiler.instrument.JavassistEngine)1 ClassPool (javassist.ClassPool)1