Skip to content

Commit 396c929

Browse files
committed
Remove remaining stub tests and dependency on legacy stub server
Reactive Testkit backend enabled a lot of Testkit tests to run on reactive driver. This update removes dependency on legacy stub server that is no longer maintained. The remaining stub tests have been removed since there are similar tests in Testkit already, the tests and their respective Teskit alternatives are provided below: - `DirectDriverBoltKitIT.shouldStreamingRecordsInBatchesRx` -> `TestIterationSessionRun.test_half_batch` - Both test result consumption in batches. - `DirectDriverBoltKitIT.shouldDiscardIfPullNotFinished` -> `TestIterationSessionRun.test_discards_on_session_close` - Unlike the original, Testkit test consumes one record and discards the rest using session `run` intead of tx function. Based on its name, the original test purpose was to check if discard happens when result stream is not consumed in full and the suggested test covers this. - `RoutingDriverBoltKitIT.shouldHandleLeaderSwitchAndRetryWhenWritingInTxFunctionRX` -> `RoutingV4x4.test_should_write_successfully_on_leader_switch_using_tx_function` - Both check leader failure handling. One of examples that dependended on stub server has been brought in line with the rest of examples and uses `DatabaseExtension` to manage server.
1 parent 4366ce0 commit 396c929

File tree

14 files changed

+53
-536
lines changed

14 files changed

+53
-536
lines changed

driver/src/test/java/org/neo4j/driver/GraphDatabaseTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,16 @@
4949
import static org.mockito.Mockito.mock;
5050
import static org.mockito.Mockito.verify;
5151
import static org.mockito.Mockito.when;
52+
import static org.neo4j.driver.Logging.none;
5253
import static org.neo4j.driver.internal.logging.DevNullLogging.DEV_NULL_LOGGING;
53-
import static org.neo4j.driver.util.StubServer.INSECURE_CONFIG;
5454

5555
class GraphDatabaseTest
5656
{
57+
private static final Config INSECURE_CONFIG = Config.builder()
58+
.withoutEncryption()
59+
.withLogging( none() )
60+
.build();
61+
5762
@Test
5863
void throwsWhenBoltSchemeUsedWithRoutingParams()
5964
{

driver/src/test/java/org/neo4j/driver/integration/RoutingDriverBoltKitIT.java

Lines changed: 6 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -18,108 +18,35 @@
1818
*/
1919
package org.neo4j.driver.integration;
2020

21-
import org.junit.jupiter.api.AfterEach;
22-
import org.junit.jupiter.api.BeforeAll;
2321
import org.junit.jupiter.api.Test;
24-
import reactor.core.publisher.Flux;
25-
import reactor.core.publisher.Mono;
26-
import reactor.test.StepVerifier;
27-
28-
import java.io.IOException;
29-
import java.net.URI;
30-
import java.util.concurrent.TimeUnit;
3122

3223
import org.neo4j.driver.Config;
3324
import org.neo4j.driver.Driver;
3425
import org.neo4j.driver.GraphDatabase;
35-
import org.neo4j.driver.Record;
3626
import org.neo4j.driver.net.ServerAddress;
3727
import org.neo4j.driver.net.ServerAddressResolver;
38-
import org.neo4j.driver.reactive.RxResult;
39-
import org.neo4j.driver.reactive.RxSession;
40-
import org.neo4j.driver.util.StubServer;
41-
import org.neo4j.driver.util.StubServerController;
4228

43-
import static org.hamcrest.core.IsEqual.equalTo;
44-
import static org.hamcrest.junit.MatcherAssert.assertThat;
4529
import static org.junit.jupiter.api.Assertions.assertEquals;
4630
import static org.junit.jupiter.api.Assertions.assertThrows;
4731
import static org.mockito.ArgumentMatchers.any;
4832
import static org.mockito.Mockito.mock;
4933
import static org.mockito.Mockito.verify;
5034
import static org.mockito.Mockito.when;
51-
import static org.neo4j.driver.SessionConfig.builder;
52-
import static org.neo4j.driver.util.StubServer.insecureBuilder;
35+
import static org.neo4j.driver.Logging.none;
5336

54-
/**
55-
* New tests should be added to testkit (https://github.com/neo4j-drivers/testkit).
56-
*
57-
* This class exists only for the following:
58-
* - to keep the remaining tests that are due to be migrated
59-
* - to keep the tests that are currently not portable
60-
*/
61-
@Deprecated
6237
class RoutingDriverBoltKitIT
6338
{
64-
private static StubServerController stubController;
65-
66-
@BeforeAll
67-
public static void setup()
68-
{
69-
stubController = new StubServerController();
70-
}
71-
72-
@AfterEach
73-
public void killServers()
74-
{
75-
stubController.reset();
76-
}
77-
78-
private static String extractNameField( Record record )
79-
{
80-
return record.get( 0 ).asString();
81-
}
82-
83-
// RX is not currently supported in testkit.
84-
85-
// This does not exactly reproduce the async and blocking versions above, as we don't have any means of ignoring
86-
// the flux of the RETURN 1 query (not pulling the result) like we do in above, so this is "just" a test for
87-
// a leader going away during the execution of a flux.
88-
@Test
89-
void shouldHandleLeaderSwitchAndRetryWhenWritingInTxFunctionRX() throws IOException, InterruptedException
90-
{
91-
// Given
92-
StubServer server = stubController.startStub( "acquire_endpoints_twice_v4.script", 9001 );
93-
94-
// START a write server that fails on the first write attempt but then succeeds on the second
95-
StubServer writeServer = stubController.startStub( "not_able_to_write_server_tx_func_retries_rx.script", 9007 );
96-
URI uri = URI.create( "neo4j://127.0.0.1:9001" );
97-
98-
Driver driver = GraphDatabase.driver( uri, Config.builder().withMaxTransactionRetryTime( 1, TimeUnit.MILLISECONDS ).build() );
99-
100-
Flux<String> fluxOfNames = Flux.usingWhen( Mono.fromSupplier( () -> driver.rxSession( builder().withDatabase( "mydatabase" ).build() ) ),
101-
session -> session.writeTransaction( tx ->
102-
{
103-
RxResult result = tx.run( "RETURN 1" );
104-
return Flux.from( result.records() ).limitRate( 100 ).thenMany( tx.run( "MATCH (n) RETURN n.name" ).records() ).limitRate( 100 ).map(
105-
RoutingDriverBoltKitIT::extractNameField );
106-
} ), RxSession::close );
107-
108-
StepVerifier.create( fluxOfNames ).expectNext( "Foo", "Bar" ).verifyComplete();
109-
110-
// Finally
111-
driver.close();
112-
assertThat( server.exitStatus(), equalTo( 0 ) );
113-
assertThat( writeServer.exitStatus(), equalTo( 0 ) );
114-
}
115-
11639
@Test
11740
void shouldFailInitialDiscoveryWhenConfiguredResolverThrows()
11841
{
11942
ServerAddressResolver resolver = mock( ServerAddressResolver.class );
12043
when( resolver.resolve( any( ServerAddress.class ) ) ).thenThrow( new RuntimeException( "Resolution failure!" ) );
12144

122-
Config config = insecureBuilder().withResolver( resolver ).build();
45+
Config config = Config.builder()
46+
.withoutEncryption()
47+
.withLogging( none() )
48+
.withResolver( resolver )
49+
.build();
12350
final Driver driver = GraphDatabase.driver( "neo4j://my.server.com:9001", config );
12451

12552
RuntimeException error = assertThrows( RuntimeException.class, driver::verifyConnectivity );

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

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

0 commit comments

Comments
 (0)