Search in sources :

Example 6 with Interceptor

use of com.navercorp.pinpoint.bootstrap.interceptor.Interceptor in project pinpoint by naver.

the class AnnotatedInterceptorFactoryTest method test12.

@Test
public void test12() throws Exception {
    AnnotatedInterceptorFactory factory = newAnnotatedInterceptorFactory();
    Interceptor interceptor = factory.getInterceptor(getClass().getClassLoader(), TestInterceptor2.class.getName(), null, null, null, instrumentClass, instrumentMethod);
    assertEquals(TestInterceptor2.class, interceptor.getClass());
    assertEquals(null, getField(interceptor, "field0"));
    assertEquals(0, getField(interceptor, "field1"));
    assertEquals(0.0, getField(interceptor, "field2"));
    assertEquals(false, getField(interceptor, "field3"));
    assertEquals(0L, getField(interceptor, "field4"));
    assertSame(descriptor, getField(interceptor, "descriptor"));
    assertSame(instrumentClass, getField(interceptor, "targetClass"));
    assertSame(instrumentMethod, getField(interceptor, "targetMethod"));
}
Also used : TestInterceptor2(com.navercorp.pinpoint.profiler.plugin.TestInterceptors.TestInterceptor2) Interceptor(com.navercorp.pinpoint.bootstrap.interceptor.Interceptor) AnnotatedInterceptorFactory(com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory) Test(org.junit.Test)

Example 7 with Interceptor

use of com.navercorp.pinpoint.bootstrap.interceptor.Interceptor in project pinpoint by naver.

the class AnnotatedInterceptorFactoryTest method test9.

@Test
public void test9() throws Exception {
    Object[] args = new Object[] { "arg0", 1, 2.0, true, 3L };
    AnnotatedInterceptorFactory factory = newAnnotatedInterceptorFactory();
    Interceptor interceptor = factory.getInterceptor(getClass().getClassLoader(), TestInterceptor2.class.getName(), args, null, null, instrumentClass, instrumentMethod);
    assertEquals(TestInterceptor2.class, interceptor.getClass());
    assertEquals(args[0], getField(interceptor, "field0"));
    assertEquals(args[1], getField(interceptor, "field1"));
    assertEquals(args[2], getField(interceptor, "field2"));
    assertEquals(args[3], getField(interceptor, "field3"));
    assertEquals(args[4], getField(interceptor, "field4"));
    assertSame(descriptor, getField(interceptor, "descriptor"));
    assertSame(instrumentClass, getField(interceptor, "targetClass"));
    assertSame(instrumentMethod, getField(interceptor, "targetMethod"));
}
Also used : TestInterceptor2(com.navercorp.pinpoint.profiler.plugin.TestInterceptors.TestInterceptor2) Interceptor(com.navercorp.pinpoint.bootstrap.interceptor.Interceptor) AnnotatedInterceptorFactory(com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory) Test(org.junit.Test)

Example 8 with Interceptor

use of com.navercorp.pinpoint.bootstrap.interceptor.Interceptor in project pinpoint by naver.

the class AnnotatedInterceptorFactoryTest method test14.

@Test
public void test14() throws Exception {
    String arg0 = "arg0";
    Object[] args = new Object[] { ObjectFactory.byConstructor("java.lang.String", arg0) };
    AnnotatedInterceptorFactory factory = newAnnotatedInterceptorFactory();
    Interceptor interceptor = factory.getInterceptor(getClass().getClassLoader(), TestInterceptor0.class.getName(), args, null, null, instrumentClass, instrumentMethod);
    assertEquals(TestInterceptor0.class, interceptor.getClass());
    assertEquals(arg0, getField(interceptor, "field0"));
}
Also used : TestInterceptor0(com.navercorp.pinpoint.profiler.plugin.TestInterceptors.TestInterceptor0) Interceptor(com.navercorp.pinpoint.bootstrap.interceptor.Interceptor) AnnotatedInterceptorFactory(com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory) Test(org.junit.Test)

Example 9 with Interceptor

use of com.navercorp.pinpoint.bootstrap.interceptor.Interceptor in project pinpoint by naver.

the class AnnotatedInterceptorFactoryTest method test13.

@Test
public void test13() throws Exception {
    Object[] args = new Object[] { "arg0" };
    AnnotatedInterceptorFactory factory = newAnnotatedInterceptorFactory();
    Interceptor interceptor = factory.getInterceptor(getClass().getClassLoader(), TestInterceptor2.class.getName(), args, null, null, instrumentClass, instrumentMethod);
    assertEquals(TestInterceptor2.class, interceptor.getClass());
    assertEquals(args[0], getField(interceptor, "field0"));
    assertEquals(0, getField(interceptor, "field1"));
    assertEquals(0.0, getField(interceptor, "field2"));
    assertEquals(false, getField(interceptor, "field3"));
    assertEquals(0L, getField(interceptor, "field4"));
    assertSame(descriptor, getField(interceptor, "descriptor"));
    assertSame(instrumentClass, getField(interceptor, "targetClass"));
    assertNull(getField(interceptor, "targetMethod"));
}
Also used : TestInterceptor2(com.navercorp.pinpoint.profiler.plugin.TestInterceptors.TestInterceptor2) Interceptor(com.navercorp.pinpoint.bootstrap.interceptor.Interceptor) AnnotatedInterceptorFactory(com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory) Test(org.junit.Test)

Example 10 with Interceptor

use of com.navercorp.pinpoint.bootstrap.interceptor.Interceptor in project pinpoint by naver.

the class AnnotatedInterceptorFactoryTest method test0.

@Test
public void test0() throws Exception {
    AnnotatedInterceptorFactory factory = newAnnotatedInterceptorFactory();
    Interceptor interceptor = factory.getInterceptor(getClass().getClassLoader(), TestInterceptor0.class.getName(), null, null, null, instrumentClass, instrumentMethod);
    assertEquals(TestInterceptor0.class, interceptor.getClass());
}
Also used : TestInterceptor0(com.navercorp.pinpoint.profiler.plugin.TestInterceptors.TestInterceptor0) Interceptor(com.navercorp.pinpoint.bootstrap.interceptor.Interceptor) AnnotatedInterceptorFactory(com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory) Test(org.junit.Test)

Aggregations

Interceptor (com.navercorp.pinpoint.bootstrap.interceptor.Interceptor)22 AnnotatedInterceptorFactory (com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory)14 Test (org.junit.Test)14 TestInterceptor2 (com.navercorp.pinpoint.profiler.plugin.TestInterceptors.TestInterceptor2)5 TestInterceptor1 (com.navercorp.pinpoint.profiler.plugin.TestInterceptors.TestInterceptor1)4 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)3 TestInterceptor0 (com.navercorp.pinpoint.profiler.plugin.TestInterceptors.TestInterceptor0)3 Method (java.lang.reflect.Method)3 InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)2 InstrumentException (com.navercorp.pinpoint.bootstrap.instrument.InstrumentException)2 Instrumentor (com.navercorp.pinpoint.bootstrap.instrument.Instrumentor)2 TransformCallback (com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)2 TestClassLoader (com.navercorp.pinpoint.test.classloader.TestClassLoader)2 ProtectionDomain (java.security.ProtectionDomain)2 ApiIdAwareAroundInterceptor (com.navercorp.pinpoint.bootstrap.interceptor.ApiIdAwareAroundInterceptor)1 AroundInterceptor (com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor)1 ExceptionHandleApiIdAwareAroundInterceptor (com.navercorp.pinpoint.bootstrap.interceptor.ExceptionHandleApiIdAwareAroundInterceptor)1 ExceptionHandleAroundInterceptor (com.navercorp.pinpoint.bootstrap.interceptor.ExceptionHandleAroundInterceptor)1 ExceptionHandleStaticAroundInterceptor (com.navercorp.pinpoint.bootstrap.interceptor.ExceptionHandleStaticAroundInterceptor)1 StaticAroundInterceptor (com.navercorp.pinpoint.bootstrap.interceptor.StaticAroundInterceptor)1