|
31 | 31 | import com.google.cloud.spanner.SpannerException; |
32 | 32 | import com.google.cloud.spanner.Statement; |
33 | 33 | import com.google.cloud.spanner.connection.ITAbstractSpannerTest.ITConnection; |
| 34 | +import com.google.cloud.spanner.connection.StatementResult.ResultType; |
34 | 35 | import com.google.spanner.v1.BeginTransactionRequest; |
35 | 36 | import com.google.spanner.v1.CommitRequest; |
36 | 37 | import com.google.spanner.v1.ExecuteBatchDmlRequest; |
@@ -357,5 +358,45 @@ public long nanoTime() { |
357 | 358 | } |
358 | 359 |
|
359 | 360 | @Test |
360 | | - public void testTransactionTimeoutInAutoCommit() {} |
| 361 | + public void testCanUseAllMethodsWithInternalRetriesDisabled() { |
| 362 | + // Verify that all query/update methods work as expected when internal retries have been |
| 363 | + // disabled. |
| 364 | + try (Connection connection = createConnection()) { |
| 365 | + connection.setAutocommit(false); |
| 366 | + connection.setRetryAbortsInternally(false); |
| 367 | + |
| 368 | + try (ResultSet result = connection.executeQuery(SELECT1_STATEMENT)) { |
| 369 | + assertTrue(result.next()); |
| 370 | + assertEquals(1L, result.getLong(0)); |
| 371 | + assertFalse(result.next()); |
| 372 | + } |
| 373 | + assertEquals(1, connection.executeUpdate(INSERT_STATEMENT)); |
| 374 | + try (ResultSet result = connection.executeQuery(INSERT_RETURNING_STATEMENT)) { |
| 375 | + assertTrue(result.next()); |
| 376 | + assertEquals(1L, result.getLong(0)); |
| 377 | + assertFalse(result.next()); |
| 378 | + } |
| 379 | + |
| 380 | + StatementResult statementResult = connection.execute(SELECT1_STATEMENT); |
| 381 | + assertEquals(ResultType.RESULT_SET, statementResult.getResultType()); |
| 382 | + try (ResultSet result = statementResult.getResultSet()) { |
| 383 | + assertTrue(result.next()); |
| 384 | + assertEquals(1L, result.getLong(0)); |
| 385 | + assertFalse(result.next()); |
| 386 | + } |
| 387 | + |
| 388 | + statementResult = connection.execute(INSERT_STATEMENT); |
| 389 | + assertEquals(ResultType.UPDATE_COUNT, statementResult.getResultType()); |
| 390 | + assertEquals(1L, statementResult.getUpdateCount().longValue()); |
| 391 | + |
| 392 | + statementResult = connection.execute(INSERT_RETURNING_STATEMENT); |
| 393 | + assertEquals(ResultType.RESULT_SET, statementResult.getResultType()); |
| 394 | + try (ResultSet result = statementResult.getResultSet()) { |
| 395 | + assertTrue(result.next()); |
| 396 | + assertEquals(1L, result.getLong(0)); |
| 397 | + assertFalse(result.next()); |
| 398 | + } |
| 399 | + connection.commit(); |
| 400 | + } |
| 401 | + } |
361 | 402 | } |
0 commit comments