use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan 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.AbstractTracingSpan 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.AbstractTracingSpan 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");
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class SWConnectionTest method testCloseWithException.
@Test(expected = SQLException.class)
public void testCloseWithException() throws SQLException {
doThrow(new SQLException()).when(jdbcConnection).close();
swConnection.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/Connection/close");
assertDBSpanLog(SpanHelper.getLogs(spans.get(0)).get(0));
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class SWConnectionTest method testRollBackWithException.
@Test(expected = SQLException.class)
public void testRollBackWithException() throws SQLException {
doThrow(new SQLException()).when(jdbcConnection).rollback();
swConnection.rollback();
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/Connection/rollback");
}
Aggregations