Merge pull request #319 from ascrutae/wu-sheng-patch-db-operationName

add prepared statement test case
This commit is contained in:
吴晟 Wu Sheng 2017-07-28 14:06:20 +08:00 committed by GitHub
commit fbf9bf9748
1 changed files with 16 additions and 1 deletions

View File

@ -298,6 +298,21 @@ public class SwPreparedStatementTest extends AbstractStatementTest {
assertDBSpan(spans.get(0), "Mysql/JDBI/PreparedStatement/executeQuery", "SELECT * FROM test");
}
@Test
public void testExecute() throws SQLException {
PreparedStatement preparedStatement = swConnection.prepareStatement("SELECT * FROM test", 1, 1, 1);
preparedStatement.execute();
preparedStatement.close();
verify(mysqlPreparedStatement, times(1)).execute();
verify(mysqlPreparedStatement, times(1)).close();
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/PreparedStatement/execute", "SELECT * FROM test");
}
@Test
public void testQuerySqlWithSql() throws SQLException {
PreparedStatement preparedStatement = swConnection.prepareStatement("SELECT * FROM test", 1);
@ -359,7 +374,7 @@ public class SwPreparedStatementTest extends AbstractStatementTest {
}
@Test
public void testExecute() throws SQLException {
public void testExecuteWithSQL() throws SQLException {
PreparedStatement preparedStatement = swConnection.prepareStatement("UPDATE test SET a = ?");
preparedStatement.setString(1, "a");
boolean updateCount = preparedStatement.execute("UPDATE test SET a = 1");