|
29 | 29 | import java.net.URI;
|
30 | 30 | import java.util.ArrayList;
|
31 | 31 | import java.util.List;
|
32 |
| -import java.util.function.Consumer; |
33 | 32 |
|
34 | 33 | import org.neo4j.driver.AccessMode;
|
35 | 34 | import org.neo4j.driver.AuthTokens;
|
36 |
| -import org.neo4j.driver.Bookmark; |
37 | 35 | import org.neo4j.driver.Config;
|
38 | 36 | import org.neo4j.driver.Driver;
|
39 | 37 | import org.neo4j.driver.GraphDatabase;
|
40 | 38 | import org.neo4j.driver.Result;
|
41 | 39 | import org.neo4j.driver.Session;
|
42 |
| -import org.neo4j.driver.Transaction; |
43 | 40 | import org.neo4j.driver.async.AsyncSession;
|
44 | 41 | import org.neo4j.driver.async.ResultCursor;
|
45 |
| -import org.neo4j.driver.exceptions.TransientException; |
46 | 42 | import org.neo4j.driver.internal.cluster.RoutingSettings;
|
47 | 43 | import org.neo4j.driver.internal.retry.RetrySettings;
|
48 | 44 | import org.neo4j.driver.internal.security.SecurityPlanImpl;
|
|
56 | 52 | import static java.util.Arrays.asList;
|
57 | 53 | import static java.util.Collections.singletonList;
|
58 | 54 | import static java.util.concurrent.TimeUnit.SECONDS;
|
59 |
| -import static org.hamcrest.core.IsEqual.equalTo; |
60 |
| -import static org.hamcrest.junit.MatcherAssert.assertThat; |
61 | 55 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
62 |
| -import static org.junit.jupiter.api.Assertions.assertFalse; |
63 | 56 | import static org.junit.jupiter.api.Assertions.assertNull;
|
64 |
| -import static org.junit.jupiter.api.Assertions.assertThrows; |
65 |
| -import static org.junit.jupiter.api.Assertions.assertTrue; |
66 | 57 | import static org.neo4j.driver.SessionConfig.builder;
|
67 | 58 | import static org.neo4j.driver.SessionConfig.forDatabase;
|
68 | 59 | import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
|
69 | 60 | import static org.neo4j.driver.util.StubServer.INSECURE_CONFIG;
|
70 |
| -import static org.neo4j.driver.util.StubServer.insecureBuilder; |
71 | 61 | import static org.neo4j.driver.util.TestUtil.await;
|
72 | 62 |
|
73 | 63 | class DirectDriverBoltKitIT
|
@@ -206,76 +196,6 @@ void shouldPullAllRecordsOnListAsyncWhenOverWatermark() throws Exception
|
206 | 196 | }
|
207 | 197 | }
|
208 | 198 |
|
209 |
| - @Test |
210 |
| - void shouldAllowPullAll() throws Exception |
211 |
| - { |
212 |
| - StubServer server = stubController.startStub( "streaming_records_v4_all.script", 9001 ); |
213 |
| - try |
214 |
| - { |
215 |
| - try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", insecureBuilder().withFetchSize( -1 ).build() ) ) |
216 |
| - { |
217 |
| - Session session = driver.session(); |
218 |
| - Result result = session.run( "MATCH (n) RETURN n.name" ); |
219 |
| - List<String> list = result.list( record -> record.get( "n.name" ).asString() ); |
220 |
| - assertEquals( list, asList( "Bob", "Alice", "Tina" ) ); |
221 |
| - } |
222 |
| - } |
223 |
| - finally |
224 |
| - { |
225 |
| - assertEquals( 0, server.exitStatus() ); |
226 |
| - } |
227 |
| - } |
228 |
| - |
229 |
| - @Test |
230 |
| - void shouldThrowCommitErrorWhenTransactionCommit() throws Exception |
231 |
| - { |
232 |
| - testTxCloseErrorPropagation( "commit_error.script", Transaction::commit, "Unable to commit" ); |
233 |
| - } |
234 |
| - |
235 |
| - @Test |
236 |
| - void shouldThrowCorrectErrorOnRunFailure() throws Throwable |
237 |
| - { |
238 |
| - StubServer server = stubController.startStub( "database_shutdown.script", 9001 ); |
239 |
| - |
240 |
| - Bookmark bookmark = InternalBookmark.parse( "neo4j:bookmark:v1:tx0" ); |
241 |
| - try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ); |
242 |
| - Session session = driver.session( builder().withBookmarks( bookmark ).build() ); |
243 |
| - // has to enforce to flush BEGIN to have tx started. |
244 |
| - Transaction transaction = session.beginTransaction() ) |
245 |
| - { |
246 |
| - TransientException error = assertThrows( TransientException.class, () -> { |
247 |
| - Result result = transaction.run( "RETURN 1" ); |
248 |
| - result.consume(); |
249 |
| - } ); |
250 |
| - assertThat( error.code(), equalTo( "Neo.TransientError.General.DatabaseUnavailable" ) ); |
251 |
| - } |
252 |
| - finally |
253 |
| - { |
254 |
| - assertEquals( 0, server.exitStatus() ); |
255 |
| - } |
256 |
| - } |
257 |
| - |
258 |
| - @Test |
259 |
| - void shouldThrowCorrectErrorOnCommitFailure() throws Throwable |
260 |
| - { |
261 |
| - StubServer server = stubController.startStub( "database_shutdown_at_commit.script", 9001 ); |
262 |
| - |
263 |
| - try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ); |
264 |
| - Session session = driver.session() ) |
265 |
| - { |
266 |
| - Transaction transaction = session.beginTransaction(); |
267 |
| - Result result = transaction.run( "CREATE (n {name:'Bob'})" ); |
268 |
| - result.consume(); |
269 |
| - |
270 |
| - TransientException error = assertThrows( TransientException.class, transaction::commit ); |
271 |
| - assertThat( error.code(), equalTo( "Neo.TransientError.General.DatabaseUnavailable" ) ); |
272 |
| - } |
273 |
| - finally |
274 |
| - { |
275 |
| - assertEquals( 0, server.exitStatus() ); |
276 |
| - } |
277 |
| - } |
278 |
| - |
279 | 199 | @Test
|
280 | 200 | void shouldAllowDatabaseNameInSessionRun() throws Throwable
|
281 | 201 | {
|
@@ -327,75 +247,4 @@ void shouldDiscardIfPullNotFinished() throws Throwable
|
327 | 247 | assertEquals( 0, server.exitStatus() );
|
328 | 248 | }
|
329 | 249 | }
|
330 |
| - |
331 |
| - @Test |
332 |
| - void shouldServerWithBoltV4SupportMultiDb() throws Throwable |
333 |
| - { |
334 |
| - StubServer server = stubController.startStub( "support_multidb_v4.script", 9001 ); |
335 |
| - try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ) ) |
336 |
| - { |
337 |
| - assertTrue( driver.supportsMultiDb() ); |
338 |
| - } |
339 |
| - finally |
340 |
| - { |
341 |
| - assertEquals( 0, server.exitStatus() ); |
342 |
| - } |
343 |
| - } |
344 |
| - |
345 |
| - @Test |
346 |
| - void shouldServerWithBoltV3NotSupportMultiDb() throws Throwable |
347 |
| - { |
348 |
| - StubServer server = stubController.startStub( "support_multidb_v3.script", 9001 ); |
349 |
| - try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ) ) |
350 |
| - { |
351 |
| - assertFalse( driver.supportsMultiDb() ); |
352 |
| - } |
353 |
| - finally |
354 |
| - { |
355 |
| - assertEquals( 0, server.exitStatus() ); |
356 |
| - } |
357 |
| - } |
358 |
| - |
359 |
| - @Test |
360 |
| - void shouldBeAbleHandleNOOPsDuringRunCypher() throws Exception |
361 |
| - { |
362 |
| - StubServer server = stubController.startStub( "noop.script", 9001 ); |
363 |
| - URI uri = URI.create( "bolt://127.0.0.1:9001" ); |
364 |
| - |
365 |
| - try ( Driver driver = GraphDatabase.driver( uri, INSECURE_CONFIG ) ) |
366 |
| - { |
367 |
| - try ( Session session = driver.session() ) |
368 |
| - { |
369 |
| - List<String> names = session.run( "MATCH (n) RETURN n.name" ).list( rec -> rec.get( 0 ).asString() ); |
370 |
| - assertEquals( asList( "Foo", "Bar", "Baz" ), names ); |
371 |
| - } |
372 |
| - } |
373 |
| - |
374 |
| - assertThat( server.exitStatus(), equalTo( 0 ) ); |
375 |
| - } |
376 |
| - |
377 |
| - private static void testTxCloseErrorPropagation( String script, Consumer<Transaction> txAction, String expectedErrorMessage ) |
378 |
| - throws Exception |
379 |
| - { |
380 |
| - StubServer server = stubController.startStub( script, 9001 ); |
381 |
| - try |
382 |
| - { |
383 |
| - try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ); |
384 |
| - Session session = driver.session() ) |
385 |
| - { |
386 |
| - Transaction tx = session.beginTransaction(); |
387 |
| - Result result = tx.run( "CREATE (n {name:'Alice'}) RETURN n.name AS name" ); |
388 |
| - assertEquals( "Alice", result.single().get( "name" ).asString() ); |
389 |
| - |
390 |
| - TransientException e = assertThrows( TransientException.class, () -> txAction.accept( tx ) ); |
391 |
| - |
392 |
| - assertEquals( "Neo.TransientError.General.DatabaseUnavailable", e.code() ); |
393 |
| - assertEquals( expectedErrorMessage, e.getMessage() ); |
394 |
| - } |
395 |
| - } |
396 |
| - finally |
397 |
| - { |
398 |
| - assertEquals( 0, server.exitStatus() ); |
399 |
| - } |
400 |
| - } |
401 | 250 | }
|
0 commit comments