Skip to content

Commit 79c215f

Browse files
authored
Migrate tests from Java Driver to Testkit (#978) (#980)
Migrated tests: - shouldAllowPullAll -> test_should_pull_all_when_fetch_is_minus_one_using_driver_configuration (Bolt bump from v4 to v4.1) - shouldThrowCommitErrorWhenTransactionCommit -> test_should_error_on_commit_failure_using_tx_commit - shouldServerWithBoltV4SupportMultiDb -> test_should_check_multi_db_support - shouldServerWithBoltV3NotSupportMultiDb -> test_should_check_multi_db_support - shouldBeAbleHandleNOOPsDuringRunCypher -> test_should_accept_noop_during_records_streaming - shouldThrowCorrectErrorOnCommitFailure -> test_should_error_on_database_shutdown_using_tx_commit - shouldThrowCorrectErrorOnRunFailure -> test_should_error_on_database_shutdown_using_tx_run
1 parent 24d459c commit 79c215f

File tree

8 files changed

+0
-229
lines changed

8 files changed

+0
-229
lines changed

driver/src/test/java/org/neo4j/driver/internal/DirectDriverBoltKitIT.java

Lines changed: 0 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,16 @@
2929
import java.net.URI;
3030
import java.util.ArrayList;
3131
import java.util.List;
32-
import java.util.function.Consumer;
3332

3433
import org.neo4j.driver.AccessMode;
3534
import org.neo4j.driver.AuthTokens;
36-
import org.neo4j.driver.Bookmark;
3735
import org.neo4j.driver.Config;
3836
import org.neo4j.driver.Driver;
3937
import org.neo4j.driver.GraphDatabase;
4038
import org.neo4j.driver.Result;
4139
import org.neo4j.driver.Session;
42-
import org.neo4j.driver.Transaction;
4340
import org.neo4j.driver.async.AsyncSession;
4441
import org.neo4j.driver.async.ResultCursor;
45-
import org.neo4j.driver.exceptions.TransientException;
4642
import org.neo4j.driver.internal.cluster.RoutingSettings;
4743
import org.neo4j.driver.internal.retry.RetrySettings;
4844
import org.neo4j.driver.internal.security.SecurityPlanImpl;
@@ -56,18 +52,12 @@
5652
import static java.util.Arrays.asList;
5753
import static java.util.Collections.singletonList;
5854
import static java.util.concurrent.TimeUnit.SECONDS;
59-
import static org.hamcrest.core.IsEqual.equalTo;
60-
import static org.hamcrest.junit.MatcherAssert.assertThat;
6155
import static org.junit.jupiter.api.Assertions.assertEquals;
62-
import static org.junit.jupiter.api.Assertions.assertFalse;
6356
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;
6657
import static org.neo4j.driver.SessionConfig.builder;
6758
import static org.neo4j.driver.SessionConfig.forDatabase;
6859
import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
6960
import static org.neo4j.driver.util.StubServer.INSECURE_CONFIG;
70-
import static org.neo4j.driver.util.StubServer.insecureBuilder;
7161
import static org.neo4j.driver.util.TestUtil.await;
7262

7363
class DirectDriverBoltKitIT
@@ -206,76 +196,6 @@ void shouldPullAllRecordsOnListAsyncWhenOverWatermark() throws Exception
206196
}
207197
}
208198

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-
279199
@Test
280200
void shouldAllowDatabaseNameInSessionRun() throws Throwable
281201
{
@@ -327,75 +247,4 @@ void shouldDiscardIfPullNotFinished() throws Throwable
327247
assertEquals( 0, server.exitStatus() );
328248
}
329249
}
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-
}
401250
}

driver/src/test/resources/commit_error.script

Lines changed: 0 additions & 17 deletions
This file was deleted.

driver/src/test/resources/database_shutdown.script

Lines changed: 0 additions & 11 deletions
This file was deleted.

driver/src/test/resources/database_shutdown_at_commit.script

Lines changed: 0 additions & 14 deletions
This file was deleted.

driver/src/test/resources/noop.script

Lines changed: 0 additions & 16 deletions
This file was deleted.

driver/src/test/resources/streaming_records_v4_all.script

Lines changed: 0 additions & 12 deletions
This file was deleted.

driver/src/test/resources/support_multidb_v3.script

Lines changed: 0 additions & 4 deletions
This file was deleted.

driver/src/test/resources/support_multidb_v4.script

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)