Search in sources :

Example 1 with JdbcUrlParser

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser in project pinpoint by naver.

the class DriverConnectInterceptorTest method driverConnect.

@Test
public void driverConnect() throws SQLException {
    TraceContext traceContext = mock(TraceContext.class);
    MethodDescriptor methodDescriptor = mock(MethodDescriptor.class);
    JdbcUrlParser parser = mock(JdbcUrlParser.class);
    when(parser.parse(anyString())).thenReturn(UnKnownDatabaseInfo.INSTANCE);
    String invalidJdbcUrl = "invalidUrl";
    Driver driver = mock(Driver.class);
    DatabaseInfoAccessor setAccessor = mock(DatabaseInfoAccessor.class);
    DatabaseInfoAccessor getAccessor = mock(DatabaseInfoAccessor.class);
    SpanEventRecorder spanEventRecorder = mock(SpanEventRecorder.class);
    DriverConnectInterceptor driverConnectInterceptor = new DriverConnectInterceptor(traceContext, methodDescriptor, parser);
    driverConnectInterceptor.prepareAfterTrace(driver, va(invalidJdbcUrl), setAccessor, null);
    driverConnectInterceptor.doInAfterTrace(spanEventRecorder, driver, va(invalidJdbcUrl), getAccessor, null);
    verify(setAccessor, times(1))._$PINPOINT$_setDatabaseInfo(UnKnownDatabaseInfo.INSTANCE);
    verify(getAccessor, times(1))._$PINPOINT$_getDatabaseInfo();
}
Also used : JdbcUrlParser(com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser) DatabaseInfoAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext) Driver(java.sql.Driver) Matchers.anyString(org.mockito.Matchers.anyString) MethodDescriptor(com.navercorp.pinpoint.bootstrap.context.MethodDescriptor) Test(org.junit.Test)

Example 2 with JdbcUrlParser

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser in project pinpoint by naver.

the class DriverConnectInterceptorTest method driverConnect_return_Null_NPEtest.

@Test
public void driverConnect_return_Null_NPEtest() throws SQLException {
    TraceContext traceContext = mock(TraceContext.class);
    MethodDescriptor methodDescriptor = mock(MethodDescriptor.class);
    JdbcUrlParser parser = mock(JdbcUrlParser.class);
    when(parser.parse(anyString())).thenReturn(UnKnownDatabaseInfo.INSTANCE);
    String invalidJdbcUrl = "invalidUrl";
    final Driver driver = mock(Driver.class);
    SpanEventRecorder spanEventRecorder = mock(SpanEventRecorder.class);
    DriverConnectInterceptor driverConnectInterceptor = new DriverConnectInterceptor(traceContext, methodDescriptor, parser);
    driverConnectInterceptor.prepareAfterTrace(driver, va(invalidJdbcUrl), null, null);
    driverConnectInterceptor.doInAfterTrace(spanEventRecorder, driver, va(invalidJdbcUrl), null, null);
}
Also used : JdbcUrlParser(com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext) Driver(java.sql.Driver) Matchers.anyString(org.mockito.Matchers.anyString) MethodDescriptor(com.navercorp.pinpoint.bootstrap.context.MethodDescriptor) Test(org.junit.Test)

Aggregations

MethodDescriptor (com.navercorp.pinpoint.bootstrap.context.MethodDescriptor)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)2 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)2 JdbcUrlParser (com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser)2 Driver (java.sql.Driver)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 DatabaseInfoAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor)1