Skip to content

Commit 44fe659

Browse files
committed
Migrate remaining tests to vertx-junit5
Some portions of this content were created with the assistance of Claude Code.
1 parent f64a5cb commit 44fe659

File tree

100 files changed

+3156
-4206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3156
-4206
lines changed

vertx-web-client/src/test/java/io/vertx/ext/web/client/tests/WebClientTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import java.nio.charset.StandardCharsets;
4444
import java.util.*;
4545
import java.util.concurrent.CompletableFuture;
46-
import java.util.concurrent.CountDownLatch;
4746
import java.util.concurrent.TimeoutException;
4847
import java.util.concurrent.atomic.AtomicBoolean;
4948
import java.util.concurrent.atomic.AtomicInteger;
@@ -965,7 +964,7 @@ class SendStreamErrorTest extends SendStreamTestBase {
965964
AtomicReference<Handler<Buffer>> dataHandler = new AtomicReference<>();
966965
AtomicReference<Handler<Void>> endHandler = new AtomicReference<>();
967966
AtomicBoolean paused = new AtomicBoolean();
968-
CountDownLatch latch = new CountDownLatch(1);
967+
Promise<Void> requestReceived = Promise.promise();
969968

970969
@Override
971970
void init() throws Exception {
@@ -1005,7 +1004,7 @@ public ReadStream<Buffer> endHandler(Handler<Void> handler) {
10051004
void handleRequest(HttpServerRequest req) {
10061005
conn.set(req.connection());
10071006
req.pause();
1008-
latch.countDown();
1007+
requestReceived.complete();
10091008
}
10101009

10111010
@Override
@@ -1014,9 +1013,8 @@ Future<HttpResponse<Buffer>> send(WebClient client) {
10141013
assertWaitUntil(() -> dataHandler.get() != null);
10151014
dataHandler.get().handle(TestUtils.randomBuffer(1024));
10161015
try {
1017-
TestUtils.awaitLatch(latch);
1018-
} catch (InterruptedException e) {
1019-
Thread.currentThread().interrupt();
1016+
requestReceived.future().await();
1017+
} catch (Exception e) {
10201018
fail(e);
10211019
}
10221020
while (!paused.get()) {

vertx-web-graphql/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@
7171
<type>test-jar</type>
7272
<scope>test</scope>
7373
</dependency>
74+
<dependency>
75+
<groupId>io.vertx</groupId>
76+
<artifactId>vertx-junit5</artifactId>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.junit.jupiter</groupId>
81+
<artifactId>junit-jupiter-engine</artifactId>
82+
<version>5.14.0</version>
83+
<scope>test</scope>
84+
</dependency>
7485
</dependencies>
7586

7687
<build>

vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/tests/BasicTypesTest.java

Lines changed: 49 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
import graphql.schema.idl.SchemaGenerator;
1010
import graphql.schema.idl.SchemaParser;
1111
import graphql.schema.idl.TypeDefinitionRegistry;
12-
import io.vertx.core.Future;
1312
import io.vertx.core.json.JsonArray;
1413
import io.vertx.core.json.JsonObject;
15-
import org.junit.Test;
14+
import org.junit.jupiter.api.Test;
1615

1716
import java.time.LocalDate;
1817
import java.time.LocalDateTime;
@@ -21,12 +20,12 @@
2120
import java.time.format.DateTimeParseException;
2221
import java.time.temporal.TemporalAccessor;
2322
import java.util.Arrays;
24-
import java.util.List;
2523
import java.util.Locale;
2624
import java.util.concurrent.atomic.AtomicInteger;
2725

2826
import static graphql.schema.idl.RuntimeWiring.newRuntimeWiring;
2927
import static io.vertx.core.http.HttpMethod.POST;
28+
import static org.junit.jupiter.api.Assertions.*;
3029

3130
public class BasicTypesTest extends GraphQLTestBase {
3231

@@ -77,85 +76,67 @@ protected GraphQL graphQL() {
7776
}
7877

7978
@Test
80-
public void helloWorld() throws Exception {
79+
public void helloWorld() {
8180
JsonObject result = new JsonObject().put("data", new JsonObject().put("hello", "Hello World!"));
8281
GraphQLRequest request = new GraphQLRequest()
8382
.setMethod(POST)
8483
.setGraphQLQuery("query { hello }");
85-
request.send(client).onComplete(onSuccess(body -> {
86-
assertEquals(result, body);
87-
testComplete();
88-
}));
89-
await();
84+
JsonObject body = request.send(webClient);
85+
assertEquals(result, body);
9086
}
9187

9288
@Test
93-
public void integerNumber() throws Exception {
89+
public void integerNumber() {
9490
JsonObject result = new JsonObject().put("data", new JsonObject().put("number", 130));
9591
GraphQLRequest request = new GraphQLRequest()
9692
.setMethod(POST)
9793
.setGraphQLQuery("query { number }");
98-
request.send(client).onComplete(onSuccess(body -> {
99-
assertEquals(result, body);
100-
testComplete();
101-
}));
102-
await();
94+
JsonObject body = request.send(webClient);
95+
assertEquals(result, body);
10396
}
10497

10598
@Test
106-
public void floatingPointNumber() throws Exception {
99+
public void floatingPointNumber() {
107100
JsonObject result = new JsonObject().put("data", new JsonObject().put("floating", 3.14));
108101
GraphQLRequest request = new GraphQLRequest()
109102
.setMethod(POST)
110103
.setGraphQLQuery("query { floating }");
111-
request.send(client).onComplete(onSuccess(body -> {
112-
assertEquals(result, body);
113-
testComplete();
114-
}));
115-
await();
104+
JsonObject body = request.send(webClient);
105+
assertEquals(result, body);
116106
}
117107

118108
@Test
119-
public void bool() throws Exception {
109+
public void bool() {
120110
JsonObject result = new JsonObject().put("data", new JsonObject().put("bool", true));
121111
GraphQLRequest request = new GraphQLRequest()
122112
.setMethod(POST)
123113
.setGraphQLQuery("query { bool }");
124-
request.send(client).onComplete(onSuccess(body -> {
125-
assertEquals(result, body);
126-
testComplete();
127-
}));
128-
await();
114+
JsonObject body = request.send(webClient);
115+
assertEquals(result, body);
129116
}
130117

131118
@Test
132-
public void id() throws Exception {
119+
public void id() {
133120
JsonObject result = new JsonObject().put("data", new JsonObject().put("id", "1001"));
134121
GraphQLRequest request = new GraphQLRequest()
135122
.setMethod(POST)
136123
.setGraphQLQuery("query { id }");
137-
request.send(client).onComplete(onSuccess(body -> {
138-
assertEquals(result, body);
139-
testComplete();
140-
}));
141-
await();
124+
JsonObject body = request.send(webClient);
125+
assertEquals(result, body);
142126
}
143127

144128
@Test
145-
public void enumeration() throws Exception {
129+
public void enumeration() {
146130
JsonObject result = new JsonObject().put("data", new JsonObject().put("enum", Musketeer.ATHOS.toString()));
147131
GraphQLRequest request = new GraphQLRequest()
148132
.setMethod(POST)
149133
.setGraphQLQuery("query { enum }");
150-
request.send(client).onComplete(onSuccess(body -> {
151-
assertEquals(result, body);
152-
testComplete();
153-
}));
154-
await();
134+
JsonObject body = request.send(webClient);
135+
assertEquals(result, body);
155136
}
156137

157138
@Test
158-
public void list() throws Exception {
139+
public void list() {
159140
JsonObject result = new JsonObject().put("data", new JsonObject()
160141
.put("list", new JsonArray()
161142
.add("apples")
@@ -164,15 +145,12 @@ public void list() throws Exception {
164145
GraphQLRequest request = new GraphQLRequest()
165146
.setMethod(POST)
166147
.setGraphQLQuery("query { list }");
167-
request.send(client).onComplete(onSuccess(body -> {
168-
assertEquals(result, body);
169-
testComplete();
170-
}));
171-
await();
148+
JsonObject body = request.send(webClient);
149+
assertEquals(result, body);
172150
}
173151

174152
@Test
175-
public void alias() throws Exception {
153+
public void alias() {
176154
JsonObject result = new JsonObject().put("data", new JsonObject()
177155
.put("arr", new JsonArray()
178156
.add("apples")
@@ -181,92 +159,71 @@ public void alias() throws Exception {
181159
GraphQLRequest request = new GraphQLRequest()
182160
.setMethod(POST)
183161
.setGraphQLQuery("query { arr: array }");
184-
request.send(client).onComplete(onSuccess(body -> {
185-
assertEquals(result, body);
186-
testComplete();
187-
}));
188-
await();
162+
JsonObject body = request.send(webClient);
163+
assertEquals(result, body);
189164
}
190165

191166
@Test
192-
public void userDefined() throws Exception {
167+
public void userDefined() {
193168
LocalDateTime ldt = LocalDateTime.of(LocalDate.of(1991, 8, 25), LocalTime.of(22, 57, 8));
194169
String when = new DatetimeCoercion().serialize(ldt, null, null);
195170
JsonObject result = new JsonObject().put("data", new JsonObject().put("when", when));
196171
GraphQLRequest request = new GraphQLRequest()
197172
.setMethod(POST)
198173
.setGraphQLQuery("query { when }");
199-
request.send(client).onComplete(onSuccess(body -> {
200-
assertEquals(result, body);
201-
testComplete();
202-
}));
203-
await();
174+
JsonObject body = request.send(webClient);
175+
assertEquals(result, body);
204176
}
205177

206178
@Test
207-
public void functionDefault() throws Exception {
179+
public void functionDefault() {
208180
JsonObject result = new JsonObject().put("data", new JsonObject().put("answer", "Hello, someone!"));
209181
GraphQLRequest request = new GraphQLRequest()
210182
.setMethod(POST)
211183
.setGraphQLQuery("query { answer }");
212-
request.send(client).onComplete(onSuccess(body -> {
213-
assertEquals(result, body);
214-
testComplete();
215-
}));
216-
await();
184+
JsonObject body = request.send(webClient);
185+
assertEquals(result, body);
217186
}
218187

219188
@Test
220-
public void function() throws Exception {
189+
public void function() {
221190
JsonObject result = new JsonObject().put("data", new JsonObject().put("answer", "Hello, world!"));
222191
GraphQLRequest request = new GraphQLRequest()
223192
.setMethod(POST)
224193
.setGraphQLQuery("query { answer(name: \"world\") }");
225-
request.send(client).onComplete(onSuccess(body -> {
226-
assertEquals(result, body);
227-
testComplete();
228-
}));
229-
await();
194+
JsonObject body = request.send(webClient);
195+
assertEquals(result, body);
230196
}
231197

232198
@Test
233-
public void cached() throws Exception {
199+
public void cached() {
234200
GraphQLRequest request1 = new GraphQLRequest()
235201
.setMethod(POST)
236202
.setGraphQLQuery("query { changing }");
237-
Future<JsonObject> future1 = request1.send(client);
203+
JsonObject body1 = request1.send(webClient);
238204

239205
GraphQLRequest request2 = new GraphQLRequest()
240206
.setMethod(POST)
241207
.setGraphQLQuery("query { changing }");
242-
Future<JsonObject> future2 = request2.send(client);
208+
JsonObject body2 = request2.send(webClient);
243209

244-
Future.all(future1, future2).onComplete(onSuccess(compositeFuture -> {
245-
List<JsonObject> values = compositeFuture.list();
246-
Integer value1 = values.get(0).getJsonObject("data").getInteger("changing");
247-
Integer value2 = values.get(1).getJsonObject("data").getInteger("changing");
248-
assertFalse(value1.equals(value2));
249-
testComplete();
250-
}));
251-
252-
await();
210+
Integer value1 = body1.getJsonObject("data").getInteger("changing");
211+
Integer value2 = body2.getJsonObject("data").getInteger("changing");
212+
assertNotEquals(value1, value2);
253213
}
254214

255215
@Test
256-
public void recursive() throws Exception {
216+
public void recursive() {
257217
GraphQLRequest request = new GraphQLRequest()
258218
.setMethod(POST)
259219
.setGraphQLQuery("query { persons { name , friend { name, friend { name } } } }");
260-
request.send(client).onComplete(onSuccess(body -> {
261-
JsonObject person = body.getJsonObject("data").getJsonArray("persons").getJsonObject(0);
262-
assertEquals("Plato", person.getString("name"));
263-
JsonObject friend = person.getJsonObject("friend");
264-
assertEquals("Aristotle", friend.getString("name"));
265-
JsonObject friendOfFriend = friend.getJsonObject("friend");
266-
assertEquals("Plato", friendOfFriend.getString("name"));
267-
testComplete();
268-
}));
269-
await();
220+
JsonObject body = request.send(webClient);
221+
JsonObject person = body.getJsonObject("data").getJsonArray("persons").getJsonObject(0);
222+
assertEquals("Plato", person.getString("name"));
223+
JsonObject friend = person.getJsonObject("friend");
224+
assertEquals("Aristotle", friend.getString("name"));
225+
JsonObject friendOfFriend = friend.getJsonObject("friend");
226+
assertEquals("Plato", friendOfFriend.getString("name"));
270227
}
271228

272229
private enum Musketeer {

0 commit comments

Comments
 (0)