From 3c44fa7acc84f2fc9f93d66a2e01bd0b633c35a2 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Wed, 10 Jun 2026 20:07:17 +0000 Subject: [PATCH 1/4] chore(bigquery-jdbc): refactor tests to remove hardcoded base uri --- .../cloud/bigquery/jdbc/it/ITAuthTests.java | 23 +- .../google/cloud/bigquery/jdbc/it/ITBase.java | 14 +- .../bigquery/jdbc/it/ITBigQueryJDBCTest.java | 220 ++++-------------- .../jdbc/it/ITCallableStatementTest.java | 5 +- .../jdbc/it/ITConnectionPoolingTest.java | 46 ++-- .../bigquery/jdbc/it/ITConnectionTest.java | 3 +- .../jdbc/it/ITDatabaseMetadataTest.java | 31 +-- .../jdbc/it/ITNightlyBigQueryTest.java | 81 ++----- .../jdbc/it/ITResultSetMetadataTest.java | 2 +- .../bigquery/jdbc/it/ITStatementTest.java | 18 +- .../bigquery/jdbc/utils/TestUtilities.java | 25 ++ 11 files changed, 129 insertions(+), 339 deletions(-) diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java index 0877553e42c0..0e571b6af83a 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java @@ -16,6 +16,7 @@ package com.google.cloud.bigquery.jdbc.it; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -90,7 +91,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep Files.write(tempFile.toPath(), authJson.toString().getBytes()); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" + getBaseConnectionUrl() + "" + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=0;" @@ -105,7 +106,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep @Test public void testServiceAccountAuthenticationMissingOAuthPvtKeyPath() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" + getBaseConnectionUrl() + "" + "ProjectId=" + PROJECT_ID + ";OAuthType=0;"; @@ -127,7 +128,7 @@ public void testValidServiceAccountAuthenticationOAuthPvtKeyAsPath() Files.write(tempFile.toPath(), authJson.toString().getBytes()); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" + getBaseConnectionUrl() + "" + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=0;" @@ -144,7 +145,7 @@ public void testValidServiceAccountAuthenticationViaEmailAndPkcs8Key() final JsonObject authJson = getAuthJson(); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" + getBaseConnectionUrl() + "" + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=0;" @@ -162,7 +163,7 @@ public void testValidServiceAccountAuthenticationOAuthPvtKeyAsJson() final JsonObject authJson = getAuthJson(); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" + getBaseConnectionUrl() + "" + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=0;" @@ -192,7 +193,7 @@ public void testValidServiceAccountAuthenticationP12() throws SQLException, IOEx @Disabled public void testValidGoogleUserAccountAuthentication() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" + getBaseConnectionUrl() + "PROJECTID=" + PROJECT_ID + ";OAuthType=1;OAuthClientId=client_id;OAuthClientSecret=client_secret;"; @@ -213,7 +214,7 @@ public void testValidGoogleUserAccountAuthentication() throws SQLException { @Disabled public void testValidExternalAccountAuthentication() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" + getBaseConnectionUrl() + "PROJECTID=" + PROJECT_ID + ";OAUTHTYPE=4;" + "BYOID_AudienceUri=//iam.googleapis.com/projects//locations//workloadIdentityPools//providers/;" @@ -237,7 +238,7 @@ public void testValidExternalAccountAuthentication() throws SQLException { @Disabled public void testValidExternalAccountAuthenticationFromFile() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" + getBaseConnectionUrl() + "PROJECTID=" + PROJECT_ID + ";OAUTHTYPE=4;" + "OAuthPvtKeyPath=/path/to/file;"; @@ -259,7 +260,7 @@ public void testValidExternalAccountAuthenticationFromFile() throws SQLException @Disabled public void testValidExternalAccountAuthenticationRawJson() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" + getBaseConnectionUrl() + "PROJECTID=" + PROJECT_ID + ";OAUTHTYPE=4;OAuthPvtKey={\n" + " \"universe_domain\": \"googleapis.com\",\n" @@ -303,7 +304,7 @@ public void testValidPreGeneratedAccessTokenAuthentication(String scope, boolean String accessToken = credentials.getAccessToken().getTokenValue(); String connectionUri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=" + getBaseConnectionUrl() + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=2" + ";OAuthAccessToken=" @@ -319,7 +320,7 @@ public void testValidPreGeneratedAccessTokenAuthentication(String scope, boolean @Disabled public void testValidRefreshTokenAuthentication() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" + getBaseConnectionUrl() + "PROJECTID=" + PROJECT_ID + ";OAUTHTYPE=2;OAuthRefreshToken=refresh_token;" + ";OAuthClientId=client;OAuthClientSecret=secret;"; diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBase.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBase.java index 5b4d36fac4fe..dbe16bea9516 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBase.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBase.java @@ -17,6 +17,7 @@ package com.google.cloud.bigquery.jdbc.it; import static org.junit.jupiter.api.Assertions.assertNotNull; +import com.google.cloud.bigquery.jdbc.utils.TestUtilities; import com.google.cloud.ServiceOptions; import com.google.cloud.bigquery.BigQuery; @@ -177,10 +178,15 @@ private static void registerShutdownHook(final String dataset) { } public static final String DEFAULT_CATALOG = ServiceOptions.getDefaultProjectId(); - public static String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=" - + DEFAULT_CATALOG - + ";OAuthType=3;Timeout=3600;"; + + public static String getBaseConnectionUrl() { + return TestUtilities.getBaseConnectionUrl(); + } + + public static String connectionUrl = getBaseConnectionUrl() + + "ProjectId=" + + DEFAULT_CATALOG + + ";OAuthType=3;Timeout=3600;"; public static final String createDatasetQuery = "CREATE SCHEMA IF NOT EXISTS `%s.%s` OPTIONS(default_table_expiration_days = 5)"; diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java index 9fe1c4f0f2fc..fa951e71f1ea 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java @@ -16,6 +16,7 @@ package com.google.cloud.bigquery.jdbc.it; + import static com.google.common.truth.Truth.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -64,11 +65,8 @@ public class ITBigQueryJDBCTest extends ITBase { static final String PROJECT_ID = ServiceOptions.getDefaultProjectId(); - static final String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3"; - static final String session_enabled_connection_uri = connection_uri + ";EnableSession=1"; + static final String connection_uri = ITBase.connectionUrl; + static final String session_enabled_connection_uri = connection_uri + "EnableSession=1;"; private static final String BASE_QUERY = "SELECT * FROM bigquery-public-data.new_york_taxi_trips.tlc_yellow_trips_2017 order by" + " trip_distance asc LIMIT %s"; @@ -108,13 +106,7 @@ public void testValidAllDataTypesSerializationFromSelectQueryArrowDataset() thro String DATASET = "JDBC_INTEGRATION_DATASET"; String TABLE_NAME = "JDBC_INTEGRATION_ARROW_TEST_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME + " LIMIT 5000;"; - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;ProjectId=" - + DEFAULT_CATALOG - + ";EnableHighThroughputAPI=1;" - + "HighThroughputActivationRatio=2;" - + "HighThroughputMinTableSize=1000;"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "EnableHighThroughputAPI=1;HighThroughputActivationRatio=2;HighThroughputMinTableSize=1000;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -240,9 +232,7 @@ public void testReadAPIPathLarge() throws SQLException { @Test public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { String connectionUri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + DEFAULT_CATALOG - + ";OAUTHTYPE=3;MaxResults=300;HighThroughputActivationRatio=2;" + ITBigQueryJDBCTest.connection_uri + "MaxResults=300;HighThroughputActivationRatio=2;" + "HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); @@ -257,9 +247,7 @@ public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { @Test public void testReadAPIPathLargeWithThresholdNotMet() throws SQLException { String connectionUri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + DEFAULT_CATALOG - + ";OAUTHTYPE=3;HighThroughputActivationRatio=4;" + ITBigQueryJDBCTest.connection_uri + "HighThroughputActivationRatio=4;" + "HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); @@ -306,9 +294,7 @@ public void testInvalidQuery() throws SQLException { @Test public void testDriver() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3"; + ITBigQueryJDBCTest.connection_uri + ""; Driver driver = BigQueryDriver.getRegisteredDriver(); assertTrue(driver.acceptsURL(connection_uri)); @@ -324,9 +310,7 @@ public void testDriver() throws SQLException { @Test public void testDefaultDataset() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3;DEFAULTDATASET=testDataset"; + ITBigQueryJDBCTest.connection_uri + "DEFAULTDATASET=testDataset"; Driver driver = BigQueryDriver.getRegisteredDriver(); assertTrue(driver.acceptsURL(connection_uri)); @@ -338,9 +322,7 @@ public void testDefaultDataset() throws SQLException { connection.unwrap(BigQueryConnection.class).getDefaultDataset()); String connection_uri_null_default_dataset = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3"; + ITBigQueryJDBCTest.connection_uri + ""; assertTrue(driver.acceptsURL(connection_uri_null_default_dataset)); @@ -354,9 +336,7 @@ public void testDefaultDataset() throws SQLException { @Test public void testDefaultDatasetWithProject() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3;DEFAULTDATASET=" + ITBigQueryJDBCTest.connection_uri + "DEFAULTDATASET=" + PROJECT_ID + ".testDataset"; @@ -374,9 +354,7 @@ public void testDefaultDatasetWithProject() throws SQLException { @Test public void testLocation() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3;LOCATION=EU"; + ITBigQueryJDBCTest.connection_uri + "LOCATION=EU"; Driver driver = BigQueryDriver.getRegisteredDriver(); assertTrue(driver.acceptsURL(connection_uri)); @@ -393,9 +371,7 @@ public void testLocation() throws SQLException { assertEquals(100, resultSetRowCount(resultSet)); String connection_uri_null_location = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3"; + ITBigQueryJDBCTest.connection_uri + ""; assertTrue(driver.acceptsURL(connection_uri_null_location)); @@ -409,9 +385,7 @@ public void testLocation() throws SQLException { @Test public void testIncorrectLocation() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3;LOCATION=europe-west3"; + ITBigQueryJDBCTest.connection_uri + "LOCATION=europe-west3"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -1290,13 +1264,7 @@ public void testAllValidStatementTypesForAddBatch() throws SQLException { @Test public void testUnsupportedHTAPIFallbacksToStandardQueriesWithRange() throws SQLException { String selectQuery = "select * from `DATATYPERANGETEST.RangeIntervalTestTable` LIMIT 5000;"; - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;ProjectId=" - + PROJECT_ID - + ";MaxResults=500;HighThroughputActivationRatio=1;" - + "HighThroughputMinTableSize=100;" - + "EnableHighThroughputAPI=1;UnsupportedHTAPIFallback=1;JobCreationMode=1;"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "MaxResults=500;HighThroughputActivationRatio=1;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;UnsupportedHTAPIFallback=1;JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1314,13 +1282,7 @@ public void testUnsupportedHTAPIFallbacksToStandardQueriesWithRange() throws SQL public void testIntervalDataTypeWithArrowResultSet() throws SQLException { String selectQuery = "select * from `DATATYPERANGETEST.RangeIntervalTestTable` order by intColumn limit 5000;"; - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;ProjectId=" - + PROJECT_ID - + ";MaxResults=500;HighThroughputActivationRatio=0;" - + "HighThroughputMinTableSize=100;" - + "EnableHighThroughputAPI=1;JobCreationMode=1;"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "MaxResults=500;HighThroughputActivationRatio=0;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1339,13 +1301,7 @@ public void testIntervalDataTypeWithArrowResultSet() throws SQLException { public void testIntervalDataTypeWithJsonResultSet() throws SQLException { String selectQuery = "select * from `DATATYPERANGETEST.RangeIntervalTestTable` order by intColumn limit 10 ;"; - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;ProjectId=" - + PROJECT_ID - + ";MaxResults=500;HighThroughputActivationRatio=1;" - + "HighThroughputMinTableSize=100;" - + "EnableHighThroughputAPI=0;JobCreationMode=1;"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "MaxResults=500;HighThroughputActivationRatio=1;HighThroughputMinTableSize=100;EnableHighThroughputAPI=0;JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1366,11 +1322,7 @@ public void testValidLEPEndpointQuery() throws SQLException { String TABLE_NAME = "REGIONAL_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - "jdbc:bigquery://https://googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";" + ITBigQueryJDBCTest.connection_uri + "" + "EndpointOverrides=BIGQUERY=https://us-east4-bigquery.googleapis.com;"; // Read data via JDBC @@ -1386,11 +1338,7 @@ public void testValidEndpointWithInvalidBQPortThrows() throws SQLException { String TABLE_NAME = "JDBC_REGIONAL_TABLE_" + randomNumber; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - "jdbc:bigquery://https://googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";" + ITBigQueryJDBCTest.connection_uri + "" + "EndpointOverrides=BIGQUERY=https://us-east4-bigquery.googleapis.com:12312312;"; // Read data via JDBC @@ -1406,11 +1354,7 @@ public void testLEPEndpointDataNotFoundThrows() throws SQLException { String TABLE_NAME = "REGIONAL_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";" + ITBigQueryJDBCTest.connection_uri + "" + "EndpointOverrides=BIGQUERY=https://us-east5-bigquery.googleapis.com;"; // Attempting read data via JDBC @@ -1426,11 +1370,7 @@ public void testValidREPEndpointQuery() throws SQLException { String TABLE_NAME = "REGIONAL_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";" + ITBigQueryJDBCTest.connection_uri + "" + "EndpointOverrides=BIGQUERY=https://bigquery.us-east4.rep.googleapis.com;"; // Read data via JDBC @@ -1447,11 +1387,7 @@ public void testREPEndpointDataNotFoundThrows() throws SQLException { String TABLE_NAME = "REGIONAL_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";" + ITBigQueryJDBCTest.connection_uri + "" + "EndpointOverrides=BIGQUERY=https://bigquery.us-east7.rep.googleapis.com;"; // Attempting read data via JDBC @@ -1527,7 +1463,7 @@ public void testConnectionIsValid() throws SQLException { @Test public void testDataSource() throws SQLException { DataSource ds = new DataSource(); - ds.setURL("jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"); + ds.setURL(getBaseConnectionUrl() + ""); ds.setOAuthType(3); try (Connection connection = ds.getConnection()) { @@ -1540,7 +1476,7 @@ public void testDataSourceOAuthPvtKeyPath() throws SQLException, IOException { File tempFile = File.createTempFile("auth", ".json"); tempFile.deleteOnExit(); DataSource ds = new DataSource(); - ds.setURL("jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"); + ds.setURL(getBaseConnectionUrl() + ""); ds.setOAuthType(0); ds.setOAuthPvtKeyPath(tempFile.toPath().toString()); assertEquals(0, ds.getOAuthType().intValue()); @@ -1697,11 +1633,7 @@ public void testPreparedStatementDateTimeValues() throws SQLException { public void testValidDestinationTableSavesQueriesWithLegacySQL() throws SQLException { // setup String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryDialect=BIG_QUERY;" + ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=1;" + "LargeResultTable=destination_table_test_legacy;" + "LargeResultDataset=INTEGRATION_TESTS;"; @@ -1730,11 +1662,7 @@ public void testValidDestinationTableSavesQueriesWithLegacySQL() throws SQLExcep public void testNonEnabledUseLegacySQLThrowsSyntaxError() throws SQLException { // setup String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + DEFAULT_CATALOG - + ";"; + ITBigQueryJDBCTest.connection_uri + ""; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 20000000;"; Connection connection = DriverManager.getConnection(connection_uri, new Properties()); @@ -1749,11 +1677,7 @@ public void testNonEnabledUseLegacySQLThrowsSyntaxError() throws SQLException { public void testUseLegacySQLWithLargeResultsNotAllowedQueries() throws SQLException { // setup String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + DEFAULT_CATALOG - + ";QueryDialect=BIG_QUERY;AllowLargeResults=0;"; + ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;AllowLargeResults=0;"; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 250000;"; Connection connection = DriverManager.getConnection(connection_uri, new Properties()); @@ -1771,11 +1695,7 @@ public void testUseLegacySQLWithLargeResultsNotAllowedQueries() throws SQLExcept public void testValidDestinationTableSavesQueriesWithStandardSQL() throws SQLException { // setup String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryDialect=SQL;" + ITBigQueryJDBCTest.connection_uri + "QueryDialect=SQL;" + "LargeResultTable=destination_table_test;" + "LargeResultDataset=INTEGRATION_TESTS;"; String selectLegacyQuery = @@ -1804,11 +1724,7 @@ public void testDestinationTableAndDestinationDatasetThatDoesNotExistsCreates() throws SQLException { // setup String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryDialect=BIG_QUERY;" + ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=1;" + "LargeResultTable=FakeTable;" + "LargeResultDataset=FakeDataset;"; @@ -1837,11 +1753,7 @@ public void testUseLegacySQLWithLargeResultsAllowedWithNoDestinationTableDefault throws SQLException { // setup String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + DEFAULT_CATALOG - + ";QueryDialect=BIG_QUERY;AllowLargeResults=1;"; + ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;AllowLargeResults=1;"; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 250000;"; Connection connection = DriverManager.getConnection(connection_uri, new Properties()); @@ -1859,11 +1771,7 @@ public void testUseLegacySQLWithLargeResultsAllowedWithNoDestinationTableDefault public void testDestinationTableWithMissingDestinationDatasetDefaults() throws SQLException { // setup String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryDialect=BIG_QUERY;" + ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=1;" + "LargeResultTable=FakeTable;"; String selectLegacyQuery = @@ -1892,11 +1800,7 @@ public void testNonSelectForLegacyDestinationTableThrows() throws SQLException { "CREATE OR REPLACE TABLE %s.%s (`id` INTEGER, `name` STRING, `age` INTEGER);", DATASET, TRANSACTION_TABLE); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryDialect=BIG_QUERY;" + ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=1;" + "LargeResultTable=destination_table_test;" + "LargeResultDataset=INTEGRATION_TESTS;"; @@ -1918,11 +1822,7 @@ public void testNonSelectForStandardDestinationTableDoesNotThrow() throws SQLExc "CREATE OR REPLACE TABLE %s.%s (`id` INTEGER, `name` STRING, `age` INTEGER);", DATASET, TRANSACTION_TABLE); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryDialect=SQL;" + ITBigQueryJDBCTest.connection_uri + "QueryDialect=SQL;" + "AllowLargeResults=1;" + "LargeResultTable=destination_table_test;" + "LargeResultDataset=INTEGRATION_TESTS;"; @@ -2000,13 +1900,7 @@ public void testRangeDataTypeWithArrowResultSet() throws SQLException { String selectQuery = "select * from `DATATYPERANGETEST.RangeIntervalTestTable` order by intColumn limit 5000;"; - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;ProjectId=" - + PROJECT_ID - + ";MaxResults=500;HighThroughputActivationRatio=0;" - + "HighThroughputMinTableSize=100;" - + "EnableHighThroughputAPI=1;JobCreationMode=1;"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "MaxResults=500;HighThroughputActivationRatio=0;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -2052,11 +1946,7 @@ public void testAlterTable() throws SQLException { public void testQueryPropertyDataSetProjectIdQueriesToCorrectDataset() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryProperties=dataset_project_id=" + ITBigQueryJDBCTest.connection_uri + "QueryProperties=dataset_project_id=" + PROJECT_ID + ";"; String insertQuery = @@ -2087,11 +1977,7 @@ public void testQueryPropertyDataSetProjectIdQueriesToCorrectDataset() throws SQ public void testQueryPropertyDataSetProjectIdQueriesToIncorrectDatasetThrows() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryProperties=dataset_project_id=bigquerytestdefault" + ITBigQueryJDBCTest.connection_uri + "QueryProperties=dataset_project_id=bigquerytestdefault" + ";"; String insertQuery = String.format( @@ -2109,11 +1995,7 @@ public void testQueryPropertyDataSetProjectIdQueriesToIncorrectDatasetThrows() @Test public void testQueryPropertyTimeZoneQueries() throws SQLException { String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryProperties=time_zone=America/New_York;"; + ITBigQueryJDBCTest.connection_uri + "QueryProperties=time_zone=America/New_York;"; String query = "SELECT * FROM `bigquery-public-data.samples.shakespeare` LIMIT 180"; Driver driver = BigQueryDriver.getRegisteredDriver(); Connection connection = driver.connect(connection_uri, new Properties()); @@ -2133,11 +2015,7 @@ public void testQueryPropertySessionIdSetsStatementSession() throws SQLException, InterruptedException { String sessionId = getSessionId(); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryProperties=session_id=" + ITBigQueryJDBCTest.connection_uri + "QueryProperties=session_id=" + sessionId + ";"; String selectQuery = @@ -2165,11 +2043,7 @@ public void testEncryptedTableWithKmsQueries() throws SQLException { // setup String KMSKeyName = requireEnvVar("KMS_RESOURCE_PATH"); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";KMSKeyName=" + ITBigQueryJDBCTest.connection_uri + "KMSKeyName=" + KMSKeyName + ";"; String selectQuery = "SELECT * FROM `JDBC_INTEGRATION_DATASET.KMS_Test_table`;"; @@ -2191,11 +2065,7 @@ public void testEncryptedTableWithKmsQueries() throws SQLException { public void testIncorrectKmsThrows() throws SQLException { String KMSKeyName = requireEnvVar("KMS_RESOURCE_PATH"); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";KMSKeyName=" + ITBigQueryJDBCTest.connection_uri + "KMSKeyName=" + KMSKeyName + ";"; String selectQuery = @@ -2214,11 +2084,7 @@ public void testIncorrectKmsThrows() throws SQLException { public void testQueryPropertyServiceAccountFollowsIamPermission() throws SQLException { final String SERVICE_ACCOUNT_EMAIL = requireEnvVar("SA_EMAIL"); String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryProperties=service_account=" + ITBigQueryJDBCTest.connection_uri + "QueryProperties=service_account=" + SERVICE_ACCOUNT_EMAIL + ";"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -2242,11 +2108,7 @@ public void testValidLegacySQLStatement() throws SQLException { + "FROM\n" + " [bigquery-public-data.github_repos.commits],\n" + " [bigquery-public-data.github_repos.sample_commits] LIMIT 10"; - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;ProjectId=" - + PROJECT_ID - + ";QueryDialect=BIG_QUERY;"; +String connection_uri = ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;"; Connection connection = DriverManager.getConnection(connection_uri); Statement statement = connection.createStatement(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITCallableStatementTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITCallableStatementTest.java index cbd128a818f1..d70f0cb77a9b 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITCallableStatementTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITCallableStatementTest.java @@ -48,10 +48,7 @@ public class ITCallableStatementTest extends ITBase { static final String PROJECT_ID = ServiceOptions.getDefaultProjectId(); - static final String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3"; + static final String connection_uri = ITBase.connectionUrl; private static final Random random = new Random(); private static String DATASET; private static final String CALLABLE_STMT_PROC_NAME = "IT_CALLABLE_STMT_PROC_TEST"; diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java index 6f3b5ca43926..df40b321ff31 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java @@ -43,8 +43,7 @@ public class ITConnectionPoolingTest extends ITBase { @Test public void testPooledConnectionDataSourceSuccess() throws SQLException { - String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -62,9 +61,7 @@ public void testPooledConnectionDataSourceFailNoConnectionURl() { @Test public void testPooledConnectionDataSourceFailInvalidConnectionURl() { - String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;" - + "ListenerPoolSize=invalid"; + String connectionUrl = ITBase.connectionUrl + "ListenerPoolSize=invalid;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -73,8 +70,7 @@ public void testPooledConnectionDataSourceFailInvalidConnectionURl() { @Test public void testPooledConnectionAddConnectionListener() throws SQLException { - String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -89,8 +85,7 @@ public void testPooledConnectionAddConnectionListener() throws SQLException { @Test public void testPooledConnectionRemoveConnectionListener() throws SQLException { - String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -106,7 +101,7 @@ public void testPooledConnectionRemoveConnectionListener() throws SQLException { @Test public void testPooledConnectionConnectionClosed() throws SQLException { String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -130,7 +125,7 @@ public void testPooledConnectionConnectionClosed() throws SQLException { @Test public void testPooledConnectionClose() throws SQLException { String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -150,7 +145,7 @@ public void testPooledConnectionClose() throws SQLException { @Test public void testPooledConnectionConnectionError() throws SQLException { String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -179,7 +174,7 @@ public void testPooledConnectionConnectionError() throws SQLException { @Test public void testPooledConnectionListenerAddListener() throws SQLException { String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -195,7 +190,7 @@ public void testPooledConnectionListenerAddListener() throws SQLException { @Test public void testPooledConnectionListenerRemoveListener() throws SQLException { String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -214,7 +209,7 @@ public void testPooledConnectionListenerRemoveListener() throws SQLException { @Test public void testPooledConnectionListenerCloseConnection() throws SQLException { String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -237,7 +232,7 @@ public void testPooledConnectionListenerCloseConnection() throws SQLException { @Test public void testPooledConnectionListenerClosePooledConnection() throws SQLException { String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -255,7 +250,7 @@ public void testPooledConnectionListenerClosePooledConnection() throws SQLExcept @Test public void testPooledConnectionListenerConnectionError() throws SQLException { String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;OAuthType=3;ProjectId=testProject;ConnectionPoolSize=20;ListenerPoolSize=20;"; + ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -281,24 +276,15 @@ public void testPooledConnectionListenerConnectionError() throws SQLException { @Test public void testExecuteQueryWithConnectionPoolingEnabledDefaultPoolSize() throws SQLException { - String connectionURL = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;ProjectId=" - + PROJECT_ID - + ";"; + String connectionURL = ITBase.connectionUrl + ""; + assertConnectionPoolingResults(connectionURL, DEFAULT_CONN_POOL_SIZE); } @Test public void testExecuteQueryWithConnectionPoolingEnabledCustomPoolSize() throws SQLException { - String connectionURL = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;ProjectId=" - + PROJECT_ID - + ";" - + "ConnectionPoolSize=" - + CUSTOM_CONN_POOL_SIZE - + ";"; + String connectionURL = ITBase.connectionUrl + "ConnectionPoolSize=CUSTOM_CONN_POOL_SIZE"; +"; assertConnectionPoolingResults(connectionURL, CUSTOM_CONN_POOL_SIZE); } diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionTest.java index d1a5b06ed6fb..40fd50e27488 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionTest.java @@ -49,8 +49,7 @@ public class ITConnectionTest { static int randomNumber = random.nextInt(999); private static final String TABLE_NAME = "JDBC_CONNECTION_TEST_TABLE" + randomNumber; - private static String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=%s;OAuthType=3;Timeout=3600;"; + private static String connectionUrl = ITBase.connectionUrl; @BeforeAll public static void beforeClass() throws InterruptedException { diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDatabaseMetadataTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDatabaseMetadataTest.java index 8df46d7d5802..50d1c5178a81 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDatabaseMetadataTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDatabaseMetadataTest.java @@ -49,10 +49,7 @@ public class ITDatabaseMetadataTest extends ITBase { static final String PROJECT_ID = ServiceOptions.getDefaultProjectId(); - static final String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3"; + static final String connection_uri = ITBase.connectionUrl; private static final Random random = new Random(); private static final int randomNumber = random.nextInt(9999); private static String DATASET; @@ -65,8 +62,7 @@ public class ITDatabaseMetadataTest extends ITBase { Pattern.compile("^(\\d+)\\.(\\d+)(?:\\.\\d+)+\\s*.*"); private static final String DEFAULT_CATALOG = ServiceOptions.getDefaultProjectId(); private static final String TABLE_NAME = "JDBC_DBMETADATA_TEST_TABLE" + randomNumber; - private static String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=%s;OAuthType=3;Timeout=3600;"; + private static String connectionUrl = ITBase.connectionUrl; @BeforeAll public static void beforeClass() throws InterruptedException, SQLException { @@ -1106,12 +1102,7 @@ public void testAdditionalProjectsInMetadata() throws SQLException { String additionalProjectsValue = "bigquery-public-data"; String datasetInAdditionalProject = "baseball"; - String urlWithAdditionalProjects = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=" - + PROJECT_ID - + ";OAuthType=3" - + ";AdditionalProjects=" - + additionalProjectsValue; + String urlWithAdditionalProjects = ITBase.connectionUrl + "AdditionalProjects=" + additionalProjectsValue; try (Connection conn = DriverManager.getConnection(urlWithAdditionalProjects)) { DatabaseMetaData dbMetaData = conn.getMetaData(); @@ -1171,13 +1162,7 @@ public void testFilterTablesOnDefaultDataset_getTables() throws SQLException { String table1InSpecificDataset = "base_table"; String table2InSpecificDataset = "external_table"; - String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=" - + PROJECT_ID - + ";OAuthType=3" - + ";DefaultDataset=" - + defaultDatasetValue - + ";FilterTablesOnDefaultDataset=1"; + String connectionUrl = ITDatabaseMetadataTest.connectionUrl + "DefaultDataset=" + defaultDatasetValue + ";FilterTablesOnDefaultDataset=1"; try (Connection conn = DriverManager.getConnection(connectionUrl)) { DatabaseMetaData dbMetaData = conn.getMetaData(); @@ -1242,13 +1227,7 @@ public void testFilterTablesOnDefaultDataset_getColumns() throws SQLException { String tableInSpecificDataset = "base_table"; String[] columnsInSpecificTable = {"id", "name", "created_at"}; - String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=" - + PROJECT_ID - + ";OAuthType=3" - + ";DefaultDataset=" - + defaultDatasetValue - + ";FilterTablesOnDefaultDataset=1"; + String connectionUrl = ITDatabaseMetadataTest.connectionUrl + "DefaultDataset=" + defaultDatasetValue + ";FilterTablesOnDefaultDataset=1"; try (Connection conn = DriverManager.getConnection(connectionUrl)) { DatabaseMetaData dbMetaData = conn.getMetaData(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java index 161f5163b691..e67cc8d19bfd 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java @@ -81,15 +81,9 @@ public class ITNightlyBigQueryTest { private static final String CALLABLE_STMT_DML_TABLE_NAME = "IT_CALLABLE_STMT_PROC_DML_TABLE"; private static String DATASET; private static String DATASET2; - static final String session_enabled_connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3;EnableSession=1"; + static final String session_enabled_connection_uri = ITBase.connectionUrl + "EnableSession=1;"; - static final String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3"; + static final String connection_uri = ITBase.connectionUrl; @BeforeAll public static void beforeClass() throws SQLException { @@ -342,15 +336,7 @@ public void testExecuteLargeUpdate() throws SQLException { @Test public void testHTAPIWithValidDestinationTableSavesQueriesWithStandardSQL() throws SQLException { // setup - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryDialect=SQL;" - + "LargeResultTable=destination_table_test;" - + "LargeResultDataset=INTEGRATION_TESTS;" - + "EnableHighThroughputAPI=1;"; + String connection_uri = ITNightlyBigQueryTest.connection_uri + "QueryDialect=SQL;LargeResultTable=destination_table_test;LargeResultDataset=INTEGRATION_TESTS;EnableHighThroughputAPI=1;"; String selectLegacyQuery = "SELECT * FROM `bigquery-public-data.deepmind_alphafold.metadata` LIMIT 200000;"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -732,15 +718,7 @@ public void testFailedStatementInTheMiddleOfExecuteBatchStopsExecuting() throws @Test public void testHTAPIWithValidDestinationTableSavesQueriesWithLegacy() throws SQLException { // setup - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryDialect=BIG_QUERY;" - + "LargeResultTable=destination_table_test;" - + "LargeResultDataset=INTEGRATION_TESTS;" - + "EnableHighThroughputAPI=1;"; + String connection_uri = ITNightlyBigQueryTest.connection_uri + "QueryDialect=BIG_QUERY;LargeResultTable=destination_table_test;LargeResultDataset=INTEGRATION_TESTS;EnableHighThroughputAPI=1;"; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200000;"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -1120,13 +1098,8 @@ public void testValidAllDataTypesSerializationFromSelectQueryArrowDataset() thro String DATASET = "JDBC_INTEGRATION_DATASET"; String TABLE_NAME = "JDBC_INTEGRATION_ARROW_TEST_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME + " LIMIT 5000;"; - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;ProjectId=" - + PROJECT_ID - + ";EnableHighThroughputAPI=1;" - + "HighThroughputActivationRatio=2;" - + "HighThroughputMinTableSize=1000;"; + String connection_uri = ITNightlyBigQueryTest.connection_uri + "EnableHighThroughputAPI=1;HighThroughputActivationRatio=2;HighThroughputMinTableSize=1000;"; + // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1182,11 +1155,7 @@ public void testBulkInsertOperation() throws SQLException { String dropQuery = String.format("DROP TABLE %s.%s", DATASET, TABLE_NAME); String selectQuery = String.format("SELECT * FROM %s.%s", DATASET, TABLE_NAME); - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3;" - + "EnableWriteAPI=1;SWA_ActivationRowCount=5;SWA_AppendRowCount=500"; + String connection_uri = ITNightlyBigQueryTest.connection_uri + "EnableWriteAPI=1;SWA_ActivationRowCount=5;SWA_AppendRowCount=500"; try (Connection connection = DriverManager.getConnection(connection_uri)) { bigQueryStatement.execute(createQuery); @@ -1231,11 +1200,7 @@ public void testBulkInsertOperationStandard() throws SQLException { String dropQuery = String.format("DROP TABLE %s.%s", DATASET, TABLE_NAME); String selectQuery = String.format("SELECT * FROM %s.%s", DATASET, TABLE_NAME); - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3;" - + "EnableWriteAPI=0;SWA_ActivationRowCount=50;SWA_AppendRowCount=500"; + String connection_uri = ITNightlyBigQueryTest.connection_uri + "EnableWriteAPI=0;SWA_ActivationRowCount=50;SWA_AppendRowCount=500"; try (Connection connection = DriverManager.getConnection(connection_uri)) { bigQueryStatement.execute(createQuery); @@ -1364,14 +1329,7 @@ public void testQueryPropertySessionIdIsUsedWithTransaction() bigQueryStatement.execute(createTransactionTable); // Run the transaction - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";QueryProperties=session_id=" - + sessionId - + ";"; + String connection_uri = ITNightlyBigQueryTest.connection_uri + "QueryProperties=session_id=sessionId";"; Driver driver = BigQueryDriver.getRegisteredDriver(); Connection connection = driver.connect(connection_uri, new Properties()); Statement statement = connection.createStatement(); @@ -1613,12 +1571,7 @@ public void testIterateOrderArrowMultiThread() throws SQLException { @Test public void testNonEnabledUseLegacySQLThrowsSyntaxError() throws SQLException { // setup - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;" - + "OAuthType=3;" - + "ProjectId=" - + PROJECT_ID - + ";"; + String connection_uri = ITNightlyBigQueryTest.connection_uri + ""; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 20000000;"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -1660,11 +1613,8 @@ public void testReadAPIPathLarge() throws SQLException { @Test public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { - String connectionUri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3;MaxResults=300;HighThroughputActivationRatio=2;" - + "HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + String connectionUri = ITNightlyBigQueryTest.connection_uri + "MaxResults=300;HighThroughputActivationRatio=2;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); int expectedCnt = 1000; @@ -1678,11 +1628,8 @@ public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { @Test public void testReadAPIPathLargeWithThresholdNotMet() throws SQLException { - String connectionUri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + PROJECT_ID - + ";OAUTHTYPE=3;HighThroughputActivationRatio=4;" - + "HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + String connectionUri = ITNightlyBigQueryTest.connection_uri + "HighThroughputActivationRatio=4;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); int expectedCnt = 5000; diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITResultSetMetadataTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITResultSetMetadataTest.java index 917db7124243..bd893e76729a 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITResultSetMetadataTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITResultSetMetadataTest.java @@ -56,7 +56,7 @@ public static void afterClass() throws InterruptedException { public void testResultSetMetadata() throws SQLException { String selectData = "SELECT * FROM " + DATASET + "." + TABLE_NAME + ";"; Connection connection = - DriverManager.getConnection(String.format(ITBase.connectionUrl, DEFAULT_CATALOG)); + DriverManager.getConnection(ITBase.connectionUrl); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(selectData); metaData = resultSet.getMetaData(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java index bc3a995d837a..3cd3fa0fe15c 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java @@ -43,8 +43,7 @@ public class ITStatementTest { private static final String DEFAULT_CATALOG = ServiceOptions.getDefaultProjectId(); private static String DATASET; - private static String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=%s;OAuthType=3;Timeout=3600;"; + private static String connectionUrl = ITBase.connectionUrl; private static Random random = new Random(); private static int randomNumber = random.nextInt(999); private static final String TABLE_NAME = "JDBC_STATEMENT_TEST_TABLE" + randomNumber; @@ -222,10 +221,7 @@ public void testExecuteUpdate() throws SQLException { @Test public void testScript() throws SQLException { - String connection_uri = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID=" - + DEFAULT_CATALOG - + ";OAUTHTYPE=3"; + String connection_uri = ITStatementTest.connectionUrl; Properties withReadApi = new Properties(); withReadApi.setProperty("EnableHighThroughputAPI", "1"); Connection connection = DriverManager.getConnection(connection_uri, withReadApi); @@ -258,15 +254,7 @@ public void testStringColumnLength() throws SQLException { String TABLE_NAME = "StringColumnLengthTable"; String oauthType = "3"; // Google Application Credentials int length = 10; - String connectionUrl = - "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=" - + projectId - + ";OAuthType=" - + oauthType - + ";Timeout=3600;" - + "StringColumnLength=" - + length - + ";"; + String connectionUrl = ITStatementTest.connectionUrl + "StringColumnLength=" + length + ";";; // + "EnableSession=1"; Connection connection1 = DriverManager.getConnection(connectionUrl); Statement statement = connection1.createStatement(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/utils/TestUtilities.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/utils/TestUtilities.java index 419cb9b0bcb1..dbca17096534 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/utils/TestUtilities.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/utils/TestUtilities.java @@ -140,4 +140,29 @@ public int getConnectionErrorCount() { return connectionErrorCount; } } + + private static String getEnvOrProperty(String envVar, String sysProp, String defaultValue) { + String value = System.getenv(envVar); + if (value == null || value.isEmpty()) { + value = System.getProperty(sysProp, defaultValue); + } + return value; + } + + public static String getBaseUrl() { + return getEnvOrProperty("BIGQUERY_BASE_URL", "bigquery.baseUrl", "https://www.googleapis.com/bigquery/v2:443"); + } + + public static String getUrlFlags() { + return getEnvOrProperty("BIGQUERY_URL_FLAGS", "bigquery.urlFlags", ""); + } + + public static String getBaseConnectionUrl() { + String baseUrl = getBaseUrl(); + String flags = getUrlFlags(); + if (!flags.isEmpty() && !flags.endsWith(";")) { + flags += ";"; + } + return "jdbc:bigquery://" + baseUrl + ";" + flags; + } } From f35d3a5de054fdd441e424e0e64b668a2d317d84 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Wed, 10 Jun 2026 21:02:28 +0000 Subject: [PATCH 2/4] Fix compilation --- .../cloud/bigquery/jdbc/it/ITAuthTests.java | 10 ++++----- .../bigquery/jdbc/it/ITBigQueryJDBCTest.java | 22 +++++++++---------- .../jdbc/it/ITConnectionPoolingTest.java | 5 ++--- .../jdbc/it/ITNightlyBigQueryTest.java | 4 ++-- .../bigquery/jdbc/it/ITStatementTest.java | 4 +--- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java index 0e571b6af83a..71da4d604b42 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java @@ -91,7 +91,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep Files.write(tempFile.toPath(), authJson.toString().getBytes()); String connection_uri = - getBaseConnectionUrl() + "" + getBaseConnectionUrl() + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=0;" @@ -106,7 +106,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep @Test public void testServiceAccountAuthenticationMissingOAuthPvtKeyPath() throws SQLException { String connection_uri = - getBaseConnectionUrl() + "" + getBaseConnectionUrl() + "ProjectId=" + PROJECT_ID + ";OAuthType=0;"; @@ -128,7 +128,7 @@ public void testValidServiceAccountAuthenticationOAuthPvtKeyAsPath() Files.write(tempFile.toPath(), authJson.toString().getBytes()); String connection_uri = - getBaseConnectionUrl() + "" + getBaseConnectionUrl() + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=0;" @@ -145,7 +145,7 @@ public void testValidServiceAccountAuthenticationViaEmailAndPkcs8Key() final JsonObject authJson = getAuthJson(); String connection_uri = - getBaseConnectionUrl() + "" + getBaseConnectionUrl() + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=0;" @@ -163,7 +163,7 @@ public void testValidServiceAccountAuthenticationOAuthPvtKeyAsJson() final JsonObject authJson = getAuthJson(); String connection_uri = - getBaseConnectionUrl() + "" + getBaseConnectionUrl() + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=0;" diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java index fa951e71f1ea..9aba6bd1b5a7 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java @@ -294,7 +294,7 @@ public void testInvalidQuery() throws SQLException { @Test public void testDriver() throws SQLException { String connection_uri = - ITBigQueryJDBCTest.connection_uri + ""; + ITBigQueryJDBCTest.connection_uri; Driver driver = BigQueryDriver.getRegisteredDriver(); assertTrue(driver.acceptsURL(connection_uri)); @@ -322,7 +322,7 @@ public void testDefaultDataset() throws SQLException { connection.unwrap(BigQueryConnection.class).getDefaultDataset()); String connection_uri_null_default_dataset = - ITBigQueryJDBCTest.connection_uri + ""; + ITBigQueryJDBCTest.connection_uri; assertTrue(driver.acceptsURL(connection_uri_null_default_dataset)); @@ -371,7 +371,7 @@ public void testLocation() throws SQLException { assertEquals(100, resultSetRowCount(resultSet)); String connection_uri_null_location = - ITBigQueryJDBCTest.connection_uri + ""; + ITBigQueryJDBCTest.connection_uri; assertTrue(driver.acceptsURL(connection_uri_null_location)); @@ -1322,7 +1322,7 @@ public void testValidLEPEndpointQuery() throws SQLException { String TABLE_NAME = "REGIONAL_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - ITBigQueryJDBCTest.connection_uri + "" + ITBigQueryJDBCTest.connection_uri + "EndpointOverrides=BIGQUERY=https://us-east4-bigquery.googleapis.com;"; // Read data via JDBC @@ -1338,7 +1338,7 @@ public void testValidEndpointWithInvalidBQPortThrows() throws SQLException { String TABLE_NAME = "JDBC_REGIONAL_TABLE_" + randomNumber; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - ITBigQueryJDBCTest.connection_uri + "" + ITBigQueryJDBCTest.connection_uri + "EndpointOverrides=BIGQUERY=https://us-east4-bigquery.googleapis.com:12312312;"; // Read data via JDBC @@ -1354,7 +1354,7 @@ public void testLEPEndpointDataNotFoundThrows() throws SQLException { String TABLE_NAME = "REGIONAL_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - ITBigQueryJDBCTest.connection_uri + "" + ITBigQueryJDBCTest.connection_uri + "EndpointOverrides=BIGQUERY=https://us-east5-bigquery.googleapis.com;"; // Attempting read data via JDBC @@ -1370,7 +1370,7 @@ public void testValidREPEndpointQuery() throws SQLException { String TABLE_NAME = "REGIONAL_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - ITBigQueryJDBCTest.connection_uri + "" + ITBigQueryJDBCTest.connection_uri + "EndpointOverrides=BIGQUERY=https://bigquery.us-east4.rep.googleapis.com;"; // Read data via JDBC @@ -1387,7 +1387,7 @@ public void testREPEndpointDataNotFoundThrows() throws SQLException { String TABLE_NAME = "REGIONAL_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME; String connection_uri = - ITBigQueryJDBCTest.connection_uri + "" + ITBigQueryJDBCTest.connection_uri + "EndpointOverrides=BIGQUERY=https://bigquery.us-east7.rep.googleapis.com;"; // Attempting read data via JDBC @@ -1463,7 +1463,7 @@ public void testConnectionIsValid() throws SQLException { @Test public void testDataSource() throws SQLException { DataSource ds = new DataSource(); - ds.setURL(getBaseConnectionUrl() + ""); + ds.setURL(getBaseConnectionUrl()); ds.setOAuthType(3); try (Connection connection = ds.getConnection()) { @@ -1476,7 +1476,7 @@ public void testDataSourceOAuthPvtKeyPath() throws SQLException, IOException { File tempFile = File.createTempFile("auth", ".json"); tempFile.deleteOnExit(); DataSource ds = new DataSource(); - ds.setURL(getBaseConnectionUrl() + ""); + ds.setURL(getBaseConnectionUrl()); ds.setOAuthType(0); ds.setOAuthPvtKeyPath(tempFile.toPath().toString()); assertEquals(0, ds.getOAuthType().intValue()); @@ -1662,7 +1662,7 @@ public void testValidDestinationTableSavesQueriesWithLegacySQL() throws SQLExcep public void testNonEnabledUseLegacySQLThrowsSyntaxError() throws SQLException { // setup String connection_uri = - ITBigQueryJDBCTest.connection_uri + ""; + ITBigQueryJDBCTest.connection_uri; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 20000000;"; Connection connection = DriverManager.getConnection(connection_uri, new Properties()); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java index df40b321ff31..58630b6175cf 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java @@ -276,15 +276,14 @@ public void testPooledConnectionListenerConnectionError() throws SQLException { @Test public void testExecuteQueryWithConnectionPoolingEnabledDefaultPoolSize() throws SQLException { - String connectionURL = ITBase.connectionUrl + ""; + String connectionURL = ITBase.connectionUrl; assertConnectionPoolingResults(connectionURL, DEFAULT_CONN_POOL_SIZE); } @Test public void testExecuteQueryWithConnectionPoolingEnabledCustomPoolSize() throws SQLException { - String connectionURL = ITBase.connectionUrl + "ConnectionPoolSize=CUSTOM_CONN_POOL_SIZE"; -"; + String connectionURL = ITBase.connectionUrl + "ConnectionPoolSize=" + CUSTOM_CONN_POOL_SIZE + ";"; assertConnectionPoolingResults(connectionURL, CUSTOM_CONN_POOL_SIZE); } diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java index e67cc8d19bfd..6ab6c890d0e5 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java @@ -1329,7 +1329,7 @@ public void testQueryPropertySessionIdIsUsedWithTransaction() bigQueryStatement.execute(createTransactionTable); // Run the transaction - String connection_uri = ITNightlyBigQueryTest.connection_uri + "QueryProperties=session_id=sessionId";"; + String connection_uri = ITNightlyBigQueryTest.connection_uri + "QueryProperties=session_id=" + sessionId + ";"; Driver driver = BigQueryDriver.getRegisteredDriver(); Connection connection = driver.connect(connection_uri, new Properties()); Statement statement = connection.createStatement(); @@ -1571,7 +1571,7 @@ public void testIterateOrderArrowMultiThread() throws SQLException { @Test public void testNonEnabledUseLegacySQLThrowsSyntaxError() throws SQLException { // setup - String connection_uri = ITNightlyBigQueryTest.connection_uri + ""; + String connection_uri = ITNightlyBigQueryTest.connection_uri; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 20000000;"; Driver driver = BigQueryDriver.getRegisteredDriver(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java index 3cd3fa0fe15c..0e097a6095fa 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITStatementTest.java @@ -250,11 +250,9 @@ private int resultSetRowCount(ResultSet resultSet) throws SQLException { @Test public void testStringColumnLength() throws SQLException { - String projectId = DEFAULT_CATALOG; String TABLE_NAME = "StringColumnLengthTable"; - String oauthType = "3"; // Google Application Credentials int length = 10; - String connectionUrl = ITStatementTest.connectionUrl + "StringColumnLength=" + length + ";";; + String connectionUrl = ITStatementTest.connectionUrl + "StringColumnLength=" + length + ";"; // + "EnableSession=1"; Connection connection1 = DriverManager.getConnection(connectionUrl); Statement statement = connection1.createStatement(); From 8870ac0e044faefe171dcdb81761b934d4d1bb7b Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Wed, 10 Jun 2026 22:27:28 +0000 Subject: [PATCH 3/4] lint --- .../cloud/bigquery/jdbc/it/ITAuthTests.java | 25 ++--- .../google/cloud/bigquery/jdbc/it/ITBase.java | 8 +- .../bigquery/jdbc/it/ITBigQueryJDBCTest.java | 95 ++++++++++--------- .../jdbc/it/ITConnectionPoolingTest.java | 27 ++---- .../jdbc/it/ITDatabaseMetadataTest.java | 15 ++- .../jdbc/it/ITNightlyBigQueryTest.java | 32 +++++-- .../jdbc/it/ITResultSetMetadataTest.java | 3 +- .../bigquery/jdbc/utils/TestUtilities.java | 3 +- 8 files changed, 113 insertions(+), 95 deletions(-) diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java index 71da4d604b42..f7e2108ca68d 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java @@ -16,7 +16,6 @@ package com.google.cloud.bigquery.jdbc.it; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -105,11 +104,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep @Test public void testServiceAccountAuthenticationMissingOAuthPvtKeyPath() throws SQLException { - String connection_uri = - getBaseConnectionUrl() - + "ProjectId=" - + PROJECT_ID - + ";OAuthType=0;"; + String connection_uri = getBaseConnectionUrl() + "ProjectId=" + PROJECT_ID + ";OAuthType=0;"; try { DriverManager.getConnection(connection_uri); @@ -193,7 +188,8 @@ public void testValidServiceAccountAuthenticationP12() throws SQLException, IOEx @Disabled public void testValidGoogleUserAccountAuthentication() throws SQLException { String connection_uri = - getBaseConnectionUrl() + "PROJECTID=" + getBaseConnectionUrl() + + "PROJECTID=" + PROJECT_ID + ";OAuthType=1;OAuthClientId=client_id;OAuthClientSecret=client_secret;"; @@ -214,7 +210,8 @@ public void testValidGoogleUserAccountAuthentication() throws SQLException { @Disabled public void testValidExternalAccountAuthentication() throws SQLException { String connection_uri = - getBaseConnectionUrl() + "PROJECTID=" + getBaseConnectionUrl() + + "PROJECTID=" + PROJECT_ID + ";OAUTHTYPE=4;" + "BYOID_AudienceUri=//iam.googleapis.com/projects//locations//workloadIdentityPools//providers/;" @@ -238,7 +235,8 @@ public void testValidExternalAccountAuthentication() throws SQLException { @Disabled public void testValidExternalAccountAuthenticationFromFile() throws SQLException { String connection_uri = - getBaseConnectionUrl() + "PROJECTID=" + getBaseConnectionUrl() + + "PROJECTID=" + PROJECT_ID + ";OAUTHTYPE=4;" + "OAuthPvtKeyPath=/path/to/file;"; @@ -260,7 +258,8 @@ public void testValidExternalAccountAuthenticationFromFile() throws SQLException @Disabled public void testValidExternalAccountAuthenticationRawJson() throws SQLException { String connection_uri = - getBaseConnectionUrl() + "PROJECTID=" + getBaseConnectionUrl() + + "PROJECTID=" + PROJECT_ID + ";OAUTHTYPE=4;OAuthPvtKey={\n" + " \"universe_domain\": \"googleapis.com\",\n" @@ -304,7 +303,8 @@ public void testValidPreGeneratedAccessTokenAuthentication(String scope, boolean String accessToken = credentials.getAccessToken().getTokenValue(); String connectionUri = - getBaseConnectionUrl() + "ProjectId=" + getBaseConnectionUrl() + + "ProjectId=" + authJson.get("project_id").getAsString() + ";OAuthType=2" + ";OAuthAccessToken=" @@ -320,7 +320,8 @@ public void testValidPreGeneratedAccessTokenAuthentication(String scope, boolean @Disabled public void testValidRefreshTokenAuthentication() throws SQLException { String connection_uri = - getBaseConnectionUrl() + "PROJECTID=" + getBaseConnectionUrl() + + "PROJECTID=" + PROJECT_ID + ";OAUTHTYPE=2;OAuthRefreshToken=refresh_token;" + ";OAuthClientId=client;OAuthClientSecret=secret;"; diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBase.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBase.java index dbe16bea9516..5b6377f6f885 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBase.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBase.java @@ -17,13 +17,13 @@ package com.google.cloud.bigquery.jdbc.it; import static org.junit.jupiter.api.Assertions.assertNotNull; -import com.google.cloud.bigquery.jdbc.utils.TestUtilities; import com.google.cloud.ServiceOptions; import com.google.cloud.bigquery.BigQuery; import com.google.cloud.bigquery.BigQueryOptions; import com.google.cloud.bigquery.QueryJobConfiguration; import com.google.cloud.bigquery.jdbc.BigQueryJdbcBaseTest; +import com.google.cloud.bigquery.jdbc.utils.TestUtilities; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -183,10 +183,8 @@ public static String getBaseConnectionUrl() { return TestUtilities.getBaseConnectionUrl(); } - public static String connectionUrl = getBaseConnectionUrl() - + "ProjectId=" - + DEFAULT_CATALOG - + ";OAuthType=3;Timeout=3600;"; + public static String connectionUrl = + getBaseConnectionUrl() + "ProjectId=" + DEFAULT_CATALOG + ";OAuthType=3;Timeout=3600;"; public static final String createDatasetQuery = "CREATE SCHEMA IF NOT EXISTS `%s.%s` OPTIONS(default_table_expiration_days = 5)"; diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java index 9aba6bd1b5a7..3e4ede6589b3 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java @@ -16,7 +16,6 @@ package com.google.cloud.bigquery.jdbc.it; - import static com.google.common.truth.Truth.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -106,7 +105,9 @@ public void testValidAllDataTypesSerializationFromSelectQueryArrowDataset() thro String DATASET = "JDBC_INTEGRATION_DATASET"; String TABLE_NAME = "JDBC_INTEGRATION_ARROW_TEST_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME + " LIMIT 5000;"; - String connection_uri = ITBigQueryJDBCTest.connection_uri + "EnableHighThroughputAPI=1;HighThroughputActivationRatio=2;HighThroughputMinTableSize=1000;"; + String connection_uri = + ITBigQueryJDBCTest.connection_uri + + "EnableHighThroughputAPI=1;HighThroughputActivationRatio=2;HighThroughputMinTableSize=1000;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -232,7 +233,8 @@ public void testReadAPIPathLarge() throws SQLException { @Test public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { String connectionUri = - ITBigQueryJDBCTest.connection_uri + "MaxResults=300;HighThroughputActivationRatio=2;" + ITBigQueryJDBCTest.connection_uri + + "MaxResults=300;HighThroughputActivationRatio=2;" + "HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); @@ -247,7 +249,8 @@ public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { @Test public void testReadAPIPathLargeWithThresholdNotMet() throws SQLException { String connectionUri = - ITBigQueryJDBCTest.connection_uri + "HighThroughputActivationRatio=4;" + ITBigQueryJDBCTest.connection_uri + + "HighThroughputActivationRatio=4;" + "HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); @@ -293,8 +296,7 @@ public void testInvalidQuery() throws SQLException { @Test public void testDriver() throws SQLException { - String connection_uri = - ITBigQueryJDBCTest.connection_uri; + String connection_uri = ITBigQueryJDBCTest.connection_uri; Driver driver = BigQueryDriver.getRegisteredDriver(); assertTrue(driver.acceptsURL(connection_uri)); @@ -309,8 +311,7 @@ public void testDriver() throws SQLException { @Test public void testDefaultDataset() throws SQLException { - String connection_uri = - ITBigQueryJDBCTest.connection_uri + "DEFAULTDATASET=testDataset"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "DEFAULTDATASET=testDataset"; Driver driver = BigQueryDriver.getRegisteredDriver(); assertTrue(driver.acceptsURL(connection_uri)); @@ -321,8 +322,7 @@ public void testDefaultDataset() throws SQLException { DatasetId.of("testDataset"), connection.unwrap(BigQueryConnection.class).getDefaultDataset()); - String connection_uri_null_default_dataset = - ITBigQueryJDBCTest.connection_uri; + String connection_uri_null_default_dataset = ITBigQueryJDBCTest.connection_uri; assertTrue(driver.acceptsURL(connection_uri_null_default_dataset)); @@ -336,9 +336,7 @@ public void testDefaultDataset() throws SQLException { @Test public void testDefaultDatasetWithProject() throws SQLException { String connection_uri = - ITBigQueryJDBCTest.connection_uri + "DEFAULTDATASET=" - + PROJECT_ID - + ".testDataset"; + ITBigQueryJDBCTest.connection_uri + "DEFAULTDATASET=" + PROJECT_ID + ".testDataset"; Driver driver = BigQueryDriver.getRegisteredDriver(); assertTrue(driver.acceptsURL(connection_uri)); @@ -353,8 +351,7 @@ public void testDefaultDatasetWithProject() throws SQLException { @Test public void testLocation() throws SQLException { - String connection_uri = - ITBigQueryJDBCTest.connection_uri + "LOCATION=EU"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "LOCATION=EU"; Driver driver = BigQueryDriver.getRegisteredDriver(); assertTrue(driver.acceptsURL(connection_uri)); @@ -370,8 +367,7 @@ public void testLocation() throws SQLException { ResultSet resultSet = statement.executeQuery(query); assertEquals(100, resultSetRowCount(resultSet)); - String connection_uri_null_location = - ITBigQueryJDBCTest.connection_uri; + String connection_uri_null_location = ITBigQueryJDBCTest.connection_uri; assertTrue(driver.acceptsURL(connection_uri_null_location)); @@ -384,8 +380,7 @@ public void testLocation() throws SQLException { @Test public void testIncorrectLocation() throws SQLException { - String connection_uri = - ITBigQueryJDBCTest.connection_uri + "LOCATION=europe-west3"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "LOCATION=europe-west3"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -1264,7 +1259,9 @@ public void testAllValidStatementTypesForAddBatch() throws SQLException { @Test public void testUnsupportedHTAPIFallbacksToStandardQueriesWithRange() throws SQLException { String selectQuery = "select * from `DATATYPERANGETEST.RangeIntervalTestTable` LIMIT 5000;"; - String connection_uri = ITBigQueryJDBCTest.connection_uri + "MaxResults=500;HighThroughputActivationRatio=1;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;UnsupportedHTAPIFallback=1;JobCreationMode=1;"; + String connection_uri = + ITBigQueryJDBCTest.connection_uri + + "MaxResults=500;HighThroughputActivationRatio=1;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;UnsupportedHTAPIFallback=1;JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1282,7 +1279,9 @@ public void testUnsupportedHTAPIFallbacksToStandardQueriesWithRange() throws SQL public void testIntervalDataTypeWithArrowResultSet() throws SQLException { String selectQuery = "select * from `DATATYPERANGETEST.RangeIntervalTestTable` order by intColumn limit 5000;"; - String connection_uri = ITBigQueryJDBCTest.connection_uri + "MaxResults=500;HighThroughputActivationRatio=0;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;JobCreationMode=1;"; + String connection_uri = + ITBigQueryJDBCTest.connection_uri + + "MaxResults=500;HighThroughputActivationRatio=0;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1301,7 +1300,9 @@ public void testIntervalDataTypeWithArrowResultSet() throws SQLException { public void testIntervalDataTypeWithJsonResultSet() throws SQLException { String selectQuery = "select * from `DATATYPERANGETEST.RangeIntervalTestTable` order by intColumn limit 10 ;"; - String connection_uri = ITBigQueryJDBCTest.connection_uri + "MaxResults=500;HighThroughputActivationRatio=1;HighThroughputMinTableSize=100;EnableHighThroughputAPI=0;JobCreationMode=1;"; + String connection_uri = + ITBigQueryJDBCTest.connection_uri + + "MaxResults=500;HighThroughputActivationRatio=1;HighThroughputMinTableSize=100;EnableHighThroughputAPI=0;JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1633,7 +1634,8 @@ public void testPreparedStatementDateTimeValues() throws SQLException { public void testValidDestinationTableSavesQueriesWithLegacySQL() throws SQLException { // setup String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + ITBigQueryJDBCTest.connection_uri + + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=1;" + "LargeResultTable=destination_table_test_legacy;" + "LargeResultDataset=INTEGRATION_TESTS;"; @@ -1661,8 +1663,7 @@ public void testValidDestinationTableSavesQueriesWithLegacySQL() throws SQLExcep @Test public void testNonEnabledUseLegacySQLThrowsSyntaxError() throws SQLException { // setup - String connection_uri = - ITBigQueryJDBCTest.connection_uri; + String connection_uri = ITBigQueryJDBCTest.connection_uri; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 20000000;"; Connection connection = DriverManager.getConnection(connection_uri, new Properties()); @@ -1695,7 +1696,8 @@ public void testUseLegacySQLWithLargeResultsNotAllowedQueries() throws SQLExcept public void testValidDestinationTableSavesQueriesWithStandardSQL() throws SQLException { // setup String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryDialect=SQL;" + ITBigQueryJDBCTest.connection_uri + + "QueryDialect=SQL;" + "LargeResultTable=destination_table_test;" + "LargeResultDataset=INTEGRATION_TESTS;"; String selectLegacyQuery = @@ -1724,7 +1726,8 @@ public void testDestinationTableAndDestinationDatasetThatDoesNotExistsCreates() throws SQLException { // setup String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + ITBigQueryJDBCTest.connection_uri + + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=1;" + "LargeResultTable=FakeTable;" + "LargeResultDataset=FakeDataset;"; @@ -1771,7 +1774,8 @@ public void testUseLegacySQLWithLargeResultsAllowedWithNoDestinationTableDefault public void testDestinationTableWithMissingDestinationDatasetDefaults() throws SQLException { // setup String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + ITBigQueryJDBCTest.connection_uri + + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=1;" + "LargeResultTable=FakeTable;"; String selectLegacyQuery = @@ -1800,7 +1804,8 @@ public void testNonSelectForLegacyDestinationTableThrows() throws SQLException { "CREATE OR REPLACE TABLE %s.%s (`id` INTEGER, `name` STRING, `age` INTEGER);", DATASET, TRANSACTION_TABLE); String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + ITBigQueryJDBCTest.connection_uri + + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=1;" + "LargeResultTable=destination_table_test;" + "LargeResultDataset=INTEGRATION_TESTS;"; @@ -1822,7 +1827,8 @@ public void testNonSelectForStandardDestinationTableDoesNotThrow() throws SQLExc "CREATE OR REPLACE TABLE %s.%s (`id` INTEGER, `name` STRING, `age` INTEGER);", DATASET, TRANSACTION_TABLE); String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryDialect=SQL;" + ITBigQueryJDBCTest.connection_uri + + "QueryDialect=SQL;" + "AllowLargeResults=1;" + "LargeResultTable=destination_table_test;" + "LargeResultDataset=INTEGRATION_TESTS;"; @@ -1900,7 +1906,9 @@ public void testRangeDataTypeWithArrowResultSet() throws SQLException { String selectQuery = "select * from `DATATYPERANGETEST.RangeIntervalTestTable` order by intColumn limit 5000;"; - String connection_uri = ITBigQueryJDBCTest.connection_uri + "MaxResults=500;HighThroughputActivationRatio=0;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;JobCreationMode=1;"; + String connection_uri = + ITBigQueryJDBCTest.connection_uri + + "MaxResults=500;HighThroughputActivationRatio=0;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1946,7 +1954,8 @@ public void testAlterTable() throws SQLException { public void testQueryPropertyDataSetProjectIdQueriesToCorrectDataset() throws SQLException { String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryProperties=dataset_project_id=" + ITBigQueryJDBCTest.connection_uri + + "QueryProperties=dataset_project_id=" + PROJECT_ID + ";"; String insertQuery = @@ -1977,7 +1986,8 @@ public void testQueryPropertyDataSetProjectIdQueriesToCorrectDataset() throws SQ public void testQueryPropertyDataSetProjectIdQueriesToIncorrectDatasetThrows() throws SQLException { String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryProperties=dataset_project_id=bigquerytestdefault" + ITBigQueryJDBCTest.connection_uri + + "QueryProperties=dataset_project_id=bigquerytestdefault" + ";"; String insertQuery = String.format( @@ -2015,9 +2025,7 @@ public void testQueryPropertySessionIdSetsStatementSession() throws SQLException, InterruptedException { String sessionId = getSessionId(); String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryProperties=session_id=" - + sessionId - + ";"; + ITBigQueryJDBCTest.connection_uri + "QueryProperties=session_id=" + sessionId + ";"; String selectQuery = "INSERT INTO `bigquery-devtools-drivers.JDBC_INTEGRATION_DATASET.No_KMS_Test_table` (id," + " name, age) VALUES (132, 'Batman', 531);"; @@ -2042,10 +2050,7 @@ public void testQueryPropertySessionIdSetsStatementSession() public void testEncryptedTableWithKmsQueries() throws SQLException { // setup String KMSKeyName = requireEnvVar("KMS_RESOURCE_PATH"); - String connection_uri = - ITBigQueryJDBCTest.connection_uri + "KMSKeyName=" - + KMSKeyName - + ";"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "KMSKeyName=" + KMSKeyName + ";"; String selectQuery = "SELECT * FROM `JDBC_INTEGRATION_DATASET.KMS_Test_table`;"; Driver driver = BigQueryDriver.getRegisteredDriver(); Connection connection = driver.connect(connection_uri, new Properties()); @@ -2064,10 +2069,7 @@ public void testEncryptedTableWithKmsQueries() throws SQLException { @Test public void testIncorrectKmsThrows() throws SQLException { String KMSKeyName = requireEnvVar("KMS_RESOURCE_PATH"); - String connection_uri = - ITBigQueryJDBCTest.connection_uri + "KMSKeyName=" - + KMSKeyName - + ";"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "KMSKeyName=" + KMSKeyName + ";"; String selectQuery = "INSERT INTO `bigquery-devtools-drivers.JDBC_INTEGRATION_DATASET.No_KMS_Test_table` (id," + " name, age) VALUES (132, 'Batman', 531);"; @@ -2084,7 +2086,8 @@ public void testIncorrectKmsThrows() throws SQLException { public void testQueryPropertyServiceAccountFollowsIamPermission() throws SQLException { final String SERVICE_ACCOUNT_EMAIL = requireEnvVar("SA_EMAIL"); String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryProperties=service_account=" + ITBigQueryJDBCTest.connection_uri + + "QueryProperties=service_account=" + SERVICE_ACCOUNT_EMAIL + ";"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -2108,7 +2111,7 @@ public void testValidLegacySQLStatement() throws SQLException { + "FROM\n" + " [bigquery-public-data.github_repos.commits],\n" + " [bigquery-public-data.github_repos.sample_commits] LIMIT 10"; -String connection_uri = ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;"; + String connection_uri = ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;"; Connection connection = DriverManager.getConnection(connection_uri); Statement statement = connection.createStatement(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java index 58630b6175cf..91e0bc1197ae 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java @@ -100,8 +100,7 @@ public void testPooledConnectionRemoveConnectionListener() throws SQLException { @Test public void testPooledConnectionConnectionClosed() throws SQLException { - String connectionUrl = - ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -124,8 +123,7 @@ public void testPooledConnectionConnectionClosed() throws SQLException { @Test public void testPooledConnectionClose() throws SQLException { - String connectionUrl = - ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -144,8 +142,7 @@ public void testPooledConnectionClose() throws SQLException { @Test public void testPooledConnectionConnectionError() throws SQLException { - String connectionUrl = - ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -173,8 +170,7 @@ public void testPooledConnectionConnectionError() throws SQLException { @Test public void testPooledConnectionListenerAddListener() throws SQLException { - String connectionUrl = - ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -189,8 +185,7 @@ public void testPooledConnectionListenerAddListener() throws SQLException { @Test public void testPooledConnectionListenerRemoveListener() throws SQLException { - String connectionUrl = - ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -208,8 +203,7 @@ public void testPooledConnectionListenerRemoveListener() throws SQLException { @Test public void testPooledConnectionListenerCloseConnection() throws SQLException { - String connectionUrl = - ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -231,8 +225,7 @@ public void testPooledConnectionListenerCloseConnection() throws SQLException { @Test public void testPooledConnectionListenerClosePooledConnection() throws SQLException { - String connectionUrl = - ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -249,8 +242,7 @@ public void testPooledConnectionListenerClosePooledConnection() throws SQLExcept @Test public void testPooledConnectionListenerConnectionError() throws SQLException { - String connectionUrl = - ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -283,7 +275,8 @@ public void testExecuteQueryWithConnectionPoolingEnabledDefaultPoolSize() throws @Test public void testExecuteQueryWithConnectionPoolingEnabledCustomPoolSize() throws SQLException { - String connectionURL = ITBase.connectionUrl + "ConnectionPoolSize=" + CUSTOM_CONN_POOL_SIZE + ";"; + String connectionURL = + ITBase.connectionUrl + "ConnectionPoolSize=" + CUSTOM_CONN_POOL_SIZE + ";"; assertConnectionPoolingResults(connectionURL, CUSTOM_CONN_POOL_SIZE); } diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDatabaseMetadataTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDatabaseMetadataTest.java index 50d1c5178a81..ab05738a41a6 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDatabaseMetadataTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDatabaseMetadataTest.java @@ -1102,7 +1102,8 @@ public void testAdditionalProjectsInMetadata() throws SQLException { String additionalProjectsValue = "bigquery-public-data"; String datasetInAdditionalProject = "baseball"; - String urlWithAdditionalProjects = ITBase.connectionUrl + "AdditionalProjects=" + additionalProjectsValue; + String urlWithAdditionalProjects = + ITBase.connectionUrl + "AdditionalProjects=" + additionalProjectsValue; try (Connection conn = DriverManager.getConnection(urlWithAdditionalProjects)) { DatabaseMetaData dbMetaData = conn.getMetaData(); @@ -1162,7 +1163,11 @@ public void testFilterTablesOnDefaultDataset_getTables() throws SQLException { String table1InSpecificDataset = "base_table"; String table2InSpecificDataset = "external_table"; - String connectionUrl = ITDatabaseMetadataTest.connectionUrl + "DefaultDataset=" + defaultDatasetValue + ";FilterTablesOnDefaultDataset=1"; + String connectionUrl = + ITDatabaseMetadataTest.connectionUrl + + "DefaultDataset=" + + defaultDatasetValue + + ";FilterTablesOnDefaultDataset=1"; try (Connection conn = DriverManager.getConnection(connectionUrl)) { DatabaseMetaData dbMetaData = conn.getMetaData(); @@ -1227,7 +1232,11 @@ public void testFilterTablesOnDefaultDataset_getColumns() throws SQLException { String tableInSpecificDataset = "base_table"; String[] columnsInSpecificTable = {"id", "name", "created_at"}; - String connectionUrl = ITDatabaseMetadataTest.connectionUrl + "DefaultDataset=" + defaultDatasetValue + ";FilterTablesOnDefaultDataset=1"; + String connectionUrl = + ITDatabaseMetadataTest.connectionUrl + + "DefaultDataset=" + + defaultDatasetValue + + ";FilterTablesOnDefaultDataset=1"; try (Connection conn = DriverManager.getConnection(connectionUrl)) { DatabaseMetaData dbMetaData = conn.getMetaData(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java index 6ab6c890d0e5..52bcdc85d7e0 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java @@ -336,7 +336,9 @@ public void testExecuteLargeUpdate() throws SQLException { @Test public void testHTAPIWithValidDestinationTableSavesQueriesWithStandardSQL() throws SQLException { // setup - String connection_uri = ITNightlyBigQueryTest.connection_uri + "QueryDialect=SQL;LargeResultTable=destination_table_test;LargeResultDataset=INTEGRATION_TESTS;EnableHighThroughputAPI=1;"; + String connection_uri = + ITNightlyBigQueryTest.connection_uri + + "QueryDialect=SQL;LargeResultTable=destination_table_test;LargeResultDataset=INTEGRATION_TESTS;EnableHighThroughputAPI=1;"; String selectLegacyQuery = "SELECT * FROM `bigquery-public-data.deepmind_alphafold.metadata` LIMIT 200000;"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -718,7 +720,9 @@ public void testFailedStatementInTheMiddleOfExecuteBatchStopsExecuting() throws @Test public void testHTAPIWithValidDestinationTableSavesQueriesWithLegacy() throws SQLException { // setup - String connection_uri = ITNightlyBigQueryTest.connection_uri + "QueryDialect=BIG_QUERY;LargeResultTable=destination_table_test;LargeResultDataset=INTEGRATION_TESTS;EnableHighThroughputAPI=1;"; + String connection_uri = + ITNightlyBigQueryTest.connection_uri + + "QueryDialect=BIG_QUERY;LargeResultTable=destination_table_test;LargeResultDataset=INTEGRATION_TESTS;EnableHighThroughputAPI=1;"; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200000;"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -1098,8 +1102,9 @@ public void testValidAllDataTypesSerializationFromSelectQueryArrowDataset() thro String DATASET = "JDBC_INTEGRATION_DATASET"; String TABLE_NAME = "JDBC_INTEGRATION_ARROW_TEST_TABLE"; String selectQuery = "select * from " + DATASET + "." + TABLE_NAME + " LIMIT 5000;"; - String connection_uri = ITNightlyBigQueryTest.connection_uri + "EnableHighThroughputAPI=1;HighThroughputActivationRatio=2;HighThroughputMinTableSize=1000;"; - + String connection_uri = + ITNightlyBigQueryTest.connection_uri + + "EnableHighThroughputAPI=1;HighThroughputActivationRatio=2;HighThroughputMinTableSize=1000;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1155,7 +1160,9 @@ public void testBulkInsertOperation() throws SQLException { String dropQuery = String.format("DROP TABLE %s.%s", DATASET, TABLE_NAME); String selectQuery = String.format("SELECT * FROM %s.%s", DATASET, TABLE_NAME); - String connection_uri = ITNightlyBigQueryTest.connection_uri + "EnableWriteAPI=1;SWA_ActivationRowCount=5;SWA_AppendRowCount=500"; + String connection_uri = + ITNightlyBigQueryTest.connection_uri + + "EnableWriteAPI=1;SWA_ActivationRowCount=5;SWA_AppendRowCount=500"; try (Connection connection = DriverManager.getConnection(connection_uri)) { bigQueryStatement.execute(createQuery); @@ -1200,7 +1207,9 @@ public void testBulkInsertOperationStandard() throws SQLException { String dropQuery = String.format("DROP TABLE %s.%s", DATASET, TABLE_NAME); String selectQuery = String.format("SELECT * FROM %s.%s", DATASET, TABLE_NAME); - String connection_uri = ITNightlyBigQueryTest.connection_uri + "EnableWriteAPI=0;SWA_ActivationRowCount=50;SWA_AppendRowCount=500"; + String connection_uri = + ITNightlyBigQueryTest.connection_uri + + "EnableWriteAPI=0;SWA_ActivationRowCount=50;SWA_AppendRowCount=500"; try (Connection connection = DriverManager.getConnection(connection_uri)) { bigQueryStatement.execute(createQuery); @@ -1329,7 +1338,8 @@ public void testQueryPropertySessionIdIsUsedWithTransaction() bigQueryStatement.execute(createTransactionTable); // Run the transaction - String connection_uri = ITNightlyBigQueryTest.connection_uri + "QueryProperties=session_id=" + sessionId + ";"; + String connection_uri = + ITNightlyBigQueryTest.connection_uri + "QueryProperties=session_id=" + sessionId + ";"; Driver driver = BigQueryDriver.getRegisteredDriver(); Connection connection = driver.connect(connection_uri, new Properties()); Statement statement = connection.createStatement(); @@ -1613,7 +1623,9 @@ public void testReadAPIPathLarge() throws SQLException { @Test public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { - String connectionUri = ITNightlyBigQueryTest.connection_uri + "MaxResults=300;HighThroughputActivationRatio=2;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + String connectionUri = + ITNightlyBigQueryTest.connection_uri + + "MaxResults=300;HighThroughputActivationRatio=2;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); @@ -1628,7 +1640,9 @@ public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { @Test public void testReadAPIPathLargeWithThresholdNotMet() throws SQLException { - String connectionUri = ITNightlyBigQueryTest.connection_uri + "HighThroughputActivationRatio=4;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + String connectionUri = + ITNightlyBigQueryTest.connection_uri + + "HighThroughputActivationRatio=4;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITResultSetMetadataTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITResultSetMetadataTest.java index bd893e76729a..65a3b888d4fd 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITResultSetMetadataTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITResultSetMetadataTest.java @@ -55,8 +55,7 @@ public static void afterClass() throws InterruptedException { @Test public void testResultSetMetadata() throws SQLException { String selectData = "SELECT * FROM " + DATASET + "." + TABLE_NAME + ";"; - Connection connection = - DriverManager.getConnection(ITBase.connectionUrl); + Connection connection = DriverManager.getConnection(ITBase.connectionUrl); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(selectData); metaData = resultSet.getMetaData(); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/utils/TestUtilities.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/utils/TestUtilities.java index dbca17096534..e395c124a8f7 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/utils/TestUtilities.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/utils/TestUtilities.java @@ -150,7 +150,8 @@ private static String getEnvOrProperty(String envVar, String sysProp, String def } public static String getBaseUrl() { - return getEnvOrProperty("BIGQUERY_BASE_URL", "bigquery.baseUrl", "https://www.googleapis.com/bigquery/v2:443"); + return getEnvOrProperty( + "BIGQUERY_BASE_URL", "bigquery.baseUrl", "https://www.googleapis.com/bigquery/v2:443"); } public static String getUrlFlags() { From 870f8f6861e3672ed46be86b2edd9097a17b6295 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Wed, 10 Jun 2026 22:48:44 +0000 Subject: [PATCH 4/4] Reduce format changes --- .../cloud/bigquery/jdbc/it/ITAuthTests.java | 19 ++++++--- .../bigquery/jdbc/it/ITBigQueryJDBCTest.java | 42 ++++++++++++++----- .../jdbc/it/ITConnectionPoolingTest.java | 22 +++++----- .../jdbc/it/ITNightlyBigQueryTest.java | 31 ++++++++++---- 4 files changed, 80 insertions(+), 34 deletions(-) diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java index f7e2108ca68d..1d6bac0cd257 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITAuthTests.java @@ -191,7 +191,9 @@ public void testValidGoogleUserAccountAuthentication() throws SQLException { getBaseConnectionUrl() + "PROJECTID=" + PROJECT_ID - + ";OAuthType=1;OAuthClientId=client_id;OAuthClientSecret=client_secret;"; + + ";OAuthType=1;" + + "OAuthClientId=client_id;" + + "OAuthClientSecret=client_secret;"; Connection connection = DriverManager.getConnection(connection_uri); assertNotNull(connection); @@ -215,8 +217,10 @@ public void testValidExternalAccountAuthentication() throws SQLException { + PROJECT_ID + ";OAUTHTYPE=4;" + "BYOID_AudienceUri=//iam.googleapis.com/projects//locations//workloadIdentityPools//providers/;" - + "BYOID_SubjectTokenType=;BYOID_CredentialSource={\"file\":\"/path/to/file\"};" - + "BYOID_SA_Impersonation_Uri=;BYOID_TokenUri=;"; + + "BYOID_SubjectTokenType=;" + + "BYOID_CredentialSource={\"file\":\"/path/to/file\"};" + + "BYOID_SA_Impersonation_Uri=;" + + "BYOID_TokenUri=;"; Connection connection = DriverManager.getConnection(connection_uri); assertNotNull(connection); @@ -261,7 +265,8 @@ public void testValidExternalAccountAuthenticationRawJson() throws SQLException getBaseConnectionUrl() + "PROJECTID=" + PROJECT_ID - + ";OAUTHTYPE=4;OAuthPvtKey={\n" + + ";OAUTHTYPE=4;" + + "OAuthPvtKey={\n" + " \"universe_domain\": \"googleapis.com\",\n" + " \"type\": \"external_account\",\n" + " \"audience\":" @@ -323,8 +328,10 @@ public void testValidRefreshTokenAuthentication() throws SQLException { getBaseConnectionUrl() + "PROJECTID=" + PROJECT_ID - + ";OAUTHTYPE=2;OAuthRefreshToken=refresh_token;" - + ";OAuthClientId=client;OAuthClientSecret=secret;"; + + ";OAUTHTYPE=2;" + + "OAuthRefreshToken=refresh_token;" + + ";OAuthClientId=client;" + + "OAuthClientSecret=secret;"; Connection connection = DriverManager.getConnection(connection_uri); assertNotNull(connection); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java index 3e4ede6589b3..44a8160f726d 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java @@ -107,7 +107,9 @@ public void testValidAllDataTypesSerializationFromSelectQueryArrowDataset() thro String selectQuery = "select * from " + DATASET + "." + TABLE_NAME + " LIMIT 5000;"; String connection_uri = ITBigQueryJDBCTest.connection_uri - + "EnableHighThroughputAPI=1;HighThroughputActivationRatio=2;HighThroughputMinTableSize=1000;"; + + "EnableHighThroughputAPI=1;" + + "HighThroughputActivationRatio=2;" + + "HighThroughputMinTableSize=1000;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -234,8 +236,10 @@ public void testReadAPIPathLarge() throws SQLException { public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { String connectionUri = ITBigQueryJDBCTest.connection_uri - + "MaxResults=300;HighThroughputActivationRatio=2;" - + "HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + + "MaxResults=300;" + + "HighThroughputActivationRatio=2;" + + "HighThroughputMinTableSize=100;" + + "EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); int expectedCnt = 1000; @@ -251,7 +255,8 @@ public void testReadAPIPathLargeWithThresholdNotMet() throws SQLException { String connectionUri = ITBigQueryJDBCTest.connection_uri + "HighThroughputActivationRatio=4;" - + "HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + + "HighThroughputMinTableSize=100;" + + "EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); int expectedCnt = 5000; @@ -1261,7 +1266,12 @@ public void testUnsupportedHTAPIFallbacksToStandardQueriesWithRange() throws SQL String selectQuery = "select * from `DATATYPERANGETEST.RangeIntervalTestTable` LIMIT 5000;"; String connection_uri = ITBigQueryJDBCTest.connection_uri - + "MaxResults=500;HighThroughputActivationRatio=1;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;UnsupportedHTAPIFallback=1;JobCreationMode=1;"; + + "MaxResults=500;" + + "HighThroughputActivationRatio=1;" + + "HighThroughputMinTableSize=100;" + + "EnableHighThroughputAPI=1;" + + "UnsupportedHTAPIFallback=1;" + + "JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1281,7 +1291,11 @@ public void testIntervalDataTypeWithArrowResultSet() throws SQLException { "select * from `DATATYPERANGETEST.RangeIntervalTestTable` order by intColumn limit 5000;"; String connection_uri = ITBigQueryJDBCTest.connection_uri - + "MaxResults=500;HighThroughputActivationRatio=0;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;JobCreationMode=1;"; + + "MaxResults=500;" + + "HighThroughputActivationRatio=0;" + + "HighThroughputMinTableSize=100;" + + "EnableHighThroughputAPI=1;" + + "JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1302,7 +1316,11 @@ public void testIntervalDataTypeWithJsonResultSet() throws SQLException { "select * from `DATATYPERANGETEST.RangeIntervalTestTable` order by intColumn limit 10 ;"; String connection_uri = ITBigQueryJDBCTest.connection_uri - + "MaxResults=500;HighThroughputActivationRatio=1;HighThroughputMinTableSize=100;EnableHighThroughputAPI=0;JobCreationMode=1;"; + + "MaxResults=500;" + + "HighThroughputActivationRatio=1;" + + "HighThroughputMinTableSize=100;" + + "EnableHighThroughputAPI=0;" + + "JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1678,7 +1696,7 @@ public void testNonEnabledUseLegacySQLThrowsSyntaxError() throws SQLException { public void testUseLegacySQLWithLargeResultsNotAllowedQueries() throws SQLException { // setup String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;AllowLargeResults=0;"; + ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=0;"; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 250000;"; Connection connection = DriverManager.getConnection(connection_uri, new Properties()); @@ -1756,7 +1774,7 @@ public void testUseLegacySQLWithLargeResultsAllowedWithNoDestinationTableDefault throws SQLException { // setup String connection_uri = - ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;AllowLargeResults=1;"; + ITBigQueryJDBCTest.connection_uri + "QueryDialect=BIG_QUERY;" + "AllowLargeResults=1;"; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 250000;"; Connection connection = DriverManager.getConnection(connection_uri, new Properties()); @@ -1908,7 +1926,11 @@ public void testRangeDataTypeWithArrowResultSet() throws SQLException { String connection_uri = ITBigQueryJDBCTest.connection_uri - + "MaxResults=500;HighThroughputActivationRatio=0;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1;JobCreationMode=1;"; + + "MaxResults=500;" + + "HighThroughputActivationRatio=0;" + + "HighThroughputMinTableSize=100;" + + "EnableHighThroughputAPI=1;" + + "JobCreationMode=1;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java index 91e0bc1197ae..0da773d7c965 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITConnectionPoolingTest.java @@ -43,7 +43,7 @@ public class ITConnectionPoolingTest extends ITBase { @Test public void testPooledConnectionDataSourceSuccess() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -70,7 +70,7 @@ public void testPooledConnectionDataSourceFailInvalidConnectionURl() { @Test public void testPooledConnectionAddConnectionListener() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -85,7 +85,7 @@ public void testPooledConnectionAddConnectionListener() throws SQLException { @Test public void testPooledConnectionRemoveConnectionListener() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -100,7 +100,7 @@ public void testPooledConnectionRemoveConnectionListener() throws SQLException { @Test public void testPooledConnectionConnectionClosed() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -123,7 +123,7 @@ public void testPooledConnectionConnectionClosed() throws SQLException { @Test public void testPooledConnectionClose() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -142,7 +142,7 @@ public void testPooledConnectionClose() throws SQLException { @Test public void testPooledConnectionConnectionError() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -170,7 +170,7 @@ public void testPooledConnectionConnectionError() throws SQLException { @Test public void testPooledConnectionListenerAddListener() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -185,7 +185,7 @@ public void testPooledConnectionListenerAddListener() throws SQLException { @Test public void testPooledConnectionListenerRemoveListener() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -203,7 +203,7 @@ public void testPooledConnectionListenerRemoveListener() throws SQLException { @Test public void testPooledConnectionListenerCloseConnection() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -225,7 +225,7 @@ public void testPooledConnectionListenerCloseConnection() throws SQLException { @Test public void testPooledConnectionListenerClosePooledConnection() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); @@ -242,7 +242,7 @@ public void testPooledConnectionListenerClosePooledConnection() throws SQLExcept @Test public void testPooledConnectionListenerConnectionError() throws SQLException { - String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;ListenerPoolSize=20;"; + String connectionUrl = ITBase.connectionUrl + "ConnectionPoolSize=20;" + "ListenerPoolSize=20;"; PooledConnectionDataSource pooledDataSource = new PooledConnectionDataSource(); pooledDataSource.setURL(connectionUrl); diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java index 52bcdc85d7e0..ff9dbf0e7060 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITNightlyBigQueryTest.java @@ -338,7 +338,10 @@ public void testHTAPIWithValidDestinationTableSavesQueriesWithStandardSQL() thro // setup String connection_uri = ITNightlyBigQueryTest.connection_uri - + "QueryDialect=SQL;LargeResultTable=destination_table_test;LargeResultDataset=INTEGRATION_TESTS;EnableHighThroughputAPI=1;"; + + "QueryDialect=SQL;" + + "LargeResultTable=destination_table_test;" + + "LargeResultDataset=INTEGRATION_TESTS;" + + "EnableHighThroughputAPI=1;"; String selectLegacyQuery = "SELECT * FROM `bigquery-public-data.deepmind_alphafold.metadata` LIMIT 200000;"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -722,7 +725,10 @@ public void testHTAPIWithValidDestinationTableSavesQueriesWithLegacy() throws SQ // setup String connection_uri = ITNightlyBigQueryTest.connection_uri - + "QueryDialect=BIG_QUERY;LargeResultTable=destination_table_test;LargeResultDataset=INTEGRATION_TESTS;EnableHighThroughputAPI=1;"; + + "QueryDialect=BIG_QUERY;" + + "LargeResultTable=destination_table_test;" + + "LargeResultDataset=INTEGRATION_TESTS;" + + "EnableHighThroughputAPI=1;"; String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200000;"; Driver driver = BigQueryDriver.getRegisteredDriver(); @@ -1104,7 +1110,9 @@ public void testValidAllDataTypesSerializationFromSelectQueryArrowDataset() thro String selectQuery = "select * from " + DATASET + "." + TABLE_NAME + " LIMIT 5000;"; String connection_uri = ITNightlyBigQueryTest.connection_uri - + "EnableHighThroughputAPI=1;HighThroughputActivationRatio=2;HighThroughputMinTableSize=1000;"; + + "EnableHighThroughputAPI=1;" + + "HighThroughputActivationRatio=2;" + + "HighThroughputMinTableSize=1000;"; // Read data via JDBC Connection connection = DriverManager.getConnection(connection_uri); @@ -1162,7 +1170,9 @@ public void testBulkInsertOperation() throws SQLException { String connection_uri = ITNightlyBigQueryTest.connection_uri - + "EnableWriteAPI=1;SWA_ActivationRowCount=5;SWA_AppendRowCount=500"; + + "EnableWriteAPI=1;" + + "SWA_ActivationRowCount=5;" + + "SWA_AppendRowCount=500"; try (Connection connection = DriverManager.getConnection(connection_uri)) { bigQueryStatement.execute(createQuery); @@ -1209,7 +1219,9 @@ public void testBulkInsertOperationStandard() throws SQLException { String connection_uri = ITNightlyBigQueryTest.connection_uri - + "EnableWriteAPI=0;SWA_ActivationRowCount=50;SWA_AppendRowCount=500"; + + "EnableWriteAPI=0;" + + "SWA_ActivationRowCount=50;" + + "SWA_AppendRowCount=500"; try (Connection connection = DriverManager.getConnection(connection_uri)) { bigQueryStatement.execute(createQuery); @@ -1625,7 +1637,10 @@ public void testReadAPIPathLarge() throws SQLException { public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { String connectionUri = ITNightlyBigQueryTest.connection_uri - + "MaxResults=300;HighThroughputActivationRatio=2;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + + "MaxResults=300;" + + "HighThroughputActivationRatio=2;" + + "HighThroughputMinTableSize=100;" + + "EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement(); @@ -1642,7 +1657,9 @@ public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { public void testReadAPIPathLargeWithThresholdNotMet() throws SQLException { String connectionUri = ITNightlyBigQueryTest.connection_uri - + "HighThroughputActivationRatio=4;HighThroughputMinTableSize=100;EnableHighThroughputAPI=1"; + + "HighThroughputActivationRatio=4;" + + "HighThroughputMinTableSize=100;" + + "EnableHighThroughputAPI=1"; Connection connection = DriverManager.getConnection(connectionUri); Statement statement = connection.createStatement();