Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate tests from Java Driver to Testkit #979

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.