use of com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder in project pinpoint by naver.
the class ASMMethodVariablesTest method hasInterceptor.
@Test
public void hasInterceptor() throws Exception {
InterceptorRegistryBinder interceptorRegistryBinder = new DefaultInterceptorRegistryBinder();
int interceptorId = interceptorRegistryBinder.getInterceptorRegistryAdaptor().addInterceptor(new ArgsArrayInterceptor());
final InterceptorDefinition interceptorDefinition = new InterceptorDefinitionFactory().createInterceptorDefinition(ArgsArrayInterceptor.class);
final ClassNode classNode = ASMClassNodeLoader.get("com.navercorp.pinpoint.profiler.instrument.mock.ArgsClass");
List<MethodNode> methodNodes = classNode.methods;
for (MethodNode methodNode : methodNodes) {
ASMMethodNodeAdapter methodNodeAdapter = new ASMMethodNodeAdapter(classNode.name, methodNode);
assertEquals(false, methodNodeAdapter.hasInterceptor());
methodNodeAdapter.addBeforeInterceptor(interceptorId, interceptorDefinition, -1);
assertEquals(true, methodNodeAdapter.hasInterceptor());
}
}
use of com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder in project pinpoint by naver.
the class ASMMethodVariablesTest method initInterceptorLocalVariables.
@Test
public void initInterceptorLocalVariables() throws Exception {
MethodNode methodNode = ASMClassNodeLoader.get("com.navercorp.pinpoint.profiler.instrument.mock.ConstructorChildClass", "<init>");
ASMMethodVariables variables = new ASMMethodVariables("com/navercorp/pinpoint/profiler/instrument/mock/ConstructorChildClass", methodNode);
assertNull(variables.getEnterInsnNode());
assertNull(variables.getEnterInsnNode());
InterceptorRegistryBinder interceptorRegistryBinder = new DefaultInterceptorRegistryBinder();
int interceptorId = interceptorRegistryBinder.getInterceptorRegistryAdaptor().addInterceptor(new ArgsArrayInterceptor());
final InterceptorDefinition interceptorDefinition = new InterceptorDefinitionFactory().createInterceptorDefinition(ArgsArrayInterceptor.class);
InsnList instructions = new InsnList();
boolean first = variables.initInterceptorLocalVariables(instructions, interceptorId, interceptorDefinition, -1);
assertEquals(true, first);
assertNotNull(variables.getEnterInsnNode());
assertNotNull(variables.getEnterInsnNode());
}
Aggregations