|
32 | 32 | import java.util.Set;
|
33 | 33 | import java.util.UUID;
|
34 | 34 |
|
35 |
| -import org.neo4j.driver.internal.util.ServerVersion; |
36 | 35 | import org.neo4j.driver.Session;
|
37 | 36 | import org.neo4j.driver.Value;
|
| 37 | +import org.neo4j.driver.internal.util.ServerVersion; |
38 | 38 | import org.neo4j.driver.summary.ResultSummary;
|
39 | 39 | import org.neo4j.driver.summary.StatementType;
|
40 | 40 | import org.neo4j.driver.util.DatabaseExtension;
|
|
45 | 45 | import static java.nio.charset.StandardCharsets.UTF_8;
|
46 | 46 | import static java.util.Arrays.asList;
|
47 | 47 | import static org.hamcrest.Matchers.containsString;
|
| 48 | +import static org.hamcrest.Matchers.emptyString; |
48 | 49 | import static org.hamcrest.Matchers.equalTo;
|
49 | 50 | import static org.hamcrest.Matchers.greaterThan;
|
50 | 51 | import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
@@ -459,20 +460,29 @@ void testSlf4jLogging() throws Exception
|
459 | 460 | {
|
460 | 461 | // log file is defined in logback-test.xml configuration file
|
461 | 462 | Path logFile = Paths.get( "target", "test.log" );
|
462 |
| - Files.deleteIfExists( logFile ); |
| 463 | + if ( Files.exists( logFile ) ) |
| 464 | + { |
| 465 | + // delete file made this test flaky |
| 466 | + // erase content instead |
| 467 | + Files.write( logFile, new byte[0] ); |
| 468 | + } |
463 | 469 |
|
| 470 | + // verify erased |
| 471 | + String logFileContent = new String( Files.readAllBytes( logFile ), UTF_8 ); |
| 472 | + assertThat( logFileContent, is( emptyString() ) ); |
| 473 | + |
| 474 | + String randomString = UUID.randomUUID().toString(); |
464 | 475 | try ( Slf4jLoggingExample example = new Slf4jLoggingExample( uri, USER, PASSWORD ) )
|
465 | 476 | {
|
466 |
| - String randomString = UUID.randomUUID().toString(); |
467 | 477 | Object result = example.runReturnQuery( randomString );
|
468 | 478 | assertEquals( randomString, result );
|
| 479 | + } |
| 480 | + assertTrue( Files.exists( logFile ) ); |
469 | 481 |
|
470 |
| - assertTrue( Files.exists( logFile ) ); |
| 482 | + logFileContent = new String( Files.readAllBytes( logFile ), UTF_8 ); |
| 483 | + assertThat( logFileContent, containsString( "RETURN $x" ) ); |
| 484 | + assertThat( logFileContent, containsString( randomString ) ); |
471 | 485 |
|
472 |
| - String logFileContent = new String( Files.readAllBytes( logFile ), UTF_8 ); |
473 |
| - assertThat( logFileContent, containsString( "RETURN $x" ) ); |
474 |
| - assertThat( logFileContent, containsString( randomString ) ); |
475 |
| - } |
476 | 486 | }
|
477 | 487 |
|
478 | 488 | @Test
|
|
0 commit comments