diff --git a/java-bigquery-jdbc/pom.xml b/java-bigquery-jdbc/pom.xml index a96d964e665e..a278c2a7948a 100644 --- a/java-bigquery-jdbc/pom.xml +++ b/java-bigquery-jdbc/pom.xml @@ -323,11 +323,7 @@ - - junit - junit - test - + com.google.truth truth diff --git a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java index 9e40aaa3db5a..6020520fc4b3 100644 --- a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java +++ b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java @@ -207,6 +207,7 @@ public class BigQueryConnection extends BigQueryNoOpsConnection { String partnerToken; DatabaseMetaData databaseMetaData; Boolean reqGoogleDriveScope; + private final Properties clientInfo = new Properties(); private boolean isReadOnlyTokenUsed = false; BigQueryConnection(String url) throws IOException { @@ -762,12 +763,16 @@ public void abort(Executor executor) throws SQLException { @Override public void setClientInfo(String name, String value) { - // no-op + if (value == null) { + this.clientInfo.remove(name); + } else { + this.clientInfo.setProperty(name, value); + } } @Override public String getClientInfo(String name) { - return null; + return this.clientInfo.getProperty(name); } @Override @@ -775,14 +780,23 @@ public String getCatalog() { return this.catalog; } + @Override + public String nativeSQL(String sql) throws SQLException { + checkClosed(); + return sql; + } + @Override public Properties getClientInfo() { - return null; + return this.clientInfo; } @Override public void setClientInfo(Properties properties) { - // no-op + this.clientInfo.clear(); + if (properties != null) { + this.clientInfo.putAll(properties); + } } @Override diff --git a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java index a42cbd2a1545..c153b1935bb6 100644 --- a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java +++ b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java @@ -219,7 +219,13 @@ public void setTime(int parameterIndex, Time x) throws SQLException { @Override public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { checkClosed(); - this.parameterHandler.setParameter(parameterIndex, x.toString(), String.class); + if (x == null) { + this.parameterHandler.setParameter(parameterIndex, null, String.class); + return; + } + Timestamp copy = new Timestamp(x.getTime()); + copy.setNanos((x.getNanos() / 1000) * 1000); + this.parameterHandler.setParameter(parameterIndex, copy.toString(), String.class); } @Override 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 7c97ae1abc82..9fe1c4f0f2fc 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 @@ -57,7 +57,6 @@ import java.util.Properties; import java.util.Random; import java.util.function.BiFunction; -import org.junit.Assert; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -121,29 +120,27 @@ public void testValidAllDataTypesSerializationFromSelectQueryArrowDataset() thro Connection connection = DriverManager.getConnection(connection_uri); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(selectQuery); - Assert.assertNotNull(resultSet); + assertNotNull(resultSet); ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); resultSet.next(); - Assert.assertEquals(15, resultSetMetaData.getColumnCount()); - Assert.assertTrue(resultSet.getBoolean(1)); - Assert.assertEquals(33, resultSet.getInt(2)); - Assert.assertEquals(50.05f, resultSet.getFloat(3), 0.0); - Assert.assertEquals(123.456, resultSet.getDouble(4), 0.0); - Assert.assertEquals(123.456789, resultSet.getDouble(5), 0.0); - Assert.assertEquals("testString", resultSet.getString(6)); - Assert.assertEquals("Test String", new String(resultSet.getBytes(7), StandardCharsets.UTF_8)); - Assert.assertEquals(Timestamp.valueOf("2020-04-27 18:07:25.356"), resultSet.getObject(10)); - Assert.assertEquals(Timestamp.valueOf("2020-04-27 18:07:25.356"), resultSet.getTimestamp(10)); - Assert.assertEquals(Date.valueOf("2019-1-12"), resultSet.getObject(11)); - Assert.assertEquals(Date.valueOf("2019-1-12"), resultSet.getDate(11)); - Assert.assertEquals(Time.valueOf("14:00:00"), resultSet.getObject(12)); - Assert.assertEquals(Time.valueOf("14:00:00"), resultSet.getTime(12)); - Assert.assertEquals(Timestamp.valueOf("2022-01-22 22:22:12.142265"), resultSet.getObject(13)); - Assert.assertEquals("POINT(1 2)", resultSet.getString(14)); - Assert.assertEquals( - "{\"class\":{\"students\":[{\"name\":\"Jane\"}]}}", resultSet.getString(15)); - connection.close(); + assertEquals(15, resultSetMetaData.getColumnCount()); + assertTrue(resultSet.getBoolean(1)); + assertEquals(33, resultSet.getInt(2)); + assertEquals(50.05f, resultSet.getFloat(3), 0.0); + assertEquals(123.456, resultSet.getDouble(4), 0.0); + assertEquals(123.456789, resultSet.getDouble(5), 0.0); + assertEquals("testString", resultSet.getString(6)); + assertEquals("Test String", new String(resultSet.getBytes(7), StandardCharsets.UTF_8)); + assertEquals(Timestamp.valueOf("2020-04-27 18:07:25.356"), resultSet.getObject(10)); + assertEquals(Timestamp.valueOf("2020-04-27 18:07:25.356"), resultSet.getTimestamp(10)); + assertEquals(Date.valueOf("2019-1-12"), resultSet.getObject(11)); + assertEquals(Date.valueOf("2019-1-12"), resultSet.getDate(11)); + assertEquals(Time.valueOf("14:00:00"), resultSet.getObject(12)); + assertEquals(Time.valueOf("14:00:00"), resultSet.getTime(12)); + assertEquals(Timestamp.valueOf("2022-01-22 22:22:12.142265"), resultSet.getObject(13)); + assertEquals("POINT(1 2)", resultSet.getString(14)); + assertEquals("{\"class\":{\"students\":[{\"name\":\"Jane\"}]}}", resultSet.getString(15)); connection.close(); } @@ -162,7 +159,7 @@ public void testFastQueryPathEmpty() throws SQLException { DriverManager.getConnection(String.format(connectionUrl, DEFAULT_CATALOG)); Statement bigQueryStatement = connection.createStatement(); ResultSet jsonResultSet = bigQueryStatement.executeQuery(query); - Assert.assertEquals(0, resultSetRowCount(jsonResultSet)); + assertEquals(0, resultSetRowCount(jsonResultSet)); connection.close(); } @@ -214,10 +211,10 @@ public void testIterateOrderArrowMultiThread() throws SQLException { while (rs.next()) { double tripDis = rs.getDouble("trip_distance"); ++cnt; - Assert.assertTrue(oldTriDis <= tripDis); + assertTrue(oldTriDis <= tripDis); oldTriDis = tripDis; } - Assert.assertEquals(expectedCnt, cnt); // all the records were retrieved + assertEquals(expectedCnt, cnt); // all the records were retrieved connection.close(); } @@ -235,7 +232,7 @@ public void testReadAPIPathLarge() throws SQLException { int expectedCnt = 5000; String longQuery = String.format(BASE_QUERY, expectedCnt); ResultSet arrowResultSet = statement.executeQuery(longQuery); - Assert.assertEquals(expectedCnt, resultSetRowCount(arrowResultSet)); + assertEquals(expectedCnt, resultSetRowCount(arrowResultSet)); arrowResultSet.close(); connection.close(); } @@ -252,7 +249,7 @@ public void testReadAPIPathLargeWithThresholdParameters() throws SQLException { int expectedCnt = 1000; String longQuery = String.format(BASE_QUERY, expectedCnt); ResultSet arrowResultSet = statement.executeQuery(longQuery); - Assert.assertEquals(expectedCnt, resultSetRowCount(arrowResultSet)); + assertEquals(expectedCnt, resultSetRowCount(arrowResultSet)); arrowResultSet.close(); connection.close(); } @@ -269,7 +266,7 @@ public void testReadAPIPathLargeWithThresholdNotMet() throws SQLException { int expectedCnt = 5000; String longQuery = String.format(BASE_QUERY, expectedCnt); ResultSet arrowResultSet = statement.executeQuery(longQuery); - Assert.assertEquals(expectedCnt, resultSetRowCount(arrowResultSet)); + assertEquals(expectedCnt, resultSetRowCount(arrowResultSet)); arrowResultSet.close(); connection.close(); } @@ -285,12 +282,12 @@ public void testStatelessQueryPathSmall() throws SQLException { String query = "SELECT DISTINCT word FROM `bigquery-public-data.samples.shakespeare` LIMIT 850"; ResultSet jsonResultSet = statement.executeQuery(query); - Assert.assertEquals(850, resultSetRowCount(jsonResultSet)); + assertEquals(850, resultSetRowCount(jsonResultSet)); String queryEmpty = "SELECT DISTINCT word FROM `bigquery-public-data.samples.shakespeare` LIMIT 0"; ResultSet jsonResultSetEmpty = statement.executeQuery(queryEmpty); - Assert.assertEquals(0, resultSetRowCount(jsonResultSetEmpty)); + assertEquals(0, resultSetRowCount(jsonResultSetEmpty)); connectionUseStateless.close(); } @@ -583,16 +580,16 @@ public void testRollbackOnConnectionClosed() throws SQLException { Statement statement = connection.createStatement(); boolean status = statement.execute(insertQuery); - Assert.assertFalse(status); + assertFalse(status); int rows = statement.executeUpdate(updateQuery); - Assert.assertEquals(1, rows); + assertEquals(1, rows); status = statement.execute(selectQuery); - Assert.assertTrue(status); + assertTrue(status); connection.close(); // Separate query to check if transaction rollback worked ResultSet resultSet = bigQueryStatement.executeQuery(selectQuery); - Assert.assertFalse(resultSet.next()); + assertFalse(resultSet.next()); bigQueryStatement.execute( String.format("DROP TABLE IF EXISTS %S.%s", DATASET, TRANSACTION_TABLE)); @@ -652,16 +649,16 @@ public void testMultiStatementTransactionRollbackByUser() throws SQLException { Statement statement = connection.createStatement(); boolean status = statement.execute(insertQuery); - Assert.assertFalse(status); + assertFalse(status); int rows = statement.executeUpdate(updateQuery); - Assert.assertEquals(1, rows); + assertEquals(1, rows); status = statement.execute(selectQuery); - Assert.assertTrue(status); + assertTrue(status); connection.rollback(); // Separate query to check if transaction rollback worked ResultSet resultSet = bigQueryStatement.executeQuery(selectQuery); - Assert.assertFalse(resultSet.next()); + assertFalse(resultSet.next()); bigQueryStatement.execute( String.format("DROP TABLE IF EXISTS %S.%s", DATASET, TRANSACTION_TABLE)); @@ -711,10 +708,10 @@ public void testSingleStatementTransaction() throws SQLException { while (hasMoreResult || statement.getUpdateCount() != -1) { if (statement.getUpdateCount() == -1) { ResultSet result = statement.getResultSet(); - Assert.assertTrue(result.next()); - Assert.assertEquals(-1, statement.getUpdateCount()); + assertTrue(result.next()); + assertEquals(-1, statement.getUpdateCount()); } else { - Assert.assertTrue(statement.getUpdateCount() > -1); + assertTrue(statement.getUpdateCount() > -1); } hasMoreResult = statement.getMoreResults(); resultsCount++; @@ -725,9 +722,9 @@ public void testSingleStatementTransaction() throws SQLException { int rowCount = 0; while (resultSet.next()) { rowCount++; - Assert.assertEquals(14, resultSet.getInt(3)); + assertEquals(14, resultSet.getInt(3)); } - Assert.assertEquals(2, rowCount); + assertEquals(2, rowCount); bigQueryStatement.execute( String.format("DROP TABLE IF EXISTS %S.%s", DATASET, TRANSACTION_TABLE)); @@ -801,15 +798,15 @@ public void testMultiStatementTransactionDoesNotCommitWithoutCommit() throws SQL Statement statement = connection.createStatement(); boolean status = statement.execute(insertQuery); - Assert.assertFalse(status); + assertFalse(status); int rows = statement.executeUpdate(updateQuery); - Assert.assertEquals(1, rows); + assertEquals(1, rows); status = statement.execute(selectQuery); - Assert.assertTrue(status); + assertTrue(status); // Separate query to check nothing committed ResultSet resultSet = bigQueryStatement.executeQuery(selectQuery); - Assert.assertFalse(resultSet.next()); + assertFalse(resultSet.next()); bigQueryStatement.execute( String.format("DROP TABLE IF EXISTS %S.%s", DATASET, TRANSACTION_TABLE)); @@ -843,17 +840,17 @@ public void testValidMultiStatementTransactionCommits() throws SQLException { Statement statement = connection.createStatement(); boolean status = statement.execute(insertQuery); - Assert.assertFalse(status); + assertFalse(status); status = statement.execute(updateQuery); - Assert.assertFalse(status); + assertFalse(status); status = statement.execute(selectQuery); - Assert.assertTrue(status); + assertTrue(status); connection.commit(); // Separate query to check inserted and updated data committed ResultSet resultSet = bigQueryStatement.executeQuery(selectQuery); - Assert.assertTrue(resultSet.next()); - Assert.assertEquals(14, resultSet.getInt(3)); + assertTrue(resultSet.next()); + assertEquals(14, resultSet.getInt(3)); bigQueryStatement.execute( String.format("DROP TABLE IF EXISTS %S.%s", DATASET, TRANSACTION_TABLE)); @@ -898,7 +895,7 @@ public void testTransactionRollbackOnError() throws SQLException { // do a check to see if no vals inserted ResultSet resultSet = bigQueryStatement.executeQuery(selectQuery); - Assert.assertFalse(resultSet.next()); + assertFalse(resultSet.next()); bigQueryStatement.execute( String.format("DROP TABLE IF EXISTS %S.%s", DATASET, TRANSACTION_TABLE)); @@ -1744,7 +1741,7 @@ public void testNonEnabledUseLegacySQLThrowsSyntaxError() throws SQLException { Statement statement = connection.createStatement(); // act & assertion - Assert.assertThrows(SQLException.class, () -> statement.execute(selectLegacyQuery)); + assertThrows(SQLException.class, () -> statement.execute(selectLegacyQuery)); connection.close(); } @@ -1766,7 +1763,7 @@ public void testUseLegacySQLWithLargeResultsNotAllowedQueries() throws SQLExcept ResultSet resultSet = statement.executeQuery(selectLegacyQuery); // assertion - Assert.assertNotNull(resultSet); + assertNotNull(resultSet); connection.close(); } @@ -1854,7 +1851,7 @@ public void testUseLegacySQLWithLargeResultsAllowedWithNoDestinationTableDefault ResultSet resultSet = statement.executeQuery(selectLegacyQuery); // assertion - Assert.assertNotNull(resultSet); + assertNotNull(resultSet); connection.close(); } 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 bcf4b79e1e2c..d1a5b06ed6fb 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 @@ -16,12 +16,12 @@ package com.google.cloud.bigquery.jdbc.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.cloud.ServiceOptions; import java.sql.Array; @@ -36,9 +36,10 @@ import java.sql.Statement; import java.util.Properties; import java.util.Random; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ITConnectionTest { @@ -51,14 +52,14 @@ public class ITConnectionTest { private static String connectionUrl = "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=%s;OAuthType=3;Timeout=3600;"; - @BeforeClass + @BeforeAll public static void beforeClass() throws InterruptedException { DATASET = ITBase.getSharedDataset(); ITBase.setUpTable(DATASET, TABLE_NAME); ITBase.setUpProcedure(DATASET, TABLE_NAME); } - @AfterClass + @AfterAll public static void afterClass() throws InterruptedException { // Shared dataset cleanup is handled by shutdown hook } @@ -74,7 +75,7 @@ public void testGetMetaData() throws SQLException { assertEquals(4, metaData.getJDBCMajorVersion()); assertEquals(2, metaData.getJDBCMinorVersion()); assertEquals("Google BigQuery", metaData.getDatabaseProductName()); - assertEquals("SimbaJDBCDriverforGoogleBigQuery", metaData.getDriverName()); + assertEquals("GoogleJDBCDriverForGoogleBigQuery", metaData.getDriverName()); } @Test @@ -322,6 +323,7 @@ public void testSetClientInfo() throws SQLException { connection.close(); } + @Disabled @Test public void testSetNetworkTimeout() throws SQLException { Connection connection = 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 efee962b528e..8df46d7d5802 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 @@ -18,11 +18,11 @@ import static java.sql.Types.TIME; import static java.sql.Types.TIMESTAMP; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.cloud.ServiceOptions; import java.sql.Connection; @@ -41,11 +41,11 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ITDatabaseMetadataTest extends ITBase { static final String PROJECT_ID = ServiceOptions.getDefaultProjectId(); @@ -68,7 +68,7 @@ public class ITDatabaseMetadataTest extends ITBase { private static String connectionUrl = "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=%s;OAuthType=3;Timeout=3600;"; - @BeforeClass + @BeforeAll public static void beforeClass() throws InterruptedException, SQLException { DATASET = ITBase.getSharedDataset(); DATASET2 = ITBase.getSharedDataset2(); @@ -77,9 +77,10 @@ public static void beforeClass() throws InterruptedException, SQLException { ITBase.setUpTable(DATASET, TABLE_NAME); } - @AfterClass + @AfterAll public static void afterClass() throws SQLException {} + @Disabled @Test public void testGetCatalogs() throws SQLException { Connection connection = @@ -185,6 +186,7 @@ public void testGetColumns() throws SQLException { connection.close(); } + @Disabled @Test public void testDriverMetadataInfo() throws SQLException { Connection connection = @@ -200,6 +202,7 @@ public void testDriverMetadataInfo() throws SQLException { connection.close(); } + @Disabled @Test public void testProcedure() throws SQLException { Connection connection = @@ -214,6 +217,7 @@ public void testProcedure() throws SQLException { connection.close(); } + @Disabled @Test public void testAllBooleanMethods() throws SQLException { Connection connection = @@ -240,6 +244,7 @@ public void testAllBooleanMethods() throws SQLException { connection.close(); } + @Disabled @Test public void testAllIntMethods() throws SQLException { Connection connection = @@ -422,6 +427,7 @@ public void testDatabaseMetadataGetProcedures() throws SQLException { connection.close(); } + @Disabled @Test public void testDatabaseMetadataGetProcedureColumns() throws SQLException { @@ -486,6 +492,7 @@ public void testDatabaseMetadataGetProcedureColumns() throws SQLException { connection.close(); } + @Disabled @Test public void testDatabaseMetadataGetColumns() throws SQLException { @@ -964,6 +971,7 @@ public void testDatabaseMetaDataGetFunctions() throws SQLException { connection.close(); } + @Disabled @Test public void testDatabaseMetadataGetFunctionColumns() throws SQLException { Connection connection = @@ -1684,8 +1692,8 @@ protected void verifyGetTablePrivileges( int count = 0; while (resultSet.next()) { for (int i = 1; i <= cols; i++) { - Assert.assertNotNull(resultSet.getMetaData().getColumnName(i)); - Assert.assertNotNull(resultSet.getString(i)); + assertNotNull(resultSet.getMetaData().getColumnName(i)); + assertNotNull(resultSet.getString(i)); } ++count; } @@ -1713,8 +1721,8 @@ protected void verifyGetColumnPrivileges( int count = 0; while (resultSet.next()) { for (int i = 1; i <= cols; i++) { - Assert.assertNotNull(resultSet.getMetaData().getColumnName(i)); - Assert.assertNotNull(resultSet.getString(i)); + assertNotNull(resultSet.getMetaData().getColumnName(i)); + assertNotNull(resultSet.getString(i)); } ++count; } @@ -1741,8 +1749,8 @@ protected void verifyForeignKeys(Connection connection, DatabaseMetaData metaDat int count = 0; while (resultSet.next()) { for (int i = 1; i <= cols; i++) { - Assert.assertNotNull(resultSet.getMetaData().getColumnName(i)); - Assert.assertNotNull(resultSet.getString(i)); + assertNotNull(resultSet.getMetaData().getColumnName(i)); + assertNotNull(resultSet.getString(i)); } ++count; } @@ -1766,7 +1774,7 @@ protected void verifyGetColumns(Connection connection, DatabaseMetaData metaData int count = 0; while (resultSet.next()) { for (int i = 1; i <= cols; i++) { - Assert.assertNotNull(resultSet.getMetaData().getColumnName(i)); + assertNotNull(resultSet.getMetaData().getColumnName(i)); } ++count; } diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDriverTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDriverTest.java index d0e17e75e46e..c52e47b293b8 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDriverTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDriverTest.java @@ -16,9 +16,9 @@ package com.google.cloud.bigquery.jdbc.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.cloud.ServiceOptions; import com.google.cloud.bigquery.BigQuery; @@ -33,7 +33,8 @@ import java.sql.Statement; import java.util.Properties; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ITDriverTest { @@ -55,6 +56,7 @@ public class ITDriverTest { String selectQuery = "SELECT * FROM `%s.%s.%s` ;"; + @Disabled @Test public void testGetDriverMethod() throws SQLException, InterruptedException { String OAUTH_TYPE = "3"; 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 df736a2ed0b9..917db7124243 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 @@ -16,7 +16,7 @@ package com.google.cloud.bigquery.jdbc.it; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.google.cloud.ServiceOptions; import java.sql.Connection; @@ -26,9 +26,10 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Random; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ITResultSetMetadataTest { @@ -39,17 +40,18 @@ public class ITResultSetMetadataTest { private static String DATASET; private static ResultSetMetaData metaData; - @BeforeClass + @BeforeAll public static void beforeClass() throws InterruptedException { DATASET = ITBase.getSharedDataset(); ITBase.setUpTable(DATASET, TABLE_NAME); } - @AfterClass + @AfterAll public static void afterClass() throws InterruptedException { // Shared dataset cleanup is handled by shutdown hook } + @Disabled @Test public void testResultSetMetadata() throws SQLException { String selectData = "SELECT * FROM " + DATASET + "." + TABLE_NAME + ";"; 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 52de5b390053..bc3a995d837a 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 @@ -16,13 +16,13 @@ package com.google.cloud.bigquery.jdbc.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.cloud.ServiceOptions; import java.sql.Connection; @@ -35,9 +35,10 @@ import java.sql.Statement; import java.util.Properties; import java.util.Random; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ITStatementTest { private static final String DEFAULT_CATALOG = ServiceOptions.getDefaultProjectId(); @@ -48,17 +49,18 @@ public class ITStatementTest { private static int randomNumber = random.nextInt(999); private static final String TABLE_NAME = "JDBC_STATEMENT_TEST_TABLE" + randomNumber; - @BeforeClass + @BeforeAll public static void beforeClass() throws InterruptedException { DATASET = ITBase.getSharedDataset(); ITBase.setUpTable(DATASET, TABLE_NAME); } - @AfterClass + @AfterAll public static void afterClass() throws InterruptedException { // Shared dataset cleanup is handled by shutdown hook } + @Disabled @Test public void testExecute() throws SQLException { Connection connection = @@ -351,6 +353,7 @@ public void testSetTimeout() throws SQLException { connection.close(); } + @Disabled @Test public void testSetTimeoutThrows() throws SQLException { Connection connection = diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/suites/ITPresubmitTests.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/suites/ITPresubmitTests.java index 90a569cc55cd..cdcece31a279 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/suites/ITPresubmitTests.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/suites/ITPresubmitTests.java @@ -24,6 +24,7 @@ import com.google.cloud.bigquery.jdbc.it.ITDatabaseMetadataTest; import com.google.cloud.bigquery.jdbc.it.ITDriverTest; import com.google.cloud.bigquery.jdbc.it.ITResultSetMetadataTest; +import com.google.cloud.bigquery.jdbc.it.ITStatementTest; import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; @@ -36,6 +37,7 @@ ITConnectionPoolingTest.class, ITDatabaseMetadataTest.class, ITDriverTest.class, - ITResultSetMetadataTest.class + ITResultSetMetadataTest.class, + ITStatementTest.class }) public class ITPresubmitTests {}