|
43 | 43 | import static org.neo4j.driver.testutil.TestUtil.await;
|
44 | 44 | import static org.neo4j.driver.testutil.TestUtil.beginMessage;
|
45 | 45 | import static org.neo4j.driver.testutil.TestUtil.connectionMock;
|
| 46 | +import static org.neo4j.driver.testutil.TestUtil.setupFailingRun; |
46 | 47 | import static org.neo4j.driver.testutil.TestUtil.setupSuccessfulRunAndPull;
|
47 | 48 | import static org.neo4j.driver.testutil.TestUtil.setupSuccessfulRunRx;
|
48 | 49 | import static org.neo4j.driver.testutil.TestUtil.verifyBeginTx;
|
|
69 | 70 | import org.neo4j.driver.exceptions.AuthorizationExpiredException;
|
70 | 71 | import org.neo4j.driver.exceptions.ClientException;
|
71 | 72 | import org.neo4j.driver.exceptions.ConnectionReadTimeoutException;
|
| 73 | +import org.neo4j.driver.exceptions.Neo4jException; |
72 | 74 | import org.neo4j.driver.internal.FailableCursor;
|
73 | 75 | import org.neo4j.driver.internal.InternalBookmark;
|
74 | 76 | import org.neo4j.driver.internal.messaging.BoltProtocol;
|
@@ -456,6 +458,27 @@ void shouldServeTheSameStageOnInterruptAsync() {
|
456 | 458 | assertEquals(stage0, stage1);
|
457 | 459 | }
|
458 | 460 |
|
| 461 | + @Test |
| 462 | + void shouldHandleInterruptionWhenAlreadyInterrupted() throws ExecutionException, InterruptedException { |
| 463 | + // Given |
| 464 | + var connection = connectionMock(BoltProtocolV4.INSTANCE); |
| 465 | + var exception = new Neo4jException("message"); |
| 466 | + setupFailingRun(connection, exception); |
| 467 | + var tx = beginTx(connection); |
| 468 | + Throwable actualException = null; |
| 469 | + |
| 470 | + // When |
| 471 | + try { |
| 472 | + tx.runAsync(new Query("RETURN 1")).toCompletableFuture().get(); |
| 473 | + } catch (ExecutionException e) { |
| 474 | + actualException = e.getCause(); |
| 475 | + } |
| 476 | + tx.interruptAsync().toCompletableFuture().get(); |
| 477 | + |
| 478 | + // Then |
| 479 | + assertEquals(exception, actualException); |
| 480 | + } |
| 481 | + |
459 | 482 | private static UnmanagedTransaction beginTx(Connection connection) {
|
460 | 483 | return beginTx(connection, Collections.emptySet());
|
461 | 484 | }
|
|
0 commit comments