use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWStatementTest method testPreparedStatementConfig.
@Test
public void testPreparedStatementConfig() throws SQLException {
Statement statement = swConnection.createStatement();
statement.cancel();
statement.getUpdateCount();
statement.setFetchDirection(1);
statement.getFetchDirection();
statement.getResultSetConcurrency();
statement.getResultSetType();
statement.isClosed();
statement.setPoolable(false);
statement.isPoolable();
statement.getWarnings();
statement.clearWarnings();
statement.setCursorName("test");
statement.setMaxFieldSize(11);
statement.getMaxFieldSize();
statement.setMaxRows(10);
statement.getMaxRows();
statement.setEscapeProcessing(true);
statement.setFetchSize(1);
statement.getFetchSize();
statement.setQueryTimeout(1);
statement.getQueryTimeout();
Connection connection = statement.getConnection();
statement.execute("SELECT * FROM test");
statement.getMoreResults();
statement.getMoreResults(1);
statement.getResultSetHoldability();
statement.getResultSet();
statement.close();
verify(mysqlStatement, times(1)).getUpdateCount();
verify(mysqlStatement, times(1)).getMoreResults();
verify(mysqlStatement, times(1)).setFetchDirection(anyInt());
verify(mysqlStatement, times(1)).getFetchDirection();
verify(mysqlStatement, times(1)).getResultSetType();
verify(mysqlStatement, times(1)).isClosed();
verify(mysqlStatement, times(1)).setPoolable(anyBoolean());
verify(mysqlStatement, times(1)).getWarnings();
verify(mysqlStatement, times(1)).clearWarnings();
verify(mysqlStatement, times(1)).setCursorName(anyString());
verify(mysqlStatement, times(1)).setMaxFieldSize(anyInt());
verify(mysqlStatement, times(1)).getMaxFieldSize();
verify(mysqlStatement, times(1)).setMaxRows(anyInt());
verify(mysqlStatement, times(1)).getMaxRows();
verify(mysqlStatement, times(1)).setEscapeProcessing(anyBoolean());
verify(mysqlStatement, times(1)).getResultSetConcurrency();
verify(mysqlStatement, times(1)).getResultSetConcurrency();
verify(mysqlStatement, times(1)).getResultSetType();
verify(mysqlStatement, times(1)).getMoreResults(anyInt());
verify(mysqlStatement, times(1)).setFetchSize(anyInt());
verify(mysqlStatement, times(1)).getFetchSize();
verify(mysqlStatement, times(1)).getQueryTimeout();
verify(mysqlStatement, times(1)).setQueryTimeout(anyInt());
verify(mysqlStatement, times(1)).getResultSet();
assertThat(connection, CoreMatchers.<Connection>is(swConnection));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/Statement/execute", "SELECT * FROM test");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWStatementTest method testExecuteWithColumnIndexes.
@Test
public void testExecuteWithColumnIndexes() throws SQLException {
Statement statement = swConnection.createStatement(1, 1, 1);
boolean executeSuccess = statement.execute("UPDATE test SET a = 1", new int[] { 1 });
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/Statement/execute", "UPDATE test SET a = 1");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWStatementTest method testExecuteQuery.
@Test
public void testExecuteQuery() throws SQLException {
Statement statement = swConnection.createStatement(1, 1, 1);
ResultSet executeSuccess = statement.executeQuery("SELECT * FROM test");
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/Statement/executeQuery", "SELECT * FROM test");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWStatementTest method testExecuteWithAutoGeneratedKey.
@Test
public void testExecuteWithAutoGeneratedKey() throws SQLException {
Statement statement = swConnection.createStatement(1, 1);
boolean executeSuccess = statement.execute("SELECT * FROM test", 1);
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/Statement/execute", "SELECT * FROM test");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWStatementTest method testExecuteUpdateWithAutoGeneratedKey.
@Test
public void testExecuteUpdateWithAutoGeneratedKey() throws SQLException {
Statement statement = swConnection.createStatement(1, 1, 1);
int executeSuccess = statement.executeUpdate("UPDATE test SET a = 1", 1);
statement.getGeneratedKeys();
verify(mysqlStatement, times(1)).getGeneratedKeys();
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/Statement/executeUpdate", "UPDATE test SET a = 1");
}
Aggregations