|
16 | 16 |
|
17 | 17 | package com.google.cloud.bigquery.jdbc.it; |
18 | 18 |
|
| 19 | +import static com.google.common.truth.Truth.assertThat; |
19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; |
20 | 21 | import static org.junit.jupiter.api.Assertions.assertFalse; |
21 | 22 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
|
48 | 49 | import org.junit.jupiter.api.Disabled; |
49 | 50 | import org.junit.jupiter.api.Test; |
50 | 51 |
|
51 | | -public class ITStatementTest { |
| 52 | +public class ITStatementTest extends ITBase { |
52 | 53 | private static final String DEFAULT_CATALOG = ServiceOptions.getDefaultProjectId(); |
53 | 54 | private static String DATASET; |
54 | 55 | private static Random random = new Random(); |
@@ -122,7 +123,7 @@ public void testExecuteQuery() throws SQLException { |
122 | 123 | // setMaxRows Test |
123 | 124 | statement.setMaxRows(5); |
124 | 125 | ResultSet maxRowsResultSet = statement.executeQuery(selectQuery); |
125 | | - assertEquals(5, getSizeOfResultSet(maxRowsResultSet)); |
| 126 | + assertEquals(5, resultSetRowCount(maxRowsResultSet)); |
126 | 127 |
|
127 | 128 | try { |
128 | 129 | statement.setMaxRows(0); |
@@ -244,14 +245,6 @@ public void testScript() throws SQLException { |
244 | 245 | connection.close(); |
245 | 246 | } |
246 | 247 |
|
247 | | - private int resultSetRowCount(ResultSet resultSet) throws SQLException { |
248 | | - int rowCount = 0; |
249 | | - while (resultSet.next()) { |
250 | | - rowCount++; |
251 | | - } |
252 | | - return rowCount; |
253 | | - } |
254 | | - |
255 | 248 | @Test |
256 | 249 | public void testStringColumnLength() throws SQLException { |
257 | 250 | String TABLE_NAME = "StringColumnLengthTable"; |
@@ -323,18 +316,13 @@ public void testSetTimeout() throws SQLException { |
323 | 316 | Connection connection = DriverManager.getConnection(ITBase.connectionUrl); |
324 | 317 | Statement statement = connection.createStatement(); |
325 | 318 |
|
326 | | - String selectQuery = |
327 | | - "SELECT views FROM bigquery-public-data.wikipedia.pageviews_2020 WHERE datehour >=" |
328 | | - + " '2020-01-01' LIMIT 9000000"; |
329 | | - |
330 | 319 | // statement.execute(selectQuery); |
331 | 320 | assertEquals(0, statement.getQueryTimeout()); |
332 | 321 | statement.setQueryTimeout(1); |
333 | 322 | assertEquals(1, statement.getQueryTimeout()); |
334 | | - SQLException e = assertThrows(SQLException.class, () -> statement.executeQuery(selectQuery)); |
335 | | - assertEquals( |
336 | | - "BigQueryException during runQuery\nJob execution was cancelled: Job timed out", |
337 | | - e.getMessage()); |
| 323 | + SQLException e = |
| 324 | + assertThrows(SQLException.class, () -> statement.executeQuery(ITBase.query300seconds)); |
| 325 | + assertThat(e.getMessage()).contains("Job execution was cancelled: Job timed out"); |
338 | 326 | statement.close(); |
339 | 327 | connection.close(); |
340 | 328 | } |
@@ -388,14 +376,6 @@ public void testRangeSelectDataset() throws SQLException { |
388 | 376 | connection.close(); |
389 | 377 | } |
390 | 378 |
|
391 | | - int getSizeOfResultSet(ResultSet resultSet) throws SQLException { |
392 | | - int count = 0; |
393 | | - while (resultSet.next()) { |
394 | | - count++; |
395 | | - } |
396 | | - return count; |
397 | | - } |
398 | | - |
399 | 379 | @Test |
400 | 380 | public void testTemporaryDatasetLocation() throws SQLException, InterruptedException { |
401 | 381 | String projectId = DEFAULT_CATALOG; |
|
0 commit comments