Skip to content

Commit 8638dcb

Browse files
committed
Virtual threads: integration tests refactoring
- move the logic from AssertHelpers to a shared component - VirtualThreadsAssertions located in quarkus-test-vertx
1 parent 14dd05e commit 8638dcb

File tree

47 files changed

+160
-929
lines changed

Some content is hidden

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

47 files changed

+160
-929
lines changed

integration-tests/virtual-threads/amqp-virtual-threads/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
<artifactId>assertj-core</artifactId>
5353
<scope>test</scope>
5454
</dependency>
55+
<!-- Use the "compile" scope because we need to include the VirtualThreadsAssertions in the app -->
5556
<dependency>
5657
<groupId>io.quarkus</groupId>
5758
<artifactId>quarkus-test-vertx</artifactId>
58-
<scope>test</scope>
5959
</dependency>
6060
<dependency>
6161
<groupId>io.quarkus</groupId>

integration-tests/virtual-threads/amqp-virtual-threads/src/main/java/io/quarkus/it/vthreads/amqp/AssertHelper.java

-68
This file was deleted.

integration-tests/virtual-threads/amqp-virtual-threads/src/main/java/io/quarkus/it/vthreads/amqp/PriceConsumer.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package io.quarkus.it.vthreads.amqp;
22

3-
import static io.quarkus.it.vthreads.amqp.AssertHelper.assertThatItRunsOnADuplicatedContext;
4-
import static io.quarkus.it.vthreads.amqp.AssertHelper.assertThatItRunsOnVirtualThread;
5-
63
import java.util.Random;
74
import java.util.concurrent.CompletionStage;
85
import java.util.concurrent.atomic.AtomicInteger;
@@ -14,6 +11,7 @@
1411
import org.eclipse.microprofile.reactive.messaging.Outgoing;
1512
import org.eclipse.microprofile.rest.client.inject.RestClient;
1613

14+
import io.quarkus.test.vertx.VirtualThreadsAssertions;
1715
import io.smallrye.common.annotation.RunOnVirtualThread;
1816

1917
@ApplicationScoped
@@ -25,12 +23,12 @@ public class PriceConsumer {
2523
@Incoming("prices")
2624
@RunOnVirtualThread
2725
public CompletionStage<Void> consume(Message<Double> msg) {
28-
assertThatItRunsOnVirtualThread();
29-
assertThatItRunsOnADuplicatedContext();
26+
VirtualThreadsAssertions.assertThatItRunsOnVirtualThread();
27+
VirtualThreadsAssertions.assertThatItRunsOnADuplicatedContext();
3028
double price = msg.getPayload();
3129
alertService.alertMessage(price);
3230
return msg.ack().thenAccept(x -> {
33-
assertThatItRunsOnADuplicatedContext();
31+
VirtualThreadsAssertions.assertThatItRunsOnADuplicatedContext();
3432
// While the ack always runs on event loop thread
3533
// the post-ack may run on the processing virtual-thread which executed the method.
3634
});
@@ -39,8 +37,8 @@ public CompletionStage<Void> consume(Message<Double> msg) {
3937
@Incoming("prices")
4038
@RunOnVirtualThread
4139
public void consume(double price) {
42-
assertThatItRunsOnVirtualThread();
43-
assertThatItRunsOnADuplicatedContext();
40+
VirtualThreadsAssertions.assertThatItRunsOnVirtualThread();
41+
VirtualThreadsAssertions.assertThatItRunsOnADuplicatedContext();
4442
alertService.alert(price);
4543
}
4644

@@ -50,7 +48,7 @@ public void consume(double price) {
5048
@Outgoing("prices-out")
5149
@RunOnVirtualThread
5250
public Message<Double> randomPriceGenerator() {
53-
assertThatItRunsOnVirtualThread();
51+
VirtualThreadsAssertions.assertThatItRunsOnVirtualThread();
5452
return Message.of(r.nextDouble() * 10 * i.incrementAndGet());
5553
}
5654

integration-tests/virtual-threads/grpc-virtual-threads/pom.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
<groupId>io.quarkus</groupId>
2323
<artifactId>quarkus-grpc</artifactId>
2424
</dependency>
25-
25+
<!-- Use the "compile" scope because we need to include the VirtualThreadsAssertions in the app -->
26+
<dependency>
27+
<groupId>io.quarkus</groupId>
28+
<artifactId>quarkus-test-vertx</artifactId>
29+
</dependency>
2630
<dependency>
2731
<groupId>io.quarkus</groupId>
2832
<artifactId>quarkus-junit5</artifactId>

integration-tests/virtual-threads/grpc-virtual-threads/src/main/java/io/quarkus/grpc/example/streaming/AssertHelper.java

-53
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package io.quarkus.grpc.example.streaming;
22

3-
import static io.quarkus.grpc.example.streaming.AssertHelper.assertEverything;
4-
53
import com.google.protobuf.ByteString;
64
import com.google.protobuf.EmptyProtos;
75

86
import io.grpc.testing.integration.Messages;
97
import io.grpc.testing.integration.TestService;
108
import io.quarkus.grpc.GrpcService;
9+
import io.quarkus.test.vertx.VirtualThreadsAssertions;
1110
import io.smallrye.common.annotation.RunOnVirtualThread;
1211
import io.smallrye.mutiny.Multi;
1312
import io.smallrye.mutiny.Uni;
@@ -18,39 +17,39 @@ public class TestServiceImpl implements TestService {
1817
@RunOnVirtualThread
1918
@Override
2019
public Uni<EmptyProtos.Empty> emptyCall(EmptyProtos.Empty request) {
21-
assertEverything();
20+
VirtualThreadsAssertions.assertEverything();
2221
return Uni.createFrom().item(EmptyProtos.Empty.newBuilder().build())
23-
.invoke(AssertHelper::assertEverything);
22+
.invoke(VirtualThreadsAssertions::assertEverything);
2423
}
2524

2625
@RunOnVirtualThread
2726
@Override
2827
public Uni<Messages.SimpleResponse> unaryCall(Messages.SimpleRequest request) {
29-
assertEverything();
28+
VirtualThreadsAssertions.assertEverything();
3029
var value = request.getPayload().getBody().toStringUtf8();
3130
var resp = Messages.SimpleResponse.newBuilder()
3231
.setPayload(Messages.Payload.newBuilder().setBody(ByteString.copyFromUtf8(value.toUpperCase())).build())
3332
.build();
3433
return Uni.createFrom().item(resp)
35-
.invoke(AssertHelper::assertEverything);
34+
.invoke(VirtualThreadsAssertions::assertEverything);
3635
}
3736

3837
@Override
3938
@RunOnVirtualThread
4039
public Multi<Messages.StreamingOutputCallResponse> streamingOutputCall(Messages.StreamingOutputCallRequest request) {
4140
var value = request.getPayload().getBody().toStringUtf8();
42-
assertEverything();
41+
VirtualThreadsAssertions.assertEverything();
4342
return Multi.createFrom().<String> emitter(emitter -> {
44-
assertEverything();
43+
VirtualThreadsAssertions.assertEverything();
4544
emitter.emit(value.toUpperCase());
4645
emitter.emit(value.toUpperCase());
4746
emitter.emit(value.toUpperCase());
4847
emitter.complete();
4948
}).map(v -> Messages.StreamingOutputCallResponse.newBuilder()
5049
.setPayload(Messages.Payload.newBuilder().setBody(ByteString.copyFromUtf8(v)).build())
5150
.build())
52-
.invoke(AssertHelper::assertEverything)
53-
.onTermination().invoke(AssertHelper::assertEverything);
51+
.invoke(VirtualThreadsAssertions::assertEverything)
52+
.onTermination().invoke(VirtualThreadsAssertions::assertEverything);
5453
}
5554

5655
}

integration-tests/virtual-threads/jms-virtual-threads/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@
7878
<artifactId>assertj-core</artifactId>
7979
<scope>test</scope>
8080
</dependency>
81+
<!-- Use the "compile" scope because we need to include the VirtualThreadsAssertions in the app -->
8182
<dependency>
8283
<groupId>io.quarkus</groupId>
8384
<artifactId>quarkus-test-vertx</artifactId>
84-
<scope>test</scope>
8585
</dependency>
8686
<dependency>
8787
<groupId>io.quarkus</groupId>

integration-tests/virtual-threads/jms-virtual-threads/src/main/java/io/quarkus/it/vthreads/jms/AssertHelper.java

-68
This file was deleted.

integration-tests/virtual-threads/jms-virtual-threads/src/main/java/io/quarkus/it/vthreads/jms/PriceConsumer.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.quarkus.it.vthreads.jms;
22

3-
import static io.quarkus.it.vthreads.jms.AssertHelper.assertThatItRunsOnVirtualThread;
4-
53
import java.util.Random;
64
import java.util.concurrent.CompletionStage;
75
import java.util.concurrent.atomic.AtomicInteger;
@@ -13,6 +11,7 @@
1311
import org.eclipse.microprofile.reactive.messaging.Outgoing;
1412
import org.eclipse.microprofile.rest.client.inject.RestClient;
1513

14+
import io.quarkus.test.vertx.VirtualThreadsAssertions;
1615
import io.smallrye.common.annotation.RunOnVirtualThread;
1716

1817
@ApplicationScoped
@@ -24,7 +23,7 @@ public class PriceConsumer {
2423
@Incoming("prices")
2524
@RunOnVirtualThread
2625
public CompletionStage<Void> consume(Message<Double> msg) {
27-
assertThatItRunsOnVirtualThread();
26+
VirtualThreadsAssertions.assertThatItRunsOnVirtualThread();
2827
double price = msg.getPayload();
2928
alertService.alertMessage(price);
3029
return msg.ack();
@@ -33,7 +32,7 @@ public CompletionStage<Void> consume(Message<Double> msg) {
3332
@Incoming("prices")
3433
@RunOnVirtualThread
3534
public void consume(double price) {
36-
assertThatItRunsOnVirtualThread();
35+
VirtualThreadsAssertions.assertThatItRunsOnVirtualThread();
3736
alertService.alert(price);
3837
}
3938

@@ -43,7 +42,7 @@ public void consume(double price) {
4342
@Outgoing("prices-out")
4443
@RunOnVirtualThread
4544
public Message<Double> randomPriceGenerator() {
46-
assertThatItRunsOnVirtualThread();
45+
VirtualThreadsAssertions.assertThatItRunsOnVirtualThread();
4746
return Message.of(r.nextDouble() * 10 * i.incrementAndGet());
4847
}
4948

0 commit comments

Comments
 (0)