Search in sources :

Example 1 with AroundInterceptor3

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

the class InvokeAfterCodeGeneratorTest method testGenerate_AroundInterceptor3_NoCatchClause.

@Test
public void testGenerate_AroundInterceptor3_NoCatchClause() {
    final Class<AroundInterceptor3> aroundInterceptor3Class = AroundInterceptor3.class;
    final InterceptorDefinition interceptorDefinition = interceptorDefinitionFactory.createInterceptorDefinition(aroundInterceptor3Class);
    final InstrumentClass mockClass = mock(InstrumentClass.class);
    Mockito.when(mockClass.getName()).thenReturn("TestClass");
    final InstrumentMethod mockMethod = mock(InstrumentMethod.class);
    Mockito.when(mockMethod.getName()).thenReturn("TestMethod");
    Mockito.when(mockMethod.getParameterTypes()).thenReturn(new String[] { "java.lang.Object", "java.lang.Object", "java.lang.Object" });
    Mockito.when(mockMethod.getReturnType()).thenReturn("java.lang.Object");
    ApiMetaDataService apiMetaDataService = mock(ApiMetaDataService.class);
    final InvokeAfterCodeGenerator invokeAfterCodeGenerator = new InvokeAfterCodeGenerator(100, interceptorDefinition, mockClass, mockMethod, apiMetaDataService, false, false);
    final String generate = invokeAfterCodeGenerator.generate();
    logger.debug("testGenerate_AroundInterceptor3_NoCatchClause:{}", generate);
    Assert.assertTrue(generate.contains("($w)$1"));
    Assert.assertTrue(generate.contains("($w)$2"));
    Assert.assertTrue(generate.contains("($w)$3"));
    Assert.assertTrue(generate.contains("($w)$_"));
}
Also used : AroundInterceptor3(com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor3) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService) Test(org.junit.Test)

Example 2 with AroundInterceptor3

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

the class InvokeAfterCodeGeneratorTest method testGenerate_AroundInterceptor3_catchClause.

@Test
public void testGenerate_AroundInterceptor3_catchClause() {
    final Class<AroundInterceptor3> aroundInterceptor3Class = AroundInterceptor3.class;
    final InterceptorDefinition interceptorDefinition = interceptorDefinitionFactory.createInterceptorDefinition(aroundInterceptor3Class);
    final InstrumentClass mockClass = mock(InstrumentClass.class);
    Mockito.when(mockClass.getName()).thenReturn("TestClass");
    final InstrumentMethod mockMethod = mock(InstrumentMethod.class);
    Mockito.when(mockMethod.getName()).thenReturn("TestMethod");
    Mockito.when(mockMethod.getParameterTypes()).thenReturn(new String[] { "java.lang.Object", "java.lang.Object", "java.lang.Object" });
    Mockito.when(mockMethod.getReturnType()).thenReturn("java.lang.Object");
    ApiMetaDataService apiMetaDataService = mock(ApiMetaDataService.class);
    final InvokeAfterCodeGenerator invokeAfterCodeGenerator = new InvokeAfterCodeGenerator(100, interceptorDefinition, mockClass, mockMethod, apiMetaDataService, false, true);
    final String generate = invokeAfterCodeGenerator.generate();
    logger.debug("testGenerate_AroundInterceptor3_catchClause:{}", generate);
    Assert.assertTrue(generate.contains("($w)$1"));
    Assert.assertTrue(generate.contains("($w)$2"));
    Assert.assertTrue(generate.contains("($w)$3"));
    Assert.assertTrue(generate.contains("$e"));
}
Also used : AroundInterceptor3(com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor3) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService) Test(org.junit.Test)

Example 3 with AroundInterceptor3

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

the class InvokeAfterCodeGeneratorTest method testGenerate_AroundInterceptor3_methodParam4.

@Test
public void testGenerate_AroundInterceptor3_methodParam4() {
    final Class<AroundInterceptor3> aroundInterceptor3Class = AroundInterceptor3.class;
    final InterceptorDefinition interceptorDefinition = interceptorDefinitionFactory.createInterceptorDefinition(aroundInterceptor3Class);
    final InstrumentClass mockClass = mock(InstrumentClass.class);
    Mockito.when(mockClass.getName()).thenReturn("TestClass");
    final InstrumentMethod mockMethod = mock(InstrumentMethod.class);
    Mockito.when(mockMethod.getName()).thenReturn("TestMethod");
    Mockito.when(mockMethod.getParameterTypes()).thenReturn(new String[] { "java.lang.Object", "java.lang.Object", "java.lang.Object", "java.lang.Object" });
    Mockito.when(mockMethod.getReturnType()).thenReturn("java.lang.Object");
    ApiMetaDataService apiMetaDataService = mock(ApiMetaDataService.class);
    final InvokeAfterCodeGenerator invokeAfterCodeGenerator = new InvokeAfterCodeGenerator(100, interceptorDefinition, mockClass, mockMethod, apiMetaDataService, false, true);
    final String generate = invokeAfterCodeGenerator.generate();
    logger.debug("testGenerate_AroundInterceptor3_methodParam4:{}", generate);
    Assert.assertTrue(generate.contains("($w)$1"));
    Assert.assertTrue(generate.contains("($w)$2"));
    Assert.assertTrue(generate.contains("($w)$3"));
    Assert.assertFalse(generate.contains("($w)$4"));
    Assert.assertTrue(generate.contains("$e"));
}
Also used : AroundInterceptor3(com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor3) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService) Test(org.junit.Test)

Example 4 with AroundInterceptor3

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

the class InvokeAfterCodeGeneratorTest method testGenerate_AroundInterceptor3_methodParam2.

@Test
public void testGenerate_AroundInterceptor3_methodParam2() {
    final Class<AroundInterceptor3> aroundInterceptor3Class = AroundInterceptor3.class;
    final InterceptorDefinition interceptorDefinition = interceptorDefinitionFactory.createInterceptorDefinition(aroundInterceptor3Class);
    final InstrumentClass mockClass = mock(InstrumentClass.class);
    Mockito.when(mockClass.getName()).thenReturn("TestClass");
    final InstrumentMethod mockMethod = mock(InstrumentMethod.class);
    Mockito.when(mockMethod.getName()).thenReturn("TestMethod");
    Mockito.when(mockMethod.getParameterTypes()).thenReturn(new String[] { "java.lang.Object", "java.lang.Object" });
    Mockito.when(mockMethod.getReturnType()).thenReturn("java.lang.Object");
    ApiMetaDataService apiMetaDataService = mock(ApiMetaDataService.class);
    final InvokeAfterCodeGenerator invokeAfterCodeGenerator = new InvokeAfterCodeGenerator(100, interceptorDefinition, mockClass, mockMethod, apiMetaDataService, false, true);
    final String generate = invokeAfterCodeGenerator.generate();
    logger.debug("testGenerate_AroundInterceptor3_methodParam2:{}", generate);
    Assert.assertTrue(generate.contains("($w)$1"));
    Assert.assertTrue(generate.contains("($w)$2"));
    Assert.assertFalse(generate.contains("($w)$3"));
    Assert.assertTrue(generate.contains("$e"));
}
Also used : AroundInterceptor3(com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor3) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService) Test(org.junit.Test)

Aggregations

InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)4 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)4 AroundInterceptor3 (com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor3)4 ApiMetaDataService (com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService)4 Test (org.junit.Test)4