use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWCallableStatementTest method testInsertWithIntColumnIndexes.
@Test
public void testInsertWithIntColumnIndexes() throws SQLException {
CallableStatement preparedStatement = swConnection.prepareCall("INSERT INTO test VALUES(?)");
boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new int[] { 1, 2 });
preparedStatement.close();
verify(mysqlCallableStatement, times(1)).close();
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/execute", "INSERT INTO test VALUES(1)");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWCallableStatementTest method testInsertWithStringColumnIndexes.
@Test
public void testInsertWithStringColumnIndexes() throws SQLException {
CallableStatement preparedStatement = swConnection.prepareCall("INSERT INTO test VALUES(?)");
boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new String[] { "1", "2" });
preparedStatement.close();
verify(mysqlCallableStatement, times(1)).close();
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/execute", "INSERT INTO test VALUES(1)");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWCallableStatementTest method testBatch.
@Test
public void testBatch() throws SQLException, MalformedURLException {
CallableStatement preparedStatement = multiHostConnection.prepareCall("UPDATE test SET a = ? WHERE b = ?");
preparedStatement.setShort(1, (short) 12);
preparedStatement.setTime(2, new Time(System.currentTimeMillis()));
preparedStatement.addBatch();
int[] resultSet = preparedStatement.executeBatch();
preparedStatement.clearBatch();
verify(mysqlCallableStatement, times(1)).executeBatch();
verify(mysqlCallableStatement, times(1)).addBatch();
verify(mysqlCallableStatement, times(1)).clearBatch();
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeBatch", "");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWCallableStatementTest method testUpdateWithAutoGeneratedKey.
@Test
public void testUpdateWithAutoGeneratedKey() throws SQLException {
CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET a = ?");
int updateCount = preparedStatement.executeUpdate("UPDATE test SET a = 1", 1);
preparedStatement.cancel();
preparedStatement.close();
verify(mysqlCallableStatement, times(1)).close();
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeUpdate", "UPDATE test SET a = 1");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWCallableStatementTest method testUpdateWithStringColumnIndexes.
@Test
public void testUpdateWithStringColumnIndexes() throws SQLException {
CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET a = ?");
int updateCount = preparedStatement.executeUpdate("UPDATE test SET a = 1", new String[] { "1" });
preparedStatement.cancel();
preparedStatement.close();
verify(mysqlCallableStatement, times(1)).close();
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeUpdate", "UPDATE test SET a = 1");
}
Aggregations