|
26 | 26 | import java.util.Map;
|
27 | 27 | import java.util.concurrent.CompletionStage;
|
28 | 28 |
|
| 29 | +import org.neo4j.driver.internal.logging.DevNullLogging; |
29 | 30 | import org.neo4j.driver.internal.util.EnabledOnNeo4jWith;
|
| 31 | +import org.neo4j.driver.v1.AuthTokens; |
| 32 | +import org.neo4j.driver.v1.Config; |
| 33 | +import org.neo4j.driver.v1.Driver; |
| 34 | +import org.neo4j.driver.v1.GraphDatabase; |
30 | 35 | import org.neo4j.driver.v1.Session;
|
31 | 36 | import org.neo4j.driver.v1.StatementResult;
|
32 | 37 | import org.neo4j.driver.v1.StatementResultCursor;
|
|
35 | 40 | import org.neo4j.driver.v1.exceptions.TransientException;
|
36 | 41 | import org.neo4j.driver.v1.summary.ResultSummary;
|
37 | 42 | import org.neo4j.driver.v1.util.SessionExtension;
|
| 43 | +import org.neo4j.driver.v1.util.StubServer; |
38 | 44 |
|
39 | 45 | import static java.time.Duration.ofMillis;
|
40 | 46 | import static java.util.Arrays.asList;
|
| 47 | +import static java.util.Collections.singletonMap; |
41 | 48 | import static org.hamcrest.MatcherAssert.assertThat;
|
42 | 49 | import static org.hamcrest.Matchers.containsString;
|
43 | 50 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
@@ -249,6 +256,26 @@ void shouldUseBookmarksForAutoCommitTransactionsAndTransactionFunctions()
|
249 | 256 | assertNotEquals( bookmark2, bookmark3 );
|
250 | 257 | }
|
251 | 258 |
|
| 259 | + @Test |
| 260 | + void shouldSendGoodbyeWhenClosingDriver() throws Throwable |
| 261 | + { |
| 262 | + StubServer server = StubServer.start( "goodbye_message.script", 9001 ); |
| 263 | + try |
| 264 | + { |
| 265 | + Config config = Config.build().withLogging( DevNullLogging.DEV_NULL_LOGGING ).withoutEncryption().toConfig(); |
| 266 | + try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", AuthTokens.none(), config ); Session session = driver.session() ) |
| 267 | + { |
| 268 | + StatementResult result = |
| 269 | + session.run( "RETURN $x", singletonMap( "x", 1 ), TransactionConfig.builder().withMetadata( singletonMap( "mode", "r" ) ).build() ); |
| 270 | + assertEquals( 1, result.single().get( "x" ).asInt() ); |
| 271 | + } |
| 272 | + } |
| 273 | + finally |
| 274 | + { |
| 275 | + assertEquals( 0, server.exitStatus() ); |
| 276 | + } |
| 277 | + } |
| 278 | + |
252 | 279 | private static void testTransactionMetadataWithTransactionFunctions( boolean read )
|
253 | 280 | {
|
254 | 281 | Map<String,Object> metadata = new HashMap<>();
|
|
0 commit comments