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");
}
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);
}
Aggregations