diff --git a/integration-tests/virtual-threads/amqp-virtual-threads/pom.xml b/integration-tests/virtual-threads/amqp-virtual-threads/pom.xml index d05b0088e1546..5e207e911d5b7 100644 --- a/integration-tests/virtual-threads/amqp-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/amqp-virtual-threads/pom.xml @@ -32,6 +32,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/amqp-virtual-threads/src/main/java/io/quarkus/it/vthreads/amqp/PriceConsumer.java b/integration-tests/virtual-threads/amqp-virtual-threads/src/main/java/io/quarkus/it/vthreads/amqp/PriceConsumer.java index 97379b28a7a2d..540015bfc892e 100644 --- a/integration-tests/virtual-threads/amqp-virtual-threads/src/main/java/io/quarkus/it/vthreads/amqp/PriceConsumer.java +++ b/integration-tests/virtual-threads/amqp-virtual-threads/src/main/java/io/quarkus/it/vthreads/amqp/PriceConsumer.java @@ -28,9 +28,7 @@ public CompletionStage consume(Message msg) { assertThatItRunsOnVirtualThread(); assertThatItRunsOnADuplicatedContext(); double price = msg.getPayload(); - if (price > 90.0) { - alertService.alertMessage(price); - } + alertService.alertMessage(price); return msg.ack().thenAccept(x -> { assertThatItRunsOnADuplicatedContext(); // While the ack always runs on event loop thread @@ -43,9 +41,7 @@ public CompletionStage consume(Message msg) { public void consume(double price) { assertThatItRunsOnVirtualThread(); assertThatItRunsOnADuplicatedContext(); - if (price > 90.0) { - alertService.alert(price); - } + alertService.alert(price); } Random r = new Random(); diff --git a/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/NoPinningVerify.java b/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/NoPinningVerify.java deleted file mode 100644 index 0db11972e439b..0000000000000 --- a/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.it.vthreads.amqp; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/VirtualThreadTest.java b/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/VirtualThreadTest.java index 4d44358a66087..f78312ba795d5 100644 --- a/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/VirtualThreadTest.java +++ b/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/VirtualThreadTest.java @@ -13,9 +13,13 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; @QuarkusTest @QuarkusTestResource(WireMockExtension.class) +@VirtualThreadUnit +@ShouldNotPin public class VirtualThreadTest { public static final int EXPECTED_CALLS = 10; diff --git a/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/WireMockExtension.java b/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/WireMockExtension.java index 8d3499c6d2856..beb5f2a4aa554 100644 --- a/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/WireMockExtension.java +++ b/integration-tests/virtual-threads/amqp-virtual-threads/src/test/java/io/quarkus/it/vthreads/amqp/WireMockExtension.java @@ -24,7 +24,7 @@ public Map start() { wireMockServer.stubFor(post(urlEqualTo("/price/alert-message")) .willReturn(aResponse().withBody("ok"))); - return Map.of("price-alert/mp-rest/url", wireMockServer.baseUrl()); + return Map.of("quarkus.rest-client.price-alert.url", wireMockServer.baseUrl()); } @Override diff --git a/integration-tests/virtual-threads/grpc-virtual-threads/pom.xml b/integration-tests/virtual-threads/grpc-virtual-threads/pom.xml index 266391bf2da6a..ba8052cf73552 100644 --- a/integration-tests/virtual-threads/grpc-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/grpc-virtual-threads/pom.xml @@ -28,6 +28,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/NoPinningVerify.java b/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/NoPinningVerify.java deleted file mode 100644 index 7e3dc8bbea963..0000000000000 --- a/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.grpc.example.streaming; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/VertxVirtualThreadTest.java b/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/VertxVirtualThreadTest.java index c2799cc70f2f8..f480f0139b76e 100644 --- a/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/VertxVirtualThreadTest.java +++ b/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/VertxVirtualThreadTest.java @@ -3,8 +3,12 @@ import io.quarkus.grpc.test.utils.VertxGRPCTestProfile; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; @QuarkusTest @TestProfile(VertxGRPCTestProfile.class) +@VirtualThreadUnit +@ShouldNotPin public class VertxVirtualThreadTest extends VirtualThreadTestBase { } diff --git a/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/VirtualThreadTest.java b/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/VirtualThreadTest.java index a8f5412fe7e71..b5c773153a0c9 100644 --- a/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/VirtualThreadTest.java +++ b/integration-tests/virtual-threads/grpc-virtual-threads/src/test/java/io/quarkus/grpc/example/streaming/VirtualThreadTest.java @@ -1,7 +1,11 @@ package io.quarkus.grpc.example.streaming; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; @QuarkusTest +@VirtualThreadUnit +@ShouldNotPin public class VirtualThreadTest extends VirtualThreadTestBase { } diff --git a/integration-tests/virtual-threads/jms-virtual-threads/pom.xml b/integration-tests/virtual-threads/jms-virtual-threads/pom.xml index f31f186aac14d..2c52d9aaa85b5 100644 --- a/integration-tests/virtual-threads/jms-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/jms-virtual-threads/pom.xml @@ -33,10 +33,11 @@ io.quarkus quarkus-smallrye-reactive-messaging + io.smallrye.reactive smallrye-reactive-messaging-jms - 4.9.0 + 4.10.1 io.quarkus @@ -57,6 +58,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured @@ -144,18 +150,6 @@ org.apache.maven.plugins maven-surefire-plugin - - - true - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - true - diff --git a/integration-tests/virtual-threads/jms-virtual-threads/src/main/java/io/quarkus/it/vthreads/jms/PriceConsumer.java b/integration-tests/virtual-threads/jms-virtual-threads/src/main/java/io/quarkus/it/vthreads/jms/PriceConsumer.java index 336974a7c66d8..b74f7dfd7baec 100644 --- a/integration-tests/virtual-threads/jms-virtual-threads/src/main/java/io/quarkus/it/vthreads/jms/PriceConsumer.java +++ b/integration-tests/virtual-threads/jms-virtual-threads/src/main/java/io/quarkus/it/vthreads/jms/PriceConsumer.java @@ -1,6 +1,5 @@ package io.quarkus.it.vthreads.jms; -import static io.quarkus.it.vthreads.jms.AssertHelper.assertThatItDoesNotRunOnVirtualThread; import static io.quarkus.it.vthreads.jms.AssertHelper.assertThatItRunsOnVirtualThread; import java.util.Random; @@ -27,19 +26,15 @@ public class PriceConsumer { public CompletionStage consume(Message msg) { assertThatItRunsOnVirtualThread(); double price = msg.getPayload(); - if (price > 90.0) { - alertService.alertMessage(price); - } - return msg.ack().thenAccept(x -> assertThatItDoesNotRunOnVirtualThread()); + alertService.alertMessage(price); + return msg.ack(); } @Incoming("prices") @RunOnVirtualThread public void consume(double price) { assertThatItRunsOnVirtualThread(); - if (price > 90.0) { - alertService.alert(price); - } + alertService.alert(price); } Random r = new Random(); diff --git a/integration-tests/virtual-threads/jms-virtual-threads/src/test/java/io/quarkus/it/vthreads/jms/NoPinningVerify.java b/integration-tests/virtual-threads/jms-virtual-threads/src/test/java/io/quarkus/it/vthreads/jms/NoPinningVerify.java deleted file mode 100644 index b32c44a8f8a15..0000000000000 --- a/integration-tests/virtual-threads/jms-virtual-threads/src/test/java/io/quarkus/it/vthreads/jms/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.it.vthreads.jms; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/jms-virtual-threads/src/test/java/io/quarkus/it/vthreads/jms/VirtualThreadTest.java b/integration-tests/virtual-threads/jms-virtual-threads/src/test/java/io/quarkus/it/vthreads/jms/VirtualThreadTest.java index bb115b5ea1d3e..39ebce8240846 100644 --- a/integration-tests/virtual-threads/jms-virtual-threads/src/test/java/io/quarkus/it/vthreads/jms/VirtualThreadTest.java +++ b/integration-tests/virtual-threads/jms-virtual-threads/src/test/java/io/quarkus/it/vthreads/jms/VirtualThreadTest.java @@ -13,9 +13,13 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; @QuarkusTest @QuarkusTestResource(WireMockExtension.class) +@VirtualThreadUnit +@ShouldNotPin public class VirtualThreadTest { public static final int EXPECTED_CALLS = 10; diff --git a/integration-tests/virtual-threads/kafka-virtual-threads/pom.xml b/integration-tests/virtual-threads/kafka-virtual-threads/pom.xml index a9fac7750e8ab..16c86a83ad846 100644 --- a/integration-tests/virtual-threads/kafka-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/kafka-virtual-threads/pom.xml @@ -32,6 +32,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured @@ -81,7 +86,8 @@ * - + + io.quarkus quarkus-rest-client-reactive-deployment ${project.version} diff --git a/integration-tests/virtual-threads/kafka-virtual-threads/src/main/java/io/quarkus/it/vthreads/kafka/PriceConsumer.java b/integration-tests/virtual-threads/kafka-virtual-threads/src/main/java/io/quarkus/it/vthreads/kafka/PriceConsumer.java index 8bdf6b7d522c5..f305a3a5f86fc 100644 --- a/integration-tests/virtual-threads/kafka-virtual-threads/src/main/java/io/quarkus/it/vthreads/kafka/PriceConsumer.java +++ b/integration-tests/virtual-threads/kafka-virtual-threads/src/main/java/io/quarkus/it/vthreads/kafka/PriceConsumer.java @@ -28,9 +28,7 @@ public CompletionStage consume(Message msg) { assertThatItRunsOnVirtualThread(); assertThatItRunsOnADuplicatedContext(); double price = msg.getPayload(); - if (price > 90.0) { - alertService.alertMessage(price); - } + alertService.alertMessage(price); return msg.ack().thenAccept(x -> { assertThatItRunsOnADuplicatedContext(); // While the ack always runs on event loop thread @@ -43,9 +41,7 @@ public CompletionStage consume(Message msg) { public void consume(double price) { assertThatItRunsOnVirtualThread(); assertThatItRunsOnADuplicatedContext(); - if (price > 90.0) { - alertService.alert(price); - } + alertService.alert(price); } Random r = new Random(); diff --git a/integration-tests/virtual-threads/kafka-virtual-threads/src/main/resources/application.properties b/integration-tests/virtual-threads/kafka-virtual-threads/src/main/resources/application.properties index f4a4265ca9756..c361e848bc491 100644 --- a/integration-tests/virtual-threads/kafka-virtual-threads/src/main/resources/application.properties +++ b/integration-tests/virtual-threads/kafka-virtual-threads/src/main/resources/application.properties @@ -1,4 +1,4 @@ -price-alert/mp-rest/url=${test.url} +quarkus.rest-client.price-alert.url=${test.url} mp.messaging.incoming.prices.broadcast=true mp.messaging.incoming.prices.auto.offset.reset=earliest mp.messaging.outgoing.prices-out.topic=prices diff --git a/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/NoPinningVerify.java b/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/NoPinningVerify.java deleted file mode 100644 index 69ade96c85ab9..0000000000000 --- a/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.it.vthreads.kafka; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/VirtualThreadTest.java b/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/VirtualThreadTest.java index 547055b00a1f1..ca5060e18aec1 100644 --- a/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/VirtualThreadTest.java +++ b/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/VirtualThreadTest.java @@ -13,9 +13,13 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; @QuarkusTest @QuarkusTestResource(WireMockExtension.class) +@VirtualThreadUnit +@ShouldNotPin public class VirtualThreadTest { public static final int EXPECTED_CALLS = 10; diff --git a/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/WireMockExtension.java b/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/WireMockExtension.java index d081410fb3bb9..1bc68ca338390 100644 --- a/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/WireMockExtension.java +++ b/integration-tests/virtual-threads/kafka-virtual-threads/src/test/java/io/quarkus/it/vthreads/kafka/WireMockExtension.java @@ -24,7 +24,7 @@ public Map start() { wireMockServer.stubFor(post(urlEqualTo("/price/alert-message")) .willReturn(aResponse().withBody("ok"))); - return Map.of("price-alert/mp-rest/url", wireMockServer.baseUrl()); + return Map.of("quarkus.rest-client.price-alert.url", wireMockServer.baseUrl()); } @Override diff --git a/integration-tests/virtual-threads/mailer-virtual-threads/pom.xml b/integration-tests/virtual-threads/mailer-virtual-threads/pom.xml index e567f6a56f49e..9ed5f6e17c566 100644 --- a/integration-tests/virtual-threads/mailer-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/mailer-virtual-threads/pom.xml @@ -28,6 +28,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/mailer-virtual-threads/src/test/java/io/quarkus/virtual/mail/NoPinningVerify.java b/integration-tests/virtual-threads/mailer-virtual-threads/src/test/java/io/quarkus/virtual/mail/NoPinningVerify.java deleted file mode 100644 index 99ce0563fdbb4..0000000000000 --- a/integration-tests/virtual-threads/mailer-virtual-threads/src/test/java/io/quarkus/virtual/mail/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.virtual.mail; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/mailer-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java b/integration-tests/virtual-threads/mailer-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java index d179f04cea365..659dc606b7e4a 100644 --- a/integration-tests/virtual-threads/mailer-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java +++ b/integration-tests/virtual-threads/mailer-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java @@ -8,12 +8,16 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; import io.restassured.RestAssured; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; @QuarkusTest @QuarkusTestResource(MailHogResource.class) +@VirtualThreadUnit +@ShouldNotPin class RunOnVirtualThreadTest { @Test diff --git a/integration-tests/virtual-threads/pom.xml b/integration-tests/virtual-threads/pom.xml index 0e70fcb25a22f..853d39c10638b 100644 --- a/integration-tests/virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/pom.xml @@ -106,19 +106,6 @@ --enable-preview -Djdk.tracePinnedThreads -Dgradle.scan.captureTestLogging=false ${skipTests} - - - pinning-test - - test - - - - NoPinningVerify.java - - - - io.quarkus diff --git a/integration-tests/virtual-threads/quartz-virtual-threads/pom.xml b/integration-tests/virtual-threads/quartz-virtual-threads/pom.xml index ba61edfaeb22b..77a37c7b6e55b 100644 --- a/integration-tests/virtual-threads/quartz-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/quartz-virtual-threads/pom.xml @@ -28,6 +28,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/quartz-virtual-threads/src/test/java/io/quarkus/virtual/mail/NoPinningVerify.java b/integration-tests/virtual-threads/quartz-virtual-threads/src/test/java/io/quarkus/virtual/mail/NoPinningVerify.java deleted file mode 100644 index 99ce0563fdbb4..0000000000000 --- a/integration-tests/virtual-threads/quartz-virtual-threads/src/test/java/io/quarkus/virtual/mail/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.virtual.mail; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/quartz-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java b/integration-tests/virtual-threads/quartz-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java index 7f2bec0ae9ba7..2a6244806d48b 100644 --- a/integration-tests/virtual-threads/quartz-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java +++ b/integration-tests/virtual-threads/quartz-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java @@ -8,10 +8,14 @@ import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; import io.restassured.RestAssured; import io.restassured.common.mapper.TypeRef; @QuarkusTest +@VirtualThreadUnit +@ShouldNotPin class RunOnVirtualThreadTest { @Test diff --git a/integration-tests/virtual-threads/redis-virtual-threads/pom.xml b/integration-tests/virtual-threads/redis-virtual-threads/pom.xml index 0ac0cd3aef8b5..9b333098d0d45 100644 --- a/integration-tests/virtual-threads/redis-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/redis-virtual-threads/pom.xml @@ -32,6 +32,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/redis-virtual-threads/src/test/java/io/quarkus/virtual/redis/NoPinningVerify.java b/integration-tests/virtual-threads/redis-virtual-threads/src/test/java/io/quarkus/virtual/redis/NoPinningVerify.java deleted file mode 100644 index 6490e39a4d387..0000000000000 --- a/integration-tests/virtual-threads/redis-virtual-threads/src/test/java/io/quarkus/virtual/redis/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.virtual.redis; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/redis-virtual-threads/src/test/java/io/quarkus/virtual/redis/RunOnVirtualThreadTest.java b/integration-tests/virtual-threads/redis-virtual-threads/src/test/java/io/quarkus/virtual/redis/RunOnVirtualThreadTest.java index 0b45efdd598d8..e0c7d648457f1 100644 --- a/integration-tests/virtual-threads/redis-virtual-threads/src/test/java/io/quarkus/virtual/redis/RunOnVirtualThreadTest.java +++ b/integration-tests/virtual-threads/redis-virtual-threads/src/test/java/io/quarkus/virtual/redis/RunOnVirtualThreadTest.java @@ -6,9 +6,13 @@ import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; import io.restassured.RestAssured; @QuarkusTest +@VirtualThreadUnit +@ShouldNotPin class RunOnVirtualThreadTest { @Test diff --git a/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/pom.xml b/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/pom.xml index 263ea8ad3342d..d5a26f855ea21 100644 --- a/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/pom.xml @@ -28,6 +28,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rest/NoPinningVerify.java b/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rest/NoPinningVerify.java deleted file mode 100644 index 2eb1d2963110d..0000000000000 --- a/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rest/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.virtual.rest; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rest/RunOnVirtualThreadTest.java b/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rest/RunOnVirtualThreadTest.java index a1b5318ba225a..8ff0ccff1f41c 100644 --- a/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rest/RunOnVirtualThreadTest.java +++ b/integration-tests/virtual-threads/rest-client-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rest/RunOnVirtualThreadTest.java @@ -5,9 +5,13 @@ import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; import io.restassured.RestAssured; @QuarkusTest +@VirtualThreadUnit +@ShouldNotPin class RunOnVirtualThreadTest { @Test diff --git a/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/pom.xml b/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/pom.xml index 2eff569b5e35d..f59e520c0348e 100644 --- a/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/pom.xml @@ -24,6 +24,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rr/NoPinningVerify.java b/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rr/NoPinningVerify.java deleted file mode 100644 index 3dc4cf6e76b2a..0000000000000 --- a/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rr/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.virtual.rr; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rr/RunOnVirtualThreadTest.java b/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rr/RunOnVirtualThreadTest.java index d4562adee1ed9..a2af77a6f9be2 100644 --- a/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rr/RunOnVirtualThreadTest.java +++ b/integration-tests/virtual-threads/resteasy-reactive-virtual-threads/src/test/java/io/quarkus/virtual/rr/RunOnVirtualThreadTest.java @@ -7,9 +7,13 @@ import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; import io.restassured.RestAssured; @QuarkusTest +@VirtualThreadUnit +@ShouldNotPin class RunOnVirtualThreadTest { @Test diff --git a/integration-tests/virtual-threads/scheduler-virtual-threads/pom.xml b/integration-tests/virtual-threads/scheduler-virtual-threads/pom.xml index 0811268cd06e2..0d7b25e3c866a 100644 --- a/integration-tests/virtual-threads/scheduler-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/scheduler-virtual-threads/pom.xml @@ -28,6 +28,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/scheduler-virtual-threads/src/test/java/io/quarkus/virtual/mail/NoPinningVerify.java b/integration-tests/virtual-threads/scheduler-virtual-threads/src/test/java/io/quarkus/virtual/mail/NoPinningVerify.java deleted file mode 100644 index 99ce0563fdbb4..0000000000000 --- a/integration-tests/virtual-threads/scheduler-virtual-threads/src/test/java/io/quarkus/virtual/mail/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.virtual.mail; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/scheduler-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java b/integration-tests/virtual-threads/scheduler-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java index 7f2bec0ae9ba7..2a6244806d48b 100644 --- a/integration-tests/virtual-threads/scheduler-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java +++ b/integration-tests/virtual-threads/scheduler-virtual-threads/src/test/java/io/quarkus/virtual/mail/RunOnVirtualThreadTest.java @@ -8,10 +8,14 @@ import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; import io.restassured.RestAssured; import io.restassured.common.mapper.TypeRef; @QuarkusTest +@VirtualThreadUnit +@ShouldNotPin class RunOnVirtualThreadTest { @Test diff --git a/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/pom.xml b/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/pom.xml index 52ce0825438bf..57617bea7d8fb 100644 --- a/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/pom.xml +++ b/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/pom.xml @@ -24,6 +24,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/src/test/java/io/quarkus/virtual/vertx/NoPinningVerify.java b/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/src/test/java/io/quarkus/virtual/vertx/NoPinningVerify.java deleted file mode 100644 index 84f96f5700fd5..0000000000000 --- a/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/src/test/java/io/quarkus/virtual/vertx/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.virtual.vertx; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/src/test/java/io/quarkus/virtual/vertx/RunOnVirtualThreadTest.java b/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/src/test/java/io/quarkus/virtual/vertx/RunOnVirtualThreadTest.java index 05c3b0516d786..d9dc0285247e6 100644 --- a/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/src/test/java/io/quarkus/virtual/vertx/RunOnVirtualThreadTest.java +++ b/integration-tests/virtual-threads/vertx-event-bus-virtual-threads/src/test/java/io/quarkus/virtual/vertx/RunOnVirtualThreadTest.java @@ -6,9 +6,13 @@ import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; import io.restassured.RestAssured; @QuarkusTest +@VirtualThreadUnit +@ShouldNotPin class RunOnVirtualThreadTest { @Test diff --git a/integration-tests/virtual-threads/virtual-threads-disabled/pom.xml b/integration-tests/virtual-threads/virtual-threads-disabled/pom.xml index 87aff3d36f75c..cf83eb35efc5d 100644 --- a/integration-tests/virtual-threads/virtual-threads-disabled/pom.xml +++ b/integration-tests/virtual-threads/virtual-threads-disabled/pom.xml @@ -24,6 +24,11 @@ quarkus-junit5 test + + io.quarkus.junit5 + junit5-virtual-threads + test + io.rest-assured rest-assured diff --git a/integration-tests/virtual-threads/virtual-threads-disabled/src/test/java/io/quarkus/virtual/disabled/NoPinningVerify.java b/integration-tests/virtual-threads/virtual-threads-disabled/src/test/java/io/quarkus/virtual/disabled/NoPinningVerify.java deleted file mode 100644 index cb1aeee98ce59..0000000000000 --- a/integration-tests/virtual-threads/virtual-threads-disabled/src/test/java/io/quarkus/virtual/disabled/NoPinningVerify.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.quarkus.virtual.disabled; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * An integration test reading the output of the unit test to verify that no tests where pinning the carrier thread. - * It reads the reports generated by surefire. - */ -public class NoPinningVerify { - - @Test - void verify() throws IOException, ParserConfigurationException, SAXException { - var reports = new File("target", "surefire-reports"); - Assertions.assertTrue(reports.isDirectory(), - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - var list = reports.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("TEST") && name.endsWith("Test.xml"); - } - }); - Assertions.assertNotNull(list, - "Unable to find " + reports.getAbsolutePath() + ", did you run the tests with Maven before?"); - - for (File report : list) { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(report); - var suite = document.getFirstChild(); - var cases = getChildren(suite.getChildNodes(), "testcase"); - for (Node c : cases) { - verify(report, c); - } - } - - } - - private void verify(File file, Node ca) { - var fullname = ca.getAttributes().getNamedItem("classname").getTextContent() + "." - + ca.getAttributes().getNamedItem("name").getTextContent(); - var output = getChildren(ca.getChildNodes(), "system-out"); - if (output.isEmpty()) { - return; - } - var sout = output.get(0).getTextContent(); - if (sout.contains("VThreadContinuation.onPinned")) { - throw new AssertionError("The test case " + fullname + " pinned the carrier thread, check " + file.getAbsolutePath() - + " for details (or the log of the test)"); - } - - } - - private List getChildren(NodeList nodes, String name) { - List list = new ArrayList<>(); - for (int i = 0; i < nodes.getLength(); i++) { - var node = nodes.item(i); - if (node.getNodeName().equalsIgnoreCase(name)) { - list.add(node); - } - } - return list; - } - -} diff --git a/integration-tests/virtual-threads/virtual-threads-disabled/src/test/java/io/quarkus/virtual/disabled/RunOnVirtualThreadDisabledTest.java b/integration-tests/virtual-threads/virtual-threads-disabled/src/test/java/io/quarkus/virtual/disabled/RunOnVirtualThreadDisabledTest.java index 4a60c8922bc2f..8fef3565fc1f3 100644 --- a/integration-tests/virtual-threads/virtual-threads-disabled/src/test/java/io/quarkus/virtual/disabled/RunOnVirtualThreadDisabledTest.java +++ b/integration-tests/virtual-threads/virtual-threads-disabled/src/test/java/io/quarkus/virtual/disabled/RunOnVirtualThreadDisabledTest.java @@ -7,9 +7,13 @@ import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit5.virtual.ShouldNotPin; +import io.quarkus.test.junit5.virtual.VirtualThreadUnit; import io.restassured.RestAssured; @QuarkusTest +@VirtualThreadUnit +@ShouldNotPin class RunOnVirtualThreadDisabledTest { @Test