Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class SpannerOptions extends ServiceOptions<Spanner, SpannerOptions> {
private static final String JDBC_API_CLIENT_LIB_TOKEN = "sp-jdbc";
private static final String HIBERNATE_API_CLIENT_LIB_TOKEN = "sp-hib";
private static final String LIQUIBASE_API_CLIENT_LIB_TOKEN = "sp-liq";
private static final String PG_ADAPTER_CLIENT_LIB_TOKEN = "pg-adapter";

private static final String API_SHORT_NAME = "Spanner";
private static final String DEFAULT_HOST = "https://spanner.googleapis.com";
Expand Down Expand Up @@ -657,7 +658,8 @@ public static class Builder
ServiceOptions.getGoogApiClientLibName(),
JDBC_API_CLIENT_LIB_TOKEN,
HIBERNATE_API_CLIENT_LIB_TOKEN,
LIQUIBASE_API_CLIENT_LIB_TOKEN);
LIQUIBASE_API_CLIENT_LIB_TOKEN,
PG_ADAPTER_CLIENT_LIB_TOKEN);
private TransportChannelProvider channelProvider;

@SuppressWarnings("rawtypes")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ public void testDoNotCacheClosedSpannerInstance() {
public void testSetClientLibToken() {
final String jdbcToken = "sp-jdbc";
final String hibernateToken = "sp-hib";
final String pgAdapterToken = "pg-adapter";
SpannerOptions options =
SpannerOptions.newBuilder()
.setProjectId("some-project")
Expand All @@ -518,6 +519,14 @@ public void testSetClientLibToken() {
.build();
assertThat(options.getClientLibToken()).isEqualTo(hibernateToken);

options =
SpannerOptions.newBuilder()
.setProjectId("some-project")
.setCredentials(NoCredentials.getInstance())
.setClientLibToken(pgAdapterToken)
.build();
assertThat(options.getClientLibToken()).isEqualTo(pgAdapterToken);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we prefer the use of assertEquals(expected, actual) (add import static org.junit.Assert.assertEquals at the top of the file to import it)

I know that it is not consistent with the other tests here, but the general rule of thumb is to use this method for new code, even when it is different from the surrounding code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @olavloite for mentioning this. I've changed it and will remember this in future


options =
SpannerOptions.newBuilder()
.setProjectId("some-project")
Expand Down