|
18 | 18 |
|
19 | 19 | import static org.junit.Assert.*; |
20 | 20 |
|
| 21 | +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; |
21 | 22 | import com.google.api.gax.rpc.HeaderProvider; |
| 23 | +import com.google.api.gax.rpc.TransportChannelProvider; |
22 | 24 | import com.google.cloud.bigquery.exception.BigQueryJdbcException; |
| 25 | +import com.google.cloud.bigquery.storage.v1.BigQueryReadClient; |
23 | 26 | import com.google.cloud.bigquery.storage.v1.BigQueryWriteClient; |
24 | 27 | import java.io.IOException; |
25 | 28 | import java.io.InputStream; |
|
30 | 33 | import java.util.Properties; |
31 | 34 | import org.junit.Before; |
32 | 35 | import org.junit.Test; |
| 36 | +import org.threeten.bp.Duration; |
33 | 37 |
|
34 | 38 | public class BigQueryConnectionTest { |
35 | 39 |
|
@@ -340,4 +344,25 @@ public void testMetaDataFetchThreadCountProperty() throws SQLException, IOExcept |
340 | 344 | connectionCustom.getMetadataFetchThreadCount()); |
341 | 345 | } |
342 | 346 | } |
| 347 | + |
| 348 | + @Test |
| 349 | + public void testBigQueryReadClientKeepAliveSettings() throws SQLException, IOException { |
| 350 | + String url = |
| 351 | + "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" |
| 352 | + + "OAuthType=2;ProjectId=MyBigQueryProject;" |
| 353 | + + "OAuthAccessToken=redactedToken;OAuthClientId=redactedToken;" |
| 354 | + + "OAuthClientSecret=redactedToken;"; |
| 355 | + try (BigQueryConnection connection = new BigQueryConnection(url)) { |
| 356 | + BigQueryReadClient readClient = connection.getBigQueryReadClient(); |
| 357 | + assertNotNull(readClient); |
| 358 | + |
| 359 | + TransportChannelProvider provider = readClient.getSettings().getTransportChannelProvider(); |
| 360 | + assertTrue(provider instanceof InstantiatingGrpcChannelProvider); |
| 361 | + |
| 362 | + InstantiatingGrpcChannelProvider grpcProvider = (InstantiatingGrpcChannelProvider) provider; |
| 363 | + assertEquals(Duration.ofSeconds(10), grpcProvider.getKeepAliveTime()); |
| 364 | + assertEquals(Duration.ofSeconds(5), grpcProvider.getKeepAliveTimeout()); |
| 365 | + assertTrue(grpcProvider.getKeepAliveWithoutCalls()); |
| 366 | + } |
| 367 | + } |
343 | 368 | } |
0 commit comments