Skip to content

Commit e57e38d

Browse files
author
Zhen Li
committed
Improve TransactionIT#shouldRollBackTxIfErrorWithoutConsume()
1 parent 2ad0d97 commit e57e38d

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

driver/src/test/java/org/neo4j/driver/v1/integration/TransactionIT.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,28 +310,27 @@ public void run()
310310
public void shouldRollBackTxIfErrorWithoutConsume() throws Throwable
311311
{
312312
// Given
313-
int failingPos = 0;
314-
try ( Transaction tx = session.beginTransaction() )
313+
Transaction tx = session.beginTransaction();
314+
tx.run( "invalid" ); // send run, pull_all
315+
tx.success();
316+
try
315317
{
316-
StatementResult result = tx.run( "invalid" ); // send run, pull_all
317-
tx.success();
318-
failingPos = 1; // fail to send?
318+
tx.close();
319+
fail("should fail tx in tx.close()");
319320
} // When send run_commit, and pull_all
320321

321322
// Then error and should also send ack_fail, roll_back and pull_all
322323
catch ( ClientException e )
323324
{
324-
failingPos = 2; // fail in tx.close in sync?
325-
try ( Transaction tx = session.beginTransaction() )
325+
try ( Transaction anotherTx = session.beginTransaction() )
326326
{
327-
StatementResult cursor = tx.run( "RETURN 1" );
327+
StatementResult cursor = anotherTx.run( "RETURN 1" );
328328
int val = cursor.single().get( "1" ).asInt();
329329

330330

331331
assertThat( val, equalTo( 1 ) );
332332
}
333333
}
334-
assertThat( failingPos, equalTo( 2 ) );
335334
}
336335

337336
@Test

0 commit comments

Comments
 (0)