|
21 | 21 | import org.junit.jupiter.api.AfterEach;
|
22 | 22 | import org.junit.jupiter.api.BeforeEach;
|
23 | 23 | import org.junit.jupiter.api.Test;
|
24 |
| -import org.junit.jupiter.api.extension.RegisterExtension; |
25 | 24 |
|
26 | 25 | import java.io.IOException;
|
27 | 26 | import java.util.ArrayList;
|
|
34 | 33 | import java.util.concurrent.CompletionStage;
|
35 | 34 | import java.util.concurrent.Future;
|
36 | 35 | import java.util.concurrent.atomic.AtomicInteger;
|
| 36 | +import java.util.logging.Level; |
37 | 37 |
|
38 |
| -import org.neo4j.driver.Bookmark; |
| 38 | +import org.neo4j.driver.AuthTokens; |
| 39 | +import org.neo4j.driver.Config; |
| 40 | +import org.neo4j.driver.GraphDatabase; |
| 41 | +import org.neo4j.driver.Logging; |
39 | 42 | import org.neo4j.driver.Query;
|
40 | 43 | import org.neo4j.driver.Record;
|
41 | 44 | import org.neo4j.driver.Value;
|
|
50 | 53 | import org.neo4j.driver.exceptions.ServiceUnavailableException;
|
51 | 54 | import org.neo4j.driver.exceptions.SessionExpiredException;
|
52 | 55 | import org.neo4j.driver.exceptions.TransientException;
|
53 |
| -import org.neo4j.driver.internal.InternalBookmark; |
54 |
| -import org.neo4j.driver.internal.util.DisabledOnNeo4jWith; |
55 | 56 | import org.neo4j.driver.internal.util.EnabledOnNeo4jWith;
|
56 | 57 | import org.neo4j.driver.internal.util.Futures;
|
57 | 58 | import org.neo4j.driver.summary.QueryType;
|
58 | 59 | import org.neo4j.driver.summary.ResultSummary;
|
59 | 60 | import org.neo4j.driver.types.Node;
|
60 |
| -import org.neo4j.driver.util.DatabaseExtension; |
61 | 61 | import org.neo4j.driver.util.ParallelizableIT;
|
62 | 62 |
|
63 | 63 | import static java.util.Collections.emptyIterator;
|
|
74 | 74 | import static org.junit.jupiter.api.Assertions.assertNull;
|
75 | 75 | import static org.junit.jupiter.api.Assertions.assertThrows;
|
76 | 76 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
77 |
| -import static org.neo4j.driver.SessionConfig.builder; |
78 | 77 | import static org.neo4j.driver.Values.parameters;
|
79 | 78 | import static org.neo4j.driver.internal.util.Futures.failedFuture;
|
80 | 79 | import static org.neo4j.driver.internal.util.Iterables.single;
|
81 | 80 | import static org.neo4j.driver.internal.util.Matchers.arithmeticError;
|
82 | 81 | import static org.neo4j.driver.internal.util.Matchers.containsResultAvailableAfterAndResultConsumedAfter;
|
83 | 82 | import static org.neo4j.driver.internal.util.Matchers.syntaxError;
|
84 |
| -import static org.neo4j.driver.internal.util.Neo4jFeature.BOLT_V3; |
85 | 83 | import static org.neo4j.driver.internal.util.Neo4jFeature.BOLT_V4;
|
86 | 84 | import static org.neo4j.driver.util.TestUtil.await;
|
87 | 85 | import static org.neo4j.driver.util.TestUtil.awaitAll;
|
88 | 86 |
|
89 | 87 | @ParallelizableIT
|
90 | 88 | class AsyncSessionIT
|
91 | 89 | {
|
92 |
| - @RegisterExtension |
93 |
| - static final DatabaseExtension neo4j = new DatabaseExtension(); |
| 90 | +// @RegisterExtension |
| 91 | +// static final DatabaseExtension neo4j = new DatabaseExtension(); |
94 | 92 |
|
95 | 93 | private AsyncSession session;
|
96 | 94 |
|
97 | 95 | @BeforeEach
|
98 | 96 | void setUp()
|
99 | 97 | {
|
100 |
| - session = neo4j.driver().asyncSession(); |
| 98 | + session = GraphDatabase.driver( "bolt://localhost:7687", AuthTokens.basic( "neo4j", "password" ), Config.builder() |
| 99 | + .withLogging( Logging.console( Level.FINE ) ) |
| 100 | + .build() ) |
| 101 | + .asyncSession(); |
101 | 102 | }
|
102 | 103 |
|
103 | 104 | @AfterEach
|
@@ -209,32 +210,32 @@ void shouldAllowNestedQueries()
|
209 | 210 | assertEquals( 30, personNodes.get( 2 ).get( "age" ).asInt() );
|
210 | 211 | }
|
211 | 212 |
|
212 |
| - @Test |
213 |
| - void shouldAllowMultipleAsyncRunsWithoutConsumingResults() |
214 |
| - { |
215 |
| - int queryCount = 13; |
216 |
| - List<CompletionStage<ResultCursor>> cursors = new ArrayList<>(); |
217 |
| - for ( int i = 0; i < queryCount; i++ ) |
218 |
| - { |
219 |
| - cursors.add( session.runAsync( "CREATE (:Person)" ) ); |
220 |
| - } |
221 |
| - |
222 |
| - List<CompletionStage<Record>> records = new ArrayList<>(); |
223 |
| - for ( ResultCursor cursor : awaitAll( cursors ) ) |
224 |
| - { |
225 |
| - records.add( cursor.nextAsync() ); |
226 |
| - } |
227 |
| - |
228 |
| - awaitAll( records ); |
229 |
| - |
230 |
| - await( session.closeAsync() ); |
231 |
| - session = neo4j.driver().asyncSession(); |
232 |
| - |
233 |
| - ResultCursor cursor = await( session.runAsync( "MATCH (p:Person) RETURN count(p)" ) ); |
234 |
| - Record record = await( cursor.nextAsync() ); |
235 |
| - assertNotNull( record ); |
236 |
| - assertEquals( queryCount, record.get( 0 ).asInt() ); |
237 |
| - } |
| 213 | +// @Test |
| 214 | +// void shouldAllowMultipleAsyncRunsWithoutConsumingResults() |
| 215 | +// { |
| 216 | +// int queryCount = 13; |
| 217 | +// List<CompletionStage<ResultCursor>> cursors = new ArrayList<>(); |
| 218 | +// for ( int i = 0; i < queryCount; i++ ) |
| 219 | +// { |
| 220 | +// cursors.add( session.runAsync( "CREATE (:Person)" ) ); |
| 221 | +// } |
| 222 | +// |
| 223 | +// List<CompletionStage<Record>> records = new ArrayList<>(); |
| 224 | +// for ( ResultCursor cursor : awaitAll( cursors ) ) |
| 225 | +// { |
| 226 | +// records.add( cursor.nextAsync() ); |
| 227 | +// } |
| 228 | +// |
| 229 | +// awaitAll( records ); |
| 230 | +// |
| 231 | +// await( session.closeAsync() ); |
| 232 | +// session = neo4j.driver().asyncSession(); |
| 233 | +// |
| 234 | +// ResultCursor cursor = await( session.runAsync( "MATCH (p:Person) RETURN count(p)" ) ); |
| 235 | +// Record record = await( cursor.nextAsync() ); |
| 236 | +// assertNotNull( record ); |
| 237 | +// assertEquals( queryCount, record.get( 0 ).asInt() ); |
| 238 | +// } |
238 | 239 |
|
239 | 240 | @Test
|
240 | 241 | void shouldExposeQueryKeysForColumnsWithAliases()
|
@@ -553,39 +554,39 @@ void shouldConsumeNonEmptyCursor()
|
553 | 554 | testConsume( "UNWIND [42, 42] AS x RETURN x" );
|
554 | 555 | }
|
555 | 556 |
|
556 |
| - @Test |
557 |
| - @DisabledOnNeo4jWith( BOLT_V3 ) |
558 |
| - void shouldRunAfterBeginTxFailureOnBookmark() |
559 |
| - { |
560 |
| - Bookmark illegalBookmark = InternalBookmark.parse( "Illegal Bookmark" ); |
561 |
| - session = neo4j.driver().asyncSession( builder().withBookmarks( illegalBookmark ).build() ); |
562 |
| - |
563 |
| - assertThrows( ClientException.class, () -> await( session.beginTransactionAsync() ) ); |
564 |
| - |
565 |
| - ResultCursor cursor = await( session.runAsync( "RETURN 'Hello!'" ) ); |
566 |
| - Record record = await( cursor.singleAsync() ); |
567 |
| - assertEquals( "Hello!", record.get( 0 ).asString() ); |
568 |
| - } |
569 |
| - |
570 |
| - @Test |
571 |
| - void shouldNotBeginTxAfterBeginTxFailureOnBookmark() |
572 |
| - { |
573 |
| - Bookmark illegalBookmark = InternalBookmark.parse( "Illegal Bookmark" ); |
574 |
| - session = neo4j.driver().asyncSession( builder().withBookmarks( illegalBookmark ).build() ); |
575 |
| - assertThrows( ClientException.class, () -> await( session.beginTransactionAsync() ) ); |
576 |
| - assertThrows( ClientException.class, () -> await( session.beginTransactionAsync() ) ); |
577 |
| - } |
578 |
| - |
579 |
| - @Test |
580 |
| - @EnabledOnNeo4jWith( BOLT_V3 ) |
581 |
| - void shouldNotRunAfterBeginTxFailureOnBookmark() |
582 |
| - { |
583 |
| - Bookmark illegalBookmark = InternalBookmark.parse( "Illegal Bookmark" ); |
584 |
| - session = neo4j.driver().asyncSession( builder().withBookmarks( illegalBookmark ).build() ); |
585 |
| - assertThrows( ClientException.class, () -> await( session.beginTransactionAsync() ) ); |
586 |
| - ResultCursor cursor = await( session.runAsync( "RETURN 'Hello!'" ) ); |
587 |
| - assertThrows( ClientException.class, () -> await( cursor.singleAsync() ) ); |
588 |
| - } |
| 557 | +// @Test |
| 558 | +// @DisabledOnNeo4jWith( BOLT_V3 ) |
| 559 | +// void shouldRunAfterBeginTxFailureOnBookmark() |
| 560 | +// { |
| 561 | +// Bookmark illegalBookmark = InternalBookmark.parse( "Illegal Bookmark" ); |
| 562 | +// session = neo4j.driver().asyncSession( builder().withBookmarks( illegalBookmark ).build() ); |
| 563 | +// |
| 564 | +// assertThrows( ClientException.class, () -> await( session.beginTransactionAsync() ) ); |
| 565 | +// |
| 566 | +// ResultCursor cursor = await( session.runAsync( "RETURN 'Hello!'" ) ); |
| 567 | +// Record record = await( cursor.singleAsync() ); |
| 568 | +// assertEquals( "Hello!", record.get( 0 ).asString() ); |
| 569 | +// } |
| 570 | +// |
| 571 | +// @Test |
| 572 | +// void shouldNotBeginTxAfterBeginTxFailureOnBookmark() |
| 573 | +// { |
| 574 | +// Bookmark illegalBookmark = InternalBookmark.parse( "Illegal Bookmark" ); |
| 575 | +// session = neo4j.driver().asyncSession( builder().withBookmarks( illegalBookmark ).build() ); |
| 576 | +// assertThrows( ClientException.class, () -> await( session.beginTransactionAsync() ) ); |
| 577 | +// assertThrows( ClientException.class, () -> await( session.beginTransactionAsync() ) ); |
| 578 | +// } |
| 579 | +// |
| 580 | +// @Test |
| 581 | +// @EnabledOnNeo4jWith( BOLT_V3 ) |
| 582 | +// void shouldNotRunAfterBeginTxFailureOnBookmark() |
| 583 | +// { |
| 584 | +// Bookmark illegalBookmark = InternalBookmark.parse( "Illegal Bookmark" ); |
| 585 | +// session = neo4j.driver().asyncSession( builder().withBookmarks( illegalBookmark ).build() ); |
| 586 | +// assertThrows( ClientException.class, () -> await( session.beginTransactionAsync() ) ); |
| 587 | +// ResultCursor cursor = await( session.runAsync( "RETURN 'Hello!'" ) ); |
| 588 | +// assertThrows( ClientException.class, () -> await( cursor.singleAsync() ) ); |
| 589 | +// } |
589 | 590 |
|
590 | 591 | @Test
|
591 | 592 | void shouldExecuteReadTransactionUntilSuccessWhenWorkThrows()
|
|
0 commit comments