Skip to content

Commit

Permalink
Migrate tests from Java Driver to Testkit (neo4j#979) (neo4j#983)
Browse files Browse the repository at this point in the history
Migrated tests:
- shouldAllowDatabaseNameInSessionRun -> test_should_support_database_name_using_session_run (Bolt bump from v4 to v4.1)
- shouldAllowDatabaseNameInBeginTransaction -> test_should_read_successfully_with_database_name_using_tx_function (Bolt bump from v4 to v4.1)
- shouldOnlyPullRecordsWhenNeededSimpleSession -> test_should_accept_custom_fetch_size_using_session_configuration (existing test)
  • Loading branch information
injectives authored Aug 13, 2021
1 parent 79c215f commit cb3b34e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
import java.util.ArrayList;
import java.util.List;

import org.neo4j.driver.AccessMode;
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Config;
import org.neo4j.driver.Driver;
import org.neo4j.driver.GraphDatabase;
import org.neo4j.driver.Result;
import org.neo4j.driver.Session;
import org.neo4j.driver.async.AsyncSession;
import org.neo4j.driver.async.ResultCursor;
Expand All @@ -55,7 +53,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.neo4j.driver.SessionConfig.builder;
import static org.neo4j.driver.SessionConfig.forDatabase;
import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
import static org.neo4j.driver.util.StubServer.INSECURE_CONFIG;
import static org.neo4j.driver.util.TestUtil.await;
Expand Down Expand Up @@ -127,28 +124,6 @@ void shouldStreamingRecordsInBatchesRx() throws Exception
}
}

@Test
void shouldOnlyPullRecordsWhenNeededSimpleSession() throws Exception
{
StubServer server = stubController.startStub( "streaming_records_v4_buffering.script", 9001 );
try
{
try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG ) )
{
Session session = driver.session( builder().withFetchSize( 2 ).build() );
Result result = session.run( "MATCH (n) RETURN n.name" );
ArrayList<String> resultList = new ArrayList<>();
result.forEachRemaining( ( rec ) -> resultList.add( rec.get( 0 ).asString() ) );

assertEquals( resultList, asList( "Bob", "Alice", "Tina", "Frank", "Daisy", "Clive" ) );
}
}
finally
{
assertEquals( 0, server.exitStatus() );
}
}

@Test
void shouldOnlyPullRecordsWhenNeededAsyncSession() throws Exception
{
Expand Down Expand Up @@ -196,39 +171,6 @@ void shouldPullAllRecordsOnListAsyncWhenOverWatermark() throws Exception
}
}

@Test
void shouldAllowDatabaseNameInSessionRun() throws Throwable
{
StubServer server = stubController.startStub( "read_server_v4_read.script", 9001 );

try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG );
Session session = driver.session( builder().withDatabase( "mydatabase" ).withDefaultAccessMode( AccessMode.READ ).build() ) )
{
final Result result = session.run( "MATCH (n) RETURN n.name" );
result.consume();
}
finally
{
assertEquals( 0, server.exitStatus() );
}
}

@Test
void shouldAllowDatabaseNameInBeginTransaction() throws Throwable
{
StubServer server = stubController.startStub( "read_server_v4_read_tx.script", 9001 );

try ( Driver driver = GraphDatabase.driver( "bolt://localhost:9001", INSECURE_CONFIG );
Session session = driver.session( forDatabase( "mydatabase" ) ) )
{
session.readTransaction( tx -> tx.run( "MATCH (n) RETURN n.name" ).consume() );
}
finally
{
assertEquals( 0, server.exitStatus() );
}
}

@Test
void shouldDiscardIfPullNotFinished() throws Throwable
{
Expand Down
12 changes: 0 additions & 12 deletions driver/src/test/resources/read_server_v4_read.script

This file was deleted.

16 changes: 0 additions & 16 deletions driver/src/test/resources/read_server_v4_read_tx.script

This file was deleted.

0 comments on commit cb3b34e

Please sign in to comment.