Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert instrument jdbc test from groovy to java #12132

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix ut
  • Loading branch information
shalk committed Sep 10, 2024
commit f02b3e695a6c39f61571a9062bba87bfd4d0b445
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;

import com.google.common.collect.ImmutableMap;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
Expand All @@ -37,15 +37,13 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.sql.DataSource;
import org.apache.derby.jdbc.EmbeddedDataSource;
Expand Down Expand Up @@ -83,20 +81,16 @@ static void setUp() {
dbName = "jdbcUnitTest";
dbNameLower = dbName.toLowerCase(Locale.ROOT);
jdbcUrls =
Collections.unmodifiableMap(
Stream.of(
entry("h2", "jdbc:h2:mem:" + dbName),
entry("derby", "jdbc:derby:memory:" + dbName),
entry("hsqldb", "jdbc:hsqldb:mem:" + dbName))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
ImmutableMap.of(
"h2", "jdbc:h2:mem:" + dbName,
"derby", "jdbc:derby:memory:" + dbName,
"hsqldb", "jdbc:hsqldb:mem:" + dbName);

jdbcDriverClassNames =
Collections.unmodifiableMap(
Stream.of(
entry("h2", "org.h2.Driver"),
entry("derby", "org.apache.derby.jdbc.EmbeddedDriver"),
entry("hsqldb", "org.hsqldb.jdbc.JDBCDriver"))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
ImmutableMap.of(
"h2", "org.h2.Driver",
"derby", "org.apache.derby.jdbc.EmbeddedDriver",
"hsqldb", "org.hsqldb.jdbc.JDBCDriver");

jdbcUserNames = new HashMap<>();
jdbcUserNames.put("derby", "APP");
Expand Down Expand Up @@ -345,7 +339,6 @@ static Stream<Arguments> basicStatementStream() throws SQLException {
"INFORMATION_SCHEMA.SYSTEM_USERS"));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@DisplayName(
"basic statement with #connection.getClass().getCanonicalName() on #system generates spans")
@ParameterizedTest
Expand Down Expand Up @@ -1018,6 +1011,8 @@ void testGetConnection(
init.accept(datasource);
}
datasource.getConnection().close();
assertThat(testing.spans())
.noneMatch(span -> Objects.equals(span.getName(), "database.connection"));

jaydeluca marked this conversation as resolved.
Show resolved Hide resolved
testing.clearData();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public String getClientInfo(String name) throws SQLException {

@Override
public Properties getClientInfo() throws SQLException {
// TODO throwable
throw new UnsupportedOperationException("Test 123");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {

@Override
public boolean generatedKeyAlwaysReturned() throws SQLException {
;
return false;
}

Expand Down
Loading