|
48 | 48 | import org.neo4j.driver.Record;
|
49 | 49 | import org.neo4j.driver.Result;
|
50 | 50 | import org.neo4j.driver.Session;
|
51 |
| -import org.neo4j.driver.Transaction; |
52 |
| -import org.neo4j.driver.Values; |
53 | 51 | import org.neo4j.driver.async.AsyncSession;
|
54 | 52 | import org.neo4j.driver.async.ResultCursor;
|
55 | 53 | import org.neo4j.driver.exceptions.ClientException;
|
|
70 | 68 | import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
71 | 69 | import static java.util.concurrent.TimeUnit.MINUTES;
|
72 | 70 | import static java.util.concurrent.TimeUnit.SECONDS;
|
73 |
| -import static org.hamcrest.Matchers.containsString; |
74 | 71 | import static org.hamcrest.Matchers.greaterThan;
|
75 | 72 | import static org.hamcrest.Matchers.is;
|
76 | 73 | import static org.hamcrest.junit.MatcherAssert.assertThat;
|
|
84 | 81 | import static org.neo4j.driver.Logging.none;
|
85 | 82 | import static org.neo4j.driver.SessionConfig.builder;
|
86 | 83 | import static org.neo4j.driver.Values.parameters;
|
87 |
| -import static org.neo4j.driver.internal.InternalBookmark.parse; |
88 | 84 | import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
|
89 | 85 | import static org.neo4j.driver.internal.util.Matchers.connectionAcquisitionTimeoutError;
|
90 | 86 | import static org.neo4j.driver.util.DaemonThreadFactory.daemon;
|
@@ -158,97 +154,6 @@ void shouldExecuteReadAndWritesWhenDriverSuppliedWithAddressOfFollower() throws
|
158 | 154 | assertEquals( 1, count );
|
159 | 155 | }
|
160 | 156 |
|
161 |
| - @Test |
162 |
| - void sessionCreationShouldFailIfCallingDiscoveryProcedureOnEdgeServer() |
163 |
| - { |
164 |
| - assertRoutingNotAvailableOnReadReplica(); |
165 |
| - Cluster cluster = clusterRule.getCluster(); |
166 |
| - |
167 |
| - ClusterMember readReplica = cluster.anyReadReplica(); |
168 |
| - final Driver driver = createDriver( readReplica.getRoutingUri() ); |
169 |
| - ServiceUnavailableException e = assertThrows( ServiceUnavailableException.class, driver::verifyConnectivity ); |
170 |
| - assertThat( e.getMessage(), containsString( "Unable to connect to database" ) ); |
171 |
| - } |
172 |
| - |
173 |
| - // Ensure that Bookmarks work with single instances using a driver created using a bolt[not+routing] URI. |
174 |
| - @Test |
175 |
| - void bookmarksShouldWorkWithDriverPinnedToSingleServer() throws Exception |
176 |
| - { |
177 |
| - Cluster cluster = clusterRule.getCluster(); |
178 |
| - ClusterMember leader = cluster.leader(); |
179 |
| - |
180 |
| - try ( Driver driver = createDriver( leader.getBoltUri() ) ) |
181 |
| - { |
182 |
| - Bookmark bookmark = inExpirableSession( driver, Driver::session, session -> |
183 |
| - { |
184 |
| - try ( Transaction tx = session.beginTransaction() ) |
185 |
| - { |
186 |
| - tx.run( "CREATE (p:Person {name: $name })", Values.parameters( "name", "Alistair" ) ); |
187 |
| - tx.commit(); |
188 |
| - } |
189 |
| - |
190 |
| - return session.lastBookmark(); |
191 |
| - } ); |
192 |
| - |
193 |
| - assertNotNull( bookmark ); |
194 |
| - |
195 |
| - try ( Session session = driver.session( builder().withBookmarks( bookmark ).build() ); |
196 |
| - Transaction tx = session.beginTransaction() ) |
197 |
| - { |
198 |
| - Record record = tx.run( "MATCH (n:Person) RETURN COUNT(*) AS count" ).next(); |
199 |
| - assertEquals( 1, record.get( "count" ).asInt() ); |
200 |
| - tx.commit(); |
201 |
| - } |
202 |
| - } |
203 |
| - } |
204 |
| - |
205 |
| - @Test |
206 |
| - void shouldUseBookmarkFromAReadSessionInAWriteSession() throws Exception |
207 |
| - { |
208 |
| - Cluster cluster = clusterRule.getCluster(); |
209 |
| - ClusterMember leader = cluster.leader(); |
210 |
| - |
211 |
| - try ( Driver driver = createDriver( leader.getBoltUri() ) ) |
212 |
| - { |
213 |
| - inExpirableSession( driver, createWritableSession( null ), session -> |
214 |
| - { |
215 |
| - session.run( "CREATE (p:Person {name: $name })", Values.parameters( "name", "Jim" ) ); |
216 |
| - return null; |
217 |
| - } ); |
218 |
| - |
219 |
| - final Bookmark bookmark; |
220 |
| - try ( Session session = driver.session( builder().withDefaultAccessMode( AccessMode.READ ).build() ) ) |
221 |
| - { |
222 |
| - try ( Transaction tx = session.beginTransaction() ) |
223 |
| - { |
224 |
| - tx.run( "MATCH (n:Person) RETURN COUNT(*) AS count" ).next(); |
225 |
| - tx.commit(); |
226 |
| - } |
227 |
| - |
228 |
| - bookmark = session.lastBookmark(); |
229 |
| - } |
230 |
| - |
231 |
| - assertNotNull( bookmark ); |
232 |
| - |
233 |
| - inExpirableSession( driver, createWritableSession( bookmark ), session -> |
234 |
| - { |
235 |
| - try ( Transaction tx = session.beginTransaction() ) |
236 |
| - { |
237 |
| - tx.run( "CREATE (p:Person {name: $name })", Values.parameters( "name", "Alistair" ) ); |
238 |
| - tx.commit(); |
239 |
| - } |
240 |
| - |
241 |
| - return null; |
242 |
| - } ); |
243 |
| - |
244 |
| - try ( Session session = driver.session() ) |
245 |
| - { |
246 |
| - Record record = session.run( "MATCH (n:Person) RETURN COUNT(*) AS count" ).next(); |
247 |
| - assertEquals( 2, record.get( "count" ).asInt() ); |
248 |
| - } |
249 |
| - } |
250 |
| - } |
251 |
| - |
252 | 157 | @Test
|
253 | 158 | void shouldDropBrokenOldConnections() throws Exception
|
254 | 159 | {
|
@@ -301,57 +206,6 @@ void shouldDropBrokenOldConnections() throws Exception
|
301 | 206 | }
|
302 | 207 | }
|
303 | 208 |
|
304 |
| - @Test |
305 |
| - void beginTransactionThrowsForInvalidBookmark() |
306 |
| - { |
307 |
| - final String text = "hi, this is an invalid bookmark"; |
308 |
| - Bookmark invalidBookmark = parse( text ); |
309 |
| - ClusterMember leader = clusterRule.getCluster().leader(); |
310 |
| - |
311 |
| - try ( Driver driver = createDriver( leader.getBoltUri() ); |
312 |
| - Session session = driver.session( builder().withBookmarks( invalidBookmark ).build() ) ) |
313 |
| - { |
314 |
| - ClientException e = assertThrows( ClientException.class, session::beginTransaction ); |
315 |
| - assertThat( e.getMessage(), containsString( text ) ); |
316 |
| - } |
317 |
| - } |
318 |
| - |
319 |
| - @Test |
320 |
| - void shouldAcceptMultipleBookmarks() throws Exception |
321 |
| - { |
322 |
| - int threadCount = 5; |
323 |
| - String label = "Person"; |
324 |
| - String property = "name"; |
325 |
| - String value = "Alice"; |
326 |
| - |
327 |
| - Cluster cluster = clusterRule.getCluster(); |
328 |
| - executor = newExecutor(); |
329 |
| - |
330 |
| - try ( Driver driver = createDriver( cluster.getRoutingUri() ) ) |
331 |
| - { |
332 |
| - List<Future<Bookmark>> futures = new ArrayList<>(); |
333 |
| - for ( int i = 0; i < threadCount; i++ ) |
334 |
| - { |
335 |
| - futures.add( executor.submit( createNodeAndGetBookmark( driver, label, property, value ) ) ); |
336 |
| - } |
337 |
| - |
338 |
| - List<Bookmark> bookmarks = new ArrayList<>(); |
339 |
| - for ( Future<Bookmark> future : futures ) |
340 |
| - { |
341 |
| - bookmarks.add( future.get( 10, SECONDS ) ); |
342 |
| - } |
343 |
| - |
344 |
| - executor.shutdown(); |
345 |
| - assertTrue( executor.awaitTermination( 5, SECONDS ) ); |
346 |
| - |
347 |
| - try ( Session session = driver.session( builder().withDefaultAccessMode( AccessMode.READ ).withBookmarks( bookmarks ).build() ) ) |
348 |
| - { |
349 |
| - int count = countNodes( session, label, property, value ); |
350 |
| - assertEquals( count, threadCount ); |
351 |
| - } |
352 |
| - } |
353 |
| - } |
354 |
| - |
355 | 209 | @Test
|
356 | 210 | void shouldNotReuseReadConnectionForWriteTransaction()
|
357 | 211 | {
|
@@ -667,25 +521,6 @@ private static int countNodes( Session session, String label, String property, S
|
667 | 521 | return session.readTransaction( tx -> runCountNodes( tx, label, property, value ) );
|
668 | 522 | }
|
669 | 523 |
|
670 |
| - private static Callable<Bookmark> createNodeAndGetBookmark( Driver driver, String label, String property, |
671 |
| - String value ) |
672 |
| - { |
673 |
| - return () -> createNodeAndGetBookmark( driver.session(), label, property, value ); |
674 |
| - } |
675 |
| - |
676 |
| - private static Bookmark createNodeAndGetBookmark( Session session, String label, String property, String value ) |
677 |
| - { |
678 |
| - try ( Session localSession = session ) |
679 |
| - { |
680 |
| - localSession.writeTransaction( tx -> |
681 |
| - { |
682 |
| - runCreateNode( tx, label, property, value ); |
683 |
| - return null; |
684 |
| - } ); |
685 |
| - return localSession.lastBookmark(); |
686 |
| - } |
687 |
| - } |
688 |
| - |
689 | 524 | private static Result runCreateNode(QueryRunner queryRunner, String label, String property, String value )
|
690 | 525 | {
|
691 | 526 | return queryRunner.run( "CREATE (n:" + label + ") SET n." + property + " = $value", parameters( "value", value ) );
|
|
0 commit comments