Skip to content

Commit c405def

Browse files
committed
Migrate java-driver-rx-tck (neo4j#1224)
* Migrate java-driver-rx-tck This update migrates verification tests from `java-driver-rx-tck` to this project. * Update surefire and failsafe to 3.0.0-M6
1 parent 6002b6e commit c405def

File tree

3 files changed

+134
-1
lines changed

3 files changed

+134
-1
lines changed

driver/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@
6969
<groupId>org.junit.jupiter</groupId>
7070
<artifactId>junit-jupiter</artifactId>
7171
</dependency>
72+
<dependency>
73+
<groupId>org.junit.support</groupId>
74+
<artifactId>testng-engine</artifactId>
75+
</dependency>
7276
<dependency>
7377
<groupId>org.rauschig</groupId>
7478
<artifactId>jarchivelib</artifactId>
@@ -96,6 +100,10 @@
96100
<artifactId>neo4j</artifactId>
97101
<scope>test</scope>
98102
</dependency>
103+
<dependency>
104+
<groupId>org.reactivestreams</groupId>
105+
<artifactId>reactive-streams-tck</artifactId>
106+
</dependency>
99107
</dependencies>
100108

101109
<build>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver.tck.reactive;
20+
21+
import org.reactivestreams.Publisher;
22+
import org.reactivestreams.tck.PublisherVerification;
23+
import org.reactivestreams.tck.TestEnvironment;
24+
import org.testcontainers.DockerClientFactory;
25+
import org.testcontainers.containers.Neo4jContainer;
26+
import org.testcontainers.junit.jupiter.Testcontainers;
27+
import org.testng.SkipException;
28+
import org.testng.annotations.BeforeClass;
29+
30+
import java.time.Duration;
31+
32+
import org.neo4j.driver.Driver;
33+
import org.neo4j.driver.GraphDatabase;
34+
import org.neo4j.driver.Record;
35+
import org.neo4j.driver.reactive.RxResult;
36+
import org.neo4j.driver.reactive.RxSession;
37+
38+
import static org.neo4j.driver.Values.parameters;
39+
40+
@Testcontainers( disabledWithoutDocker = true )
41+
public class RxResultRecordPublisherVerificationIT extends PublisherVerification<Record>
42+
{
43+
private static final Neo4jContainer<?> NEO4J_CONTAINER = new Neo4jContainer<>( "neo4j:4.4" )
44+
.withAdminPassword( null );
45+
46+
private final static long MAX_NUMBER_OF_RECORDS = 30000;
47+
48+
private static final Duration TIMEOUT = Duration.ofSeconds( 10 );
49+
private static final Duration TIMEOUT_FOR_NO_SIGNALS = Duration.ofSeconds( 1 );
50+
private static final Duration PUBLISHER_REFERENCE_CLEANUP_TIMEOUT_MILLIS = Duration.ofSeconds( 1 );
51+
52+
private final static String QUERY = "UNWIND RANGE(1, $numberOfRecords) AS n RETURN 'String Number' + n";
53+
54+
private Driver driver;
55+
56+
public RxResultRecordPublisherVerificationIT()
57+
{
58+
super( new TestEnvironment( TIMEOUT.toMillis(), TIMEOUT_FOR_NO_SIGNALS.toMillis() ),
59+
PUBLISHER_REFERENCE_CLEANUP_TIMEOUT_MILLIS.toMillis() );
60+
}
61+
62+
@BeforeClass
63+
public void beforeClass()
64+
{
65+
if ( !isDockerAvailable() )
66+
{
67+
throw new SkipException( "Docker is unavailable" );
68+
}
69+
NEO4J_CONTAINER.start();
70+
driver = GraphDatabase.driver( NEO4J_CONTAINER.getBoltUrl() );
71+
}
72+
73+
public void afterClass()
74+
{
75+
NEO4J_CONTAINER.stop();
76+
}
77+
78+
@Override
79+
public long maxElementsFromPublisher()
80+
{
81+
return MAX_NUMBER_OF_RECORDS;
82+
}
83+
84+
@Override
85+
public Publisher<Record> createPublisher( long elements )
86+
{
87+
RxSession session = driver.rxSession();
88+
RxResult result = session.run( QUERY, parameters( "numberOfRecords", elements ) );
89+
return result.records();
90+
}
91+
92+
@Override
93+
public Publisher<Record> createFailedPublisher()
94+
{
95+
RxSession session = driver.rxSession();
96+
RxResult result = session.run( "INVALID" );
97+
return result.records();
98+
}
99+
100+
boolean isDockerAvailable()
101+
{
102+
try
103+
{
104+
DockerClientFactory.instance().client();
105+
return true;
106+
}
107+
catch ( Throwable ex )
108+
{
109+
return false;
110+
}
111+
}
112+
}

pom.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<parallelizable.it.forkCount>1C</parallelizable.it.forkCount>
2626
<!-- All tests tagged are to be executed in parallel -->
2727
<parallelizable.it.tags>parallelizableIT</parallelizable.it.tags>
28-
<surefire.and.failsafe.version>2.22.1</surefire.and.failsafe.version>
28+
<surefire.and.failsafe.version>3.0.0-M6</surefire.and.failsafe.version>
2929
<!-- Skip deployment by default for everything in this project. -->
3030
<maven.deploy.skip>true</maven.deploy.skip>
3131

@@ -44,6 +44,7 @@
4444
<hamcrest-junit.version>2.0.0.0</hamcrest-junit.version>
4545
<mockito-core.version>4.6.1</mockito-core.version>
4646
<junit.version>5.8.2</junit.version>
47+
<testng-engine.version>1.0.2</testng-engine.version>
4748
<jarchivelib.version>1.2.0</jarchivelib.version>
4849
<bouncycastle-jdk15on.version>1.70</bouncycastle-jdk15on.version>
4950
<logback-classic.version>1.2.11</logback-classic.version>
@@ -150,6 +151,12 @@
150151
<version>${junit.version}</version>
151152
<scope>test</scope>
152153
</dependency>
154+
<dependency>
155+
<groupId>org.junit.support</groupId>
156+
<artifactId>testng-engine</artifactId>
157+
<version>${testng-engine.version}</version>
158+
<scope>test</scope>
159+
</dependency>
153160
<dependency>
154161
<groupId>org.rauschig</groupId>
155162
<artifactId>jarchivelib</artifactId>
@@ -174,6 +181,12 @@
174181
<version>${logback-classic.version}</version>
175182
<scope>test</scope>
176183
</dependency>
184+
<dependency>
185+
<groupId>org.reactivestreams</groupId>
186+
<artifactId>reactive-streams-tck</artifactId>
187+
<version>${reactive-streams.version}</version>
188+
<scope>test</scope>
189+
</dependency>
177190
<dependency>
178191
<groupId>org.testcontainers</groupId>
179192
<artifactId>testcontainers-bom</artifactId>

0 commit comments

Comments
 (0)