99import io .opentelemetry .instrumentation .testing .junit .InstrumentationExtension ;
1010import io .opentelemetry .instrumentation .testing .junit .LibraryInstrumentationExtension ;
1111import java .sql .Connection ;
12- import java .sql .Driver ;
13- import java .sql .DriverPropertyInfo ;
1412import java .sql .SQLException ;
15- import java .sql .SQLFeatureNotSupportedException ;
16- import java .util .Locale ;
17- import java .util .Properties ;
18- import java .util .logging .Logger ;
19- import java .util .stream .Stream ;
2013import javax .sql .DataSource ;
2114import org .junit .jupiter .api .extension .RegisterExtension ;
22- import org .junit .jupiter .params .provider .Arguments ;
2315
2416class JdbcInstrumentationTest extends AbstractJdbcInstrumentationTest {
2517
@@ -29,9 +21,6 @@ class JdbcInstrumentationTest extends AbstractJdbcInstrumentationTest {
2921 private static final LibraryJdbcTestTelemetry telemetryHelper =
3022 new LibraryJdbcTestTelemetry (testing );
3123
32- private static final String DB_NAME = "jdbcUnitTest" ;
33- private static final String DB_NAME_LOWER = DB_NAME .toLowerCase (Locale .ROOT );
34-
3524 @ Override
3625 protected InstrumentationExtension testing () {
3726 return testing ;
@@ -46,95 +35,4 @@ protected Connection wrap(Connection connection) throws SQLException {
4635 protected DataSource wrap (DataSource dataSource ) {
4736 return telemetryHelper .wrap (dataSource );
4837 }
49-
50- static Stream <Arguments > connectionConstructorStream () {
51- return Stream .of (
52- Arguments .of (
53- true ,
54- "h2" ,
55- wrapDriver (new org .h2 .Driver ()),
56- "jdbc:h2:mem:" + DB_NAME ,
57- null ,
58- "SELECT 3;" ,
59- "SELECT ?;" ,
60- "SELECT " + DB_NAME_LOWER ,
61- "h2:mem:" ,
62- null ),
63- Arguments .of (
64- true ,
65- "derby" ,
66- wrapDriver (new org .apache .derby .jdbc .EmbeddedDriver ()),
67- "jdbc:derby:memory:" + DB_NAME + ";create=true" ,
68- "APP" ,
69- "SELECT 3 FROM SYSIBM.SYSDUMMY1" ,
70- "SELECT ? FROM SYSIBM.SYSDUMMY1" ,
71- "SELECT SYSIBM.SYSDUMMY1" ,
72- "derby:memory:" ,
73- "SYSIBM.SYSDUMMY1" ),
74- Arguments .of (
75- false ,
76- "h2" ,
77- wrapDriver (new org .h2 .Driver ()),
78- "jdbc:h2:mem:" + DB_NAME ,
79- null ,
80- "SELECT 3;" ,
81- "SELECT ?;" ,
82- "SELECT " + DB_NAME_LOWER ,
83- "h2:mem:" ,
84- null ),
85- Arguments .of (
86- false ,
87- "derby" ,
88- wrapDriver (new org .apache .derby .jdbc .EmbeddedDriver ()),
89- "jdbc:derby:memory:" + DB_NAME + ";create=true" ,
90- "APP" ,
91- "SELECT 3 FROM SYSIBM.SYSDUMMY1" ,
92- "SELECT ? FROM SYSIBM.SYSDUMMY1" ,
93- "SELECT SYSIBM.SYSDUMMY1" ,
94- "derby:memory:" ,
95- "SYSIBM.SYSDUMMY1" ));
96- }
97-
98- private static Driver wrapDriver (Driver delegate ) {
99- return new Driver () {
100- @ Override
101- public Connection connect (String url , Properties info ) throws SQLException {
102- Connection connection = delegate .connect (url , info );
103- if (connection == null ) {
104- return null ;
105- }
106- return telemetryHelper .wrap (connection );
107- }
108-
109- @ Override
110- public boolean acceptsURL (String url ) throws SQLException {
111- return delegate .acceptsURL (url );
112- }
113-
114- @ Override
115- public DriverPropertyInfo [] getPropertyInfo (String url , Properties info ) throws SQLException {
116- return delegate .getPropertyInfo (url , info );
117- }
118-
119- @ Override
120- public int getMajorVersion () {
121- return delegate .getMajorVersion ();
122- }
123-
124- @ Override
125- public int getMinorVersion () {
126- return delegate .getMinorVersion ();
127- }
128-
129- @ Override
130- public boolean jdbcCompliant () {
131- return delegate .jdbcCompliant ();
132- }
133-
134- @ Override
135- public Logger getParentLogger () throws SQLFeatureNotSupportedException {
136- return delegate .getParentLogger ();
137- }
138- };
139- }
14038}
0 commit comments