From 768f515f227b909cf551b836ee45e3339809744e Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Mon, 31 Jul 2023 22:02:41 +0100 Subject: [PATCH] Add tests which exercise more complex JUnit extensions (and all fail, so all disabled) Co-Authored-By: Alexey Loubyansky --- .../gradle/FastJarFormatWorksTest.java | 8 +- .../gradle/LegacyJarFormatWorksTest.java | 8 +- .../gradle/MultiModuleUberJarTest.java | 6 +- .../MutableJarFormatBootsInDevModeTest.java | 8 +- .../gradle/QuarkusPluginFunctionalTest.java | 4 +- .../gradle/UberJarFormatWorksTest.java | 8 +- .../devmode/QuarkusDevGradleTestBase.java | 14 +- .../nativeimage/BasicJavaNativeBuildIT.java | 9 +- .../kotlin/maven/it/KotlinDevModeIT.java | 17 +- .../maven/it/KotlinRemoteDevModeIT.java | 5 +- .../java/io/quarkus/maven/it/BuildIT.java | 6 +- .../java/io/quarkus/maven/it/CodeGenIT.java | 3 +- .../quarkus/maven/it/CreateProjectMojoIT.java | 8 +- .../java/io/quarkus/maven/it/DevMojoIT.java | 220 +++++++++--------- .../java/io/quarkus/maven/it/JarRunnerIT.java | 43 ++-- .../io/quarkus/maven/it/NativeImageIT.java | 6 +- .../io/quarkus/maven/it/RemoteDevMojoIT.java | 29 ++- .../java/io/quarkus/maven/it/TestMojoIT.java | 2 +- .../scala/maven/it/ScalaDevModeIT.java | 11 +- .../scala/maven/it/ScalaRemoteDevModeIT.java | 5 +- .../deployment/disable-unbind-executions | 1 + .../deployment/pom.xml | 91 ++++++++ .../acme/deployment/AnnotationAdjuster.java | 30 +++ .../acme/deployment/ExtensionProcessor.java | 51 ++++ .../src/main/resources/application.properties | 193 +++++++++++++++ .../disable-unbind-executions | 1 + .../pom.xml | 39 ++++ .../runtime/disable-unbind-executions | 1 + .../runtime/pom.xml | 139 +++++++++++ .../org/acme/AnnotationAddedByExtension.java | 11 + .../org/acme/AnnotationCountingTestCase.java | 28 +++ .../src/main/java/org/acme/Callback.java | 11 + .../org/acme/CallbackInvokingInterceptor.java | 41 ++++ .../java/org/acme/InjectableParameter.java | 18 ++ .../main/java/org/acme/MyContextProvider.java | 59 +++++ .../java/org/acme/MyParameterResolver.java | 20 ++ integration-tests/test-extension/pom.xml | 1 + .../test-extension/tests/pom.xml | 14 ++ .../extension/it/TestCallbackDevModeIT.java | 65 ++++++ .../extension/it/TestCallbackTestModeIT.java | 75 ++++++ .../extension/it/TestParameterDevModeIT.java | 59 +++++ .../extension/it/TestParameterTestModeIT.java | 69 ++++++ .../extension/it/TestTemplateDevModeIT.java | 65 ++++++ .../extension/it/TestTemplateTestModeIT.java | 75 ++++++ .../pom.xml | 127 ++++++++++ .../main/java/org/acme/InjectableBean.java | 7 + .../resources/META-INF/resources/index.html | 16 ++ .../src/main/resources/application.properties | 1 + .../QuarkusTestAccessingBeanInCallback.java | 42 ++++ .../README.md | 21 ++ .../pom.xml | 127 ++++++++++ .../resources/META-INF/resources/index.html | 15 ++ .../src/main/resources/application.properties | 2 + .../java/org/acme/InjectableQuarkusTest.java | 18 ++ .../pom.xml | 127 ++++++++++ .../resources/META-INF/resources/index.html | 16 ++ .../src/main/resources/application.properties | 1 + .../test/java/org/acme/NormalQuarkusTest.java | 23 ++ .../java/org/acme/TemplatedNormalTest.java | 67 ++++++ .../java/org/acme/TemplatedQuarkusTest.java | 54 +++++ ...vModeTestUtils.java => DevModeClient.java} | 54 +++-- .../io/quarkus/maven/it/MojoTestBase.java | 4 +- .../maven/it/RunAndCheckMojoTestBase.java | 32 ++- .../it/RunAndCheckWithAgentMojoTestBase.java | 8 +- .../ContinuousTestingMavenTestUtils.java | 20 +- .../maven/it/verifier/RunningInvoker.java | 4 +- 66 files changed, 2117 insertions(+), 246 deletions(-) create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/disable-unbind-executions create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/pom.xml create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/java/io/quarkiverse/acme/deployment/AnnotationAdjuster.java create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/java/io/quarkiverse/acme/deployment/ExtensionProcessor.java create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/resources/application.properties create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/disable-unbind-executions create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/pom.xml create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/disable-unbind-executions create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/pom.xml create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/AnnotationAddedByExtension.java create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/AnnotationCountingTestCase.java create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/Callback.java create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/CallbackInvokingInterceptor.java create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/InjectableParameter.java create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/MyContextProvider.java create mode 100644 integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/MyParameterResolver.java create mode 100644 integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestCallbackDevModeIT.java create mode 100644 integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestCallbackTestModeIT.java create mode 100644 integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestParameterDevModeIT.java create mode 100644 integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestParameterTestModeIT.java create mode 100644 integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestTemplateDevModeIT.java create mode 100644 integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestTemplateTestModeIT.java create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/pom.xml create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/java/org/acme/InjectableBean.java create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/resources/META-INF/resources/index.html create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/resources/application.properties create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/test/java/org/acme/QuarkusTestAccessingBeanInCallback.java create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/README.md create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/pom.xml create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/main/resources/META-INF/resources/index.html create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/main/resources/application.properties create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/test/java/org/acme/InjectableQuarkusTest.java create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/pom.xml create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/main/resources/META-INF/resources/index.html create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/main/resources/application.properties create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/NormalQuarkusTest.java create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/TemplatedNormalTest.java create mode 100644 integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/TemplatedQuarkusTest.java rename test-framework/devmode-test-utils/src/main/java/io/quarkus/test/devmode/util/{DevModeTestUtils.java => DevModeClient.java} (83%) diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/FastJarFormatWorksTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/FastJarFormatWorksTest.java index 6bfa73d0c71a2..45e99a9cd222b 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/FastJarFormatWorksTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/FastJarFormatWorksTest.java @@ -13,7 +13,7 @@ import org.awaitility.core.ConditionTimeoutException; import org.junit.jupiter.api.Test; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public class FastJarFormatWorksTest extends QuarkusGradleWrapperTestBase { @@ -31,6 +31,8 @@ public void testFastJarFormatWorks() throws Exception { File output = new File(projectDir, "build/output.log"); output.createNewFile(); + + DevModeClient devModeClient = new DevModeClient(); Process process = launch(jar, output); try { //Wait until server up @@ -38,7 +40,7 @@ public void testFastJarFormatWorks() throws Exception { await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.isCode("/hello", 200)); + .until(() -> devModeClient.isCode("/hello", 200)); return null; }, output, ConditionTimeoutException.class); @@ -47,7 +49,7 @@ public void testFastJarFormatWorks() throws Exception { assertThat(logs).contains("INFO").contains("cdi, resteasy"); // test that the application name and version are properly set - assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/hello")).isEqualTo("hello"); } finally { process.destroy(); } diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/LegacyJarFormatWorksTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/LegacyJarFormatWorksTest.java index 33145777bd0c9..4166616bd2154 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/LegacyJarFormatWorksTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/LegacyJarFormatWorksTest.java @@ -13,7 +13,7 @@ import org.awaitility.core.ConditionTimeoutException; import org.junit.jupiter.api.Test; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public class LegacyJarFormatWorksTest extends QuarkusGradleWrapperTestBase { @@ -31,13 +31,15 @@ public void testLegacyJarFormatWorks() throws Exception { File output = new File(projectDir, "build/output.log"); output.createNewFile(); Process process = launch(runnerJar, output); + DevModeClient devModeClient = new DevModeClient(); + try { //Wait until server up dumpFileContentOnFailure(() -> { await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.isCode("/hello", 200)); + .until(() -> devModeClient.isCode("/hello", 200)); return null; }, output, ConditionTimeoutException.class); @@ -46,7 +48,7 @@ public void testLegacyJarFormatWorks() throws Exception { assertThat(logs).contains("INFO").contains("cdi, resteasy"); // test that the application name and version are properly set - assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/hello")).isEqualTo("hello"); } finally { process.destroy(); } diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/MultiModuleUberJarTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/MultiModuleUberJarTest.java index 7c8fca2aca04d..8ab01f5ee17c2 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/MultiModuleUberJarTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/MultiModuleUberJarTest.java @@ -13,7 +13,7 @@ import org.awaitility.core.ConditionTimeoutException; import org.junit.jupiter.api.Test; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public class MultiModuleUberJarTest extends QuarkusGradleWrapperTestBase { @@ -30,6 +30,8 @@ public void testUberJarForMultiModule() throws Exception { File output = new File(projectDir, "application/build/output.log"); output.createNewFile(); + DevModeClient devModeClient = new DevModeClient(); + Process process = launch(jar, output); try { // Wait until server up @@ -37,7 +39,7 @@ public void testUberJarForMultiModule() throws Exception { await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.isCode("/hello", 200)); + .until(() -> devModeClient.isCode("/hello", 200)); return null; }, output, ConditionTimeoutException.class); diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/MutableJarFormatBootsInDevModeTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/MutableJarFormatBootsInDevModeTest.java index ed04a90f9c6e0..ff3104986a2d1 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/MutableJarFormatBootsInDevModeTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/MutableJarFormatBootsInDevModeTest.java @@ -14,7 +14,7 @@ import org.awaitility.core.ConditionTimeoutException; import org.junit.jupiter.api.Test; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public class MutableJarFormatBootsInDevModeTest extends QuarkusGradleWrapperTestBase { @@ -32,6 +32,8 @@ public void testFastJarFormatWorks() throws Exception { File output = new File(projectDir, "build/output.log"); output.createNewFile(); + DevModeClient devModeClient = new DevModeClient(); + Process process = launch(jar, output, Collections.singletonMap("QUARKUS_LAUNCH_DEVMODE", "true")); try { //Wait until server up @@ -39,7 +41,7 @@ public void testFastJarFormatWorks() throws Exception { await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.isCode("/hello", 200)); + .until(() -> devModeClient.isCode("/hello", 200)); return null; }, output, ConditionTimeoutException.class); @@ -48,7 +50,7 @@ public void testFastJarFormatWorks() throws Exception { assertThat(logs).contains("INFO").contains("cdi, resteasy"); // test that the application name and version are properly set - assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/hello")).isEqualTo("hello"); } finally { process.destroy(); } diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java index 0530f130015ca..3cade3a2cc720 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/QuarkusPluginFunctionalTest.java @@ -23,7 +23,7 @@ import io.quarkus.devtools.project.BuildTool; import io.quarkus.devtools.project.QuarkusProjectHelper; import io.quarkus.devtools.project.SourceType; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public class QuarkusPluginFunctionalTest extends QuarkusGradleDevToolsTestBase { @@ -84,7 +84,7 @@ public void canDetectClassChangeWhenBuilding() throws Exception { final File greetingResourceFile = projectRoot.toPath().resolve("src/main/java/org/acme/foo/GreetingResource.java") .toFile(); - DevModeTestUtils.filter(greetingResourceFile, ImmutableMap.of("\"/greeting\"", "\"/test/hello\"")); + DevModeClient.filter(greetingResourceFile, ImmutableMap.of("\"/greeting\"", "\"/test/hello\"")); BuildResult secondBuild = runGradleWrapper(projectRoot, "quarkusBuild"); assertThat(BuildResult.isSuccessful(secondBuild.getTasks().get(":quarkusBuild"))).isTrue(); diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/UberJarFormatWorksTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/UberJarFormatWorksTest.java index d17b9906ebd59..5a7347963d26e 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/UberJarFormatWorksTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/UberJarFormatWorksTest.java @@ -13,7 +13,7 @@ import org.awaitility.core.ConditionTimeoutException; import org.junit.jupiter.api.Test; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public class UberJarFormatWorksTest extends QuarkusGradleWrapperTestBase { @@ -29,6 +29,8 @@ public void testUberJarFormatWorks() throws Exception { File output = new File(projectDir, "build/output.log"); output.createNewFile(); + DevModeClient devModeClient = new DevModeClient(); + Process process = launch(jar, output); try { // Wait until server up @@ -36,7 +38,7 @@ public void testUberJarFormatWorks() throws Exception { await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.isCode("/hello", 200)); + .until(() -> devModeClient.isCode("/hello", 200)); return null; }, output, ConditionTimeoutException.class); @@ -45,7 +47,7 @@ public void testUberJarFormatWorks() throws Exception { assertThat(logs).contains("INFO").contains("cdi, resteasy"); // test that the application name and version are properly set - assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/hello")).isEqualTo("hello"); } finally { process.destroy(); } diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/QuarkusDevGradleTestBase.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/QuarkusDevGradleTestBase.java index 2602e2e0e502f..cad11217f4043 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/QuarkusDevGradleTestBase.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/QuarkusDevGradleTestBase.java @@ -25,13 +25,15 @@ import io.quarkus.gradle.BuildResult; import io.quarkus.gradle.QuarkusGradleWrapperTestBase; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public abstract class QuarkusDevGradleTestBase extends QuarkusGradleWrapperTestBase { private Future quarkusDev; protected File projectDir; + protected DevModeClient devModeClient = new DevModeClient(); + @Override protected void setupTestCommand() { gradleNoWatchFs(false); @@ -67,9 +69,9 @@ public void main() throws Exception { } // Kill all processes that were (indirectly) spawned by the current process. - List childProcesses = DevModeTestUtils.killDescendingProcesses(); + List childProcesses = DevModeClient.killDescendingProcesses(); - DevModeTestUtils.awaitUntilServerDown(); + devModeClient.awaitUntilServerDown(); // sanity: forcefully terminate left-over processes childProcesses.forEach(ProcessHandle::destroyForcibly); @@ -151,7 +153,7 @@ protected void beforeQuarkusDev() throws Exception { protected abstract void testDevMode() throws Exception; protected String getHttpResponse() { - return DevModeTestUtils.getHttpResponse(getQuarkusDevBrokenReason()); + return devModeClient.getHttpResponse(getQuarkusDevBrokenReason()); } protected String getHttpResponse(String path) { @@ -159,7 +161,7 @@ protected String getHttpResponse(String path) { } protected String getHttpResponse(String path, long timeout, TimeUnit tu) { - return DevModeTestUtils.getHttpResponse(path, false, getQuarkusDevBrokenReason(), timeout, tu); + return devModeClient.getHttpResponse(path, false, getQuarkusDevBrokenReason(), timeout, tu); } private Supplier getQuarkusDevBrokenReason() { @@ -172,7 +174,7 @@ protected void replace(String srcFile, Map tokens) { final File source = new File(getProjectDir(), srcFile); assertThat(source).exists(); try { - DevModeTestUtils.filter(source, tokens); + DevModeClient.filter(source, tokens); } catch (IOException e) { throw new IllegalStateException("Failed to replace tokens in " + source, e); } diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/BasicJavaNativeBuildIT.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/BasicJavaNativeBuildIT.java index 373ce3ecae800..28c01e9c43934 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/BasicJavaNativeBuildIT.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/BasicJavaNativeBuildIT.java @@ -9,11 +9,12 @@ import org.junit.jupiter.api.Test; import io.quarkus.gradle.BuildResult; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public class BasicJavaNativeBuildIT extends QuarkusNativeGradleITBase { public static final String NATIVE_IMAGE_NAME = "foo-1.0.0-SNAPSHOT-runner"; + private DevModeClient devModeClient = new DevModeClient(); @Test public void shouldBuildNativeImage() throws Exception { @@ -33,7 +34,7 @@ public void shouldBuildNativeImage() throws Exception { assertThat(nativeImagePath).exists(); Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString()); try { - final String response = DevModeTestUtils.getHttpResponse("/hello"); + final String response = devModeClient.getHttpResponse("/hello"); assertThat(response) .withFailMessage("Response %s for /hello was expected to contain the hello, but didn't", response) .contains("hello"); @@ -63,7 +64,7 @@ public void shouldBuildNativeImageWithCustomName() throws Exception { assertThat(nativeImagePath).exists(); Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString()); try { - final String response = DevModeTestUtils.getHttpResponse("/hello"); + final String response = devModeClient.getHttpResponse("/hello"); assertThat(response) .withFailMessage("Response %s for /hello was expected to contain the hello, but didn't", response) .contains("hello"); @@ -93,7 +94,7 @@ public void shouldBuildNativeImageWithCustomNameWithoutSuffix() throws Exception assertThat(nativeImagePath).exists(); Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString()); try { - final String response = DevModeTestUtils.getHttpResponse("/hello"); + final String response = devModeClient.getHttpResponse("/hello"); assertThat(response) .withFailMessage("Response %s for /hello was expected to contain the hello, but didn't", response) .contains("hello"); diff --git a/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinDevModeIT.java b/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinDevModeIT.java index 6907db97dff4c..bd73f32a845b3 100644 --- a/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinDevModeIT.java +++ b/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinDevModeIT.java @@ -13,7 +13,6 @@ import org.junit.jupiter.api.Test; import io.quarkus.maven.it.RunAndCheckMojoTestBase; -import io.quarkus.test.devmode.util.DevModeTestUtils; public class KotlinDevModeIT extends RunAndCheckMojoTestBase { @@ -30,7 +29,7 @@ public void testThatTheApplicationIsReloadedOnKotlinChange() throws MavenInvocat // Wait until we get "uuid" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); await() .pollDelay(1, TimeUnit.SECONDS) @@ -42,7 +41,7 @@ public void testThatTheApplicationIsReloadedOnKotlinChange() throws MavenInvocat // Wait until we get "carambar" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("carambar")); File greetingService = new File(testDir, "src/main/kotlin/org/acme/GreetingService.kt"); String newUuid = UUID.randomUUID().toString(); @@ -51,7 +50,7 @@ public void testThatTheApplicationIsReloadedOnKotlinChange() throws MavenInvocat // Wait until we get "newUuid" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello/bean").contains(newUuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello/bean").contains(newUuid)); } @Test @@ -68,11 +67,11 @@ public void testThatTheApplicationIsReloadedOnKotlinChangeWithCustomCompilerArgs // Wait until we get "uuid" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/graphql/schema.graphql").contains("[Banana!]!")); + .until(() -> devModeClient.getHttpResponse("/graphql/schema.graphql").contains("[Banana!]!")); } @Test @@ -94,7 +93,7 @@ public void testExternalKotlinReloadableArtifacts() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Hello")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("Hello")); final File greetingKotlin = externalJarDir.toPath().resolve("src").resolve("main") .resolve("kotlin").resolve("org").resolve("acme").resolve("lib") @@ -117,7 +116,7 @@ public void testExternalKotlinReloadableArtifacts() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Bonjour")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("Bonjour")); // Change bonjour() method content in Greeting.kt filter(greetingKotlin, Map.of("Bonjour", "Bonjour!")); @@ -129,6 +128,6 @@ public void testExternalKotlinReloadableArtifacts() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("BONJOUR!")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("BONJOUR!")); } } \ No newline at end of file diff --git a/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinRemoteDevModeIT.java b/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinRemoteDevModeIT.java index 8663a2c5083b5..197f330746ce7 100644 --- a/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinRemoteDevModeIT.java +++ b/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinRemoteDevModeIT.java @@ -12,7 +12,6 @@ import org.junit.jupiter.api.Test; import io.quarkus.maven.it.RunAndCheckWithAgentMojoTestBase; -import io.quarkus.test.devmode.util.DevModeTestUtils; public class KotlinRemoteDevModeIT extends RunAndCheckWithAgentMojoTestBase { @@ -31,7 +30,7 @@ public void testThatTheApplicationIsReloadedOnKotlinChange() // Wait until we get "uuid" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(3, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(3, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); await() .pollDelay(1, TimeUnit.SECONDS) @@ -43,6 +42,6 @@ public void testThatTheApplicationIsReloadedOnKotlinChange() // Wait until we get "carambar" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(3, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar")); + .atMost(3, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("carambar")); } } diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/BuildIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/BuildIT.java index 5fc605a235fb7..d2afe705aa134 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/BuildIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/BuildIT.java @@ -23,11 +23,13 @@ import io.quarkus.maven.it.verifier.MavenProcessInvocationResult; import io.quarkus.maven.it.verifier.RunningInvoker; import io.quarkus.runtime.configuration.ProfileManager; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; @DisableForNative class BuildIT extends MojoTestBase { + private DevModeClient devModeClient = new DevModeClient(); + private RunningInvoker running; private File testDir; @@ -206,7 +208,7 @@ private void launch(TestContext context, String path, File testDir, String outpu List.of()) .start(); try { - Assertions.assertEquals(expectedMessage, DevModeTestUtils.getHttpResponse(path)); + Assertions.assertEquals(expectedMessage, devModeClient.getHttpResponse(path)); } finally { process.destroy(); } diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CodeGenIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CodeGenIT.java index 238403ad583cc..d8bef57773094 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CodeGenIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CodeGenIT.java @@ -13,7 +13,6 @@ import io.quarkus.maven.it.verifier.MavenProcessInvocationResult; import io.quarkus.maven.it.verifier.RunningInvoker; -import io.quarkus.test.devmode.util.DevModeTestUtils; /** *

@@ -28,7 +27,7 @@ public class CodeGenIT extends RunAndCheckMojoTestBase { public void shouldCompileAndRunWithCodegenEnabled() throws MavenInvocationException, FileNotFoundException { testDir = initProject("projects/proto-gen"); run(true); - assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("Hello, World!"); + assertThat(devModeClient.getHttpResponse("/hello")).isEqualTo("Hello, World!"); } @Test diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java index 16b859cf388da..39ba3756cf3af 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java @@ -41,7 +41,7 @@ import io.quarkus.maven.it.verifier.RunningInvoker; import io.quarkus.maven.utilities.MojoUtils; import io.quarkus.platform.tools.ToolsConstants; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; /** * @author Clement Escoffier @@ -49,6 +49,8 @@ @DisableForNative public class CreateProjectMojoIT extends QuarkusPlatformAwareMojoTestBase { + private DevModeClient devModeClient = new DevModeClient(); + private Invoker invoker; private RunningInvoker running; private File testDir; @@ -588,13 +590,13 @@ public void generateNewProjectAndRun() throws Exception { mvnRunProps.setProperty("debug", "false"); running.execute(Arrays.asList("compile", "quarkus:dev"), Collections.emptyMap(), mvnRunProps); - String resp = DevModeTestUtils.getHttpResponse(); + String resp = devModeClient.getHttpResponse(); assertThat(resp).containsIgnoringCase("Congratulations!").containsIgnoringCase("application") .containsIgnoringCase("org.acme") .containsIgnoringCase("1.0.0-SNAPSHOT"); - String greeting = DevModeTestUtils.getHttpResponse("/hello"); + String greeting = devModeClient.getHttpResponse("/hello"); assertThat(greeting).containsIgnoringCase("hello"); } diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java index ca28ff54755dc..041fa9eade9e6 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/DevMojoIT.java @@ -42,11 +42,11 @@ import io.quarkus.maven.it.continuoustesting.ContinuousTestingMavenTestUtils; import io.quarkus.maven.it.verifier.MavenProcessInvocationResult; import io.quarkus.maven.it.verifier.RunningInvoker; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; import io.restassured.RestAssured; /** - * Tests the quarkus:test mojo. + * Tests tests in the quarkus:dev mojo. * * @author Clement Escoffier *

@@ -57,6 +57,8 @@ @DisableForNative public class DevMojoIT extends LaunchMojoTestBase { + protected DevModeClient devModeClient = new DevModeClient(getPort()); + @Override protected ContinuousTestingMavenTestUtils getTestingTestUtils() { return new ContinuousTestingMavenTestUtils(); @@ -66,18 +68,18 @@ protected ContinuousTestingMavenTestUtils getTestingTestUtils() { public void testFlattenedPomInTargetDir() throws MavenInvocationException, IOException { testDir = initProject("projects/pom-in-target-dir"); run(true); - assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("Hello from RESTEasy Reactive"); + assertThat(devModeClient.getHttpResponse("/hello")).isEqualTo("Hello from RESTEasy Reactive"); } @Test public void testConfigFactoryInAppModuleBannedInCodeGen() throws MavenInvocationException, IOException { testDir = initProject("projects/codegen-config-factory", "projects/codegen-config-factory-banned"); run(true); - assertThat(DevModeTestUtils.getHttpResponse("/codegen-config/acme-config-factory")).isEqualTo("n/a"); - assertThat(DevModeTestUtils.getHttpResponse("/codegen-config/acme-config-provider")).isEqualTo("n/a"); - assertThat(DevModeTestUtils.getHttpResponse("/runtime-config/acme-config-factory")) + assertThat(devModeClient.getHttpResponse("/codegen-config/acme-config-factory")).isEqualTo("n/a"); + assertThat(devModeClient.getHttpResponse("/codegen-config/acme-config-provider")).isEqualTo("n/a"); + assertThat(devModeClient.getHttpResponse("/runtime-config/acme-config-factory")) .isEqualTo("org.acme.AppConfigSourceFactory"); - assertThat(DevModeTestUtils.getHttpResponse("/runtime-config/acme-config-provider")) + assertThat(devModeClient.getHttpResponse("/runtime-config/acme-config-provider")) .isEqualTo("org.acme.AppConfigSourceProvider"); } @@ -85,13 +87,13 @@ public void testConfigFactoryInAppModuleBannedInCodeGen() throws MavenInvocation public void testConfigFactoryInAppModuleFilteredInCodeGen() throws MavenInvocationException, IOException { testDir = initProject("projects/codegen-config-factory", "projects/codegen-config-factory-filtered"); run(true, "-Dconfig-factory.enabled"); - assertThat(DevModeTestUtils.getHttpResponse("/codegen-config/acme-config-factory")) + assertThat(devModeClient.getHttpResponse("/codegen-config/acme-config-factory")) .isEqualTo("org.acme.config.AcmeConfigSourceFactory"); - assertThat(DevModeTestUtils.getHttpResponse("/codegen-config/acme-config-provider")) + assertThat(devModeClient.getHttpResponse("/codegen-config/acme-config-provider")) .isEqualTo("org.acme.config.AcmeConfigSourceProvider"); - assertThat(DevModeTestUtils.getHttpResponse("/runtime-config/acme-config-factory")) + assertThat(devModeClient.getHttpResponse("/runtime-config/acme-config-factory")) .isEqualTo("org.acme.AppConfigSourceFactory"); - assertThat(DevModeTestUtils.getHttpResponse("/runtime-config/acme-config-provider")) + assertThat(devModeClient.getHttpResponse("/runtime-config/acme-config-provider")) .isEqualTo("org.acme.AppConfigSourceProvider"); } @@ -99,14 +101,14 @@ public void testConfigFactoryInAppModuleFilteredInCodeGen() throws MavenInvocati public void testSystemPropertiesConfig() throws MavenInvocationException, IOException { testDir = initProject("projects/dev-mode-sys-props-config"); run(true); - assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello, out there"); + assertThat(devModeClient.getHttpResponse("/hello")).isEqualTo("hello, out there"); } @Test public void testEnvironmentVariablesConfig() throws MavenInvocationException, IOException { testDir = initProject("projects/dev-mode-env-vars-config"); run(true); - assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello, WORLD"); + assertThat(devModeClient.getHttpResponse("/hello")).isEqualTo("hello, WORLD"); } @Test @@ -114,7 +116,7 @@ void testClassLoaderLinkageError() throws MavenInvocationException, IOException { testDir = initProject("projects/classloader-linkage-error", "projects/classloader-linkage-error-dev"); run(true); - assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/hello")).isEqualTo("hello"); } @Test @@ -129,14 +131,14 @@ public void testCapabilitiesConflict() throws MavenInvocationException, IOExcept final CapabilityErrors error = new CapabilityErrors(); error.addConflict("sunshine", "org.acme:alt-quarkus-ext:1.0-SNAPSHOT"); error.addConflict("sunshine", "org.acme:acme-quarkus-ext:1.0-SNAPSHOT"); - String response = DevModeTestUtils.getHttpResponse("/hello", true); + String response = devModeClient.getHttpResponse("/hello", true); assertThat(response).contains(error.report()); filter(runnerPom, Map.of("acme-quarkus-ext", "alt-quarkus-ext")); - assertThat(DevModeTestUtils.getHttpResponse("/hello", false)).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/hello", false)).isEqualTo("hello"); filter(runnerPom, Map.of("alt-quarkus-ext", "acme-quarkus-ext")); - assertThat(DevModeTestUtils.getHttpResponse("/hello", false)).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/hello", false)).isEqualTo("hello"); } @Test @@ -150,7 +152,7 @@ public void testCapabilitiesMissing() throws MavenInvocationException, IOExcepti final CapabilityErrors error = new CapabilityErrors(); error.addMissing("sunshine", "org.acme:acme-quarkus-ext:1.0-SNAPSHOT"); - String response = DevModeTestUtils.getHttpResponse("/hello", true); + String response = devModeClient.getHttpResponse("/hello", true); assertThat(response).contains(error.report()); final StringWriter buf = new StringWriter(); @@ -166,7 +168,7 @@ public void testCapabilitiesMissing() throws MavenInvocationException, IOExcepti } final String acmeDep = buf.toString(); filter(runnerPom, Collections.singletonMap("", acmeDep)); - assertThat(DevModeTestUtils.getHttpResponse("/hello", false)).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/hello", false)).isEqualTo("hello"); } @Test @@ -179,7 +181,7 @@ public void testPropertyOverridesTest() throws MavenInvocationException, IOExcep public void testSystemPropertyWithSpacesOnCommandLine() throws MavenInvocationException, IOException { testDir = initProject("projects/classic", "projects/project-classic-prop-with-spaces"); runAndCheck("-Dgreeting=\"1 2 3\""); - final String greeting = DevModeTestUtils.getHttpResponse("/app/hello/greeting"); + final String greeting = devModeClient.getHttpResponse("/app/hello/greeting"); assertThat(greeting).isEqualTo("1 2 3"); } @@ -241,15 +243,15 @@ public void testThatClassAppCanRun() throws MavenInvocationException, IOExceptio runAndCheck(); //make sure that the Class.getPackage() works for app classes - String pkg = DevModeTestUtils.getHttpResponse("/app/hello/package"); + String pkg = devModeClient.getHttpResponse("/app/hello/package"); assertThat(pkg).isEqualTo("org.acme"); //make sure the proper profile is set - String profile = DevModeTestUtils.getHttpResponse("/app/hello/profile"); + String profile = devModeClient.getHttpResponse("/app/hello/profile"); assertThat(profile).isEqualTo("dev"); //make sure webjars work - DevModeTestUtils.getHttpResponse("webjars/jquery-ui/1.13.0/jquery-ui.min.js"); + devModeClient.getHttpResponse("webjars/jquery-ui/1.13.0/jquery-ui.min.js"); assertThatOutputWorksCorrectly(running.log()); @@ -263,7 +265,7 @@ public void testThatResteasyWithoutUndertowCanRun() throws MavenInvocationExcept //make sure that a simple HTTP GET request always works IntStream.range(0, 10).forEach(i -> { - assertThat(DevModeTestUtils.getStrictHttpResponse("/hello", 200)).isTrue(); + assertThat(devModeClient.getStrictHttpResponse("/hello", 200)).isTrue(); }); } @@ -284,7 +286,7 @@ public void testThatInitialMavenResourceFilteringWorks() throws MavenInvocationE //make sure that a simple HTTP GET request always works IntStream.range(0, 10).forEach(i -> { - assertThat(DevModeTestUtils.getStrictHttpResponse("/hello", 200)).isTrue(); + assertThat(devModeClient.getStrictHttpResponse("/hello", 200)).isTrue(); }); //try to open the copied test.zip (which will fail if it was filtered) @@ -308,7 +310,7 @@ public void testThatTheApplicationIsReloadedOnJavaChange() throws MavenInvocatio // Wait until we get "uuid" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); await() .pollDelay(100, TimeUnit.MILLISECONDS) @@ -320,7 +322,7 @@ public void testThatTheApplicationIsReloadedOnJavaChange() throws MavenInvocatio // Wait until we get "carambar" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("carambar")); } @Test @@ -347,7 +349,7 @@ public void testThatNonExistentSrcDirCanBeAdded() throws MavenInvocationExceptio runAndCheck(); hello.delete(); - if (!DevModeTestUtils.getHttpResponse("/app/hello", 404)) { + if (!devModeClient.getHttpResponse("/app/hello", 404)) { Assertions.fail("expected resource to be deleted"); } if (!sourceDirMoved.renameTo(sourceDir)) { @@ -357,7 +359,7 @@ public void testThatNonExistentSrcDirCanBeAdded() throws MavenInvocationExceptio // Wait until we get "hello" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("hello")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("hello")); } @Test @@ -369,7 +371,7 @@ public void testThatInstrumentationBasedReloadWorks() throws MavenInvocationExce RestAssured.post("/q/dev-v1/io.quarkus.quarkus-vertx-http/tests/toggle-instrumentation").then().statusCode(200); //if there is an instrumentation based reload this will stay the same - String firstUuid = DevModeTestUtils.getHttpResponse("/app/uuid"); + String firstUuid = devModeClient.getHttpResponse("/app/uuid"); // Edit the "Hello" message. File source = new File(testDir, "src/main/java/org/acme/HelloResource.java"); @@ -379,10 +381,10 @@ public void testThatInstrumentationBasedReloadWorks() throws MavenInvocationExce // Wait until we get "uuid" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); //verify that this was an instrumentation based reload - Assertions.assertEquals(firstUuid, DevModeTestUtils.getHttpResponse("/app/uuid")); + Assertions.assertEquals(firstUuid, devModeClient.getHttpResponse("/app/uuid")); source = new File(testDir, "src/main/java/org/acme/HelloService.java"); filter(source, Collections.singletonMap("\"Stuart\"", "\"Stuart Douglas\"")); @@ -391,10 +393,10 @@ public void testThatInstrumentationBasedReloadWorks() throws MavenInvocationExce await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/name").contains("Stuart Douglas")); + .until(() -> devModeClient.getHttpResponse("/app/name").contains("Stuart Douglas")); //this bean observes startup event, so it should be different UUID - String secondUUid = DevModeTestUtils.getHttpResponse("/app/uuid"); + String secondUUid = devModeClient.getHttpResponse("/app/uuid"); Assertions.assertNotEquals(secondUUid, firstUuid); //now disable instrumentation based restart, and try again @@ -406,11 +408,11 @@ public void testThatInstrumentationBasedReloadWorks() throws MavenInvocationExce // Wait until we get "hello" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("hello")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("hello")); //verify that this was not instrumentation based reload - Assertions.assertNotEquals(secondUUid, DevModeTestUtils.getHttpResponse("/app/uuid")); - secondUUid = DevModeTestUtils.getHttpResponse("/app/uuid"); + Assertions.assertNotEquals(secondUUid, devModeClient.getHttpResponse("/app/uuid")); + secondUUid = devModeClient.getHttpResponse("/app/uuid"); //now re-enable //and repeat @@ -421,10 +423,10 @@ public void testThatInstrumentationBasedReloadWorks() throws MavenInvocationExce // Wait until we get uuid await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); //verify that this was an instrumentation based reload - Assertions.assertEquals(secondUUid, DevModeTestUtils.getHttpResponse("/app/uuid")); + Assertions.assertEquals(secondUUid, devModeClient.getHttpResponse("/app/uuid")); // verify that add + change results in full reload // add a new class @@ -438,11 +440,11 @@ public void testThatInstrumentationBasedReloadWorks() throws MavenInvocationExce // Wait until we get "hello" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("hello")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("hello")); //verify that this was not instrumentation based reload - Assertions.assertNotEquals(secondUUid, DevModeTestUtils.getHttpResponse("/app/uuid")); - secondUUid = DevModeTestUtils.getHttpResponse("/app/uuid"); + Assertions.assertNotEquals(secondUUid, devModeClient.getHttpResponse("/app/uuid")); + secondUUid = devModeClient.getHttpResponse("/app/uuid"); } @@ -472,12 +474,12 @@ public void testThatSourceChangesAreDetectedOnPomChange() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("hello " + uuid)); + .until(() -> devModeClient.getHttpResponse("/app/hello").contains("hello " + uuid)); await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greeting").contains(uuid)); + .until(() -> devModeClient.getHttpResponse("/app/hello/greeting").contains(uuid)); } @@ -503,11 +505,11 @@ public void testAlternatePom() throws Exception { " ")); runAndCheck(); - assertThat(DevModeTestUtils.getHttpResponse("/q/openapi", true)).contains("Resource not found"); + assertThat(devModeClient.getHttpResponse("/q/openapi", true)).contains("Resource not found"); shutdownTheApp(); runAndCheck("-f", alternatePomName); - DevModeTestUtils.getHttpResponse("/q/openapi").contains("hello"); + devModeClient.getHttpResponse("/q/openapi").contains("hello"); } @Test @@ -526,7 +528,7 @@ public void testThatTheApplicationIsReloadedOnPomChange() throws MavenInvocation // Wait until we get "uuid" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/q/openapi").contains("hello")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/q/openapi").contains("hello")); } @Test @@ -572,7 +574,7 @@ public void testRestClientCustomHeadersExtension() throws MavenInvocationExcepti assertTrue(artifacts.contains("- org.acme:rest-client-custom-headers-deployment:1.0-SNAPSHOT")); assertEquals(2, artifacts.size()); - assertThat(DevModeTestUtils.getHttpResponse("/app/frontend")).isEqualTo("CustomValue1 CustomValue2"); + assertThat(devModeClient.getHttpResponse("/app/frontend")).isEqualTo("CustomValue1 CustomValue2"); } @Test @@ -585,7 +587,7 @@ public void testThatTheApplicationIsReloadedMultiModule() throws MavenInvocation await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(5, TimeUnit.SECONDS) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/resourcesCount").equals("1")); + .until(() -> devModeClient.getHttpResponse("/app/hello/resourcesCount").equals("1")); ContinuousTestingMavenTestUtils testingTestUtils = new ContinuousTestingMavenTestUtils(); ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion(); @@ -601,7 +603,7 @@ public void testThatTheApplicationIsReloadedMultiModule() throws MavenInvocation // Wait until we get "uuid" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); await() .pollDelay(100, TimeUnit.MILLISECONDS) @@ -628,7 +630,7 @@ public void testThatTheApplicationIsReloadedMultiModule() throws MavenInvocation // Wait until we get "carambar" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("carambar")); // Create a new resource source = new File(testDir, "html/src/main/resources/META-INF/resources/lorem.txt"); @@ -638,21 +640,21 @@ public void testThatTheApplicationIsReloadedMultiModule() throws MavenInvocation await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/lorem.txt").contains("Lorem ipsum")); + .until(() -> devModeClient.getHttpResponse("/lorem.txt").contains("Lorem ipsum")); // Update the resource FileUtils.write(source, uuid, "UTF-8"); await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/lorem.txt").contains(uuid)); + .until(() -> devModeClient.getHttpResponse("/lorem.txt").contains(uuid)); // Delete the resource source.delete(); await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/lorem.txt", 404)); + .until(() -> devModeClient.getHttpResponse("/lorem.txt", 404)); } @Test @@ -660,7 +662,7 @@ public void testMultiModuleDevModeWithLocalDepsDisabled() throws MavenInvocation testDir = initProject("projects/multimodule", "projects/multimodule-nodeps"); runAndCheck("-DnoDeps"); - String greeting = DevModeTestUtils.getHttpResponse("/app/hello/greeting"); + String greeting = devModeClient.getHttpResponse("/app/hello/greeting"); assertThat(greeting).containsIgnoringCase("bonjour"); // Edit the "Hello" message. @@ -676,9 +678,9 @@ public void testMultiModuleDevModeWithLocalDepsDisabled() throws MavenInvocation await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greeting").contains(uuid)); + .until(() -> devModeClient.getHttpResponse("/app/hello/greeting").contains(uuid)); - greeting = DevModeTestUtils.getHttpResponse("/app/hello"); + greeting = devModeClient.getHttpResponse("/app/hello"); assertThat(greeting).containsIgnoringCase("hello"); } @@ -697,7 +699,7 @@ public void testMultiModuleProjectWithRevisionVersion() throws MavenInvocationEx // Wait until we get "uuid" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); await() .pollDelay(100, TimeUnit.MILLISECONDS) @@ -712,7 +714,7 @@ public void testTestScopedLocalProjectDependency() throws MavenInvocationExcepti run(true, "-Dquarkus.platform.version=" + projectVersion, "-Dquarkus-plugin.version=" + projectVersion); - assertEquals("Test class is not visible", DevModeTestUtils.getHttpResponse("/hello")); + assertEquals("Test class is not visible", devModeClient.getHttpResponse("/hello")); } @Test @@ -742,7 +744,7 @@ public void testThatTheApplicationIsReloadedOnNewResource() throws MavenInvocati // Wait until we get "bar" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/foo").contains("bar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/foo").contains("bar")); } @Test @@ -778,7 +780,7 @@ public void testThatClassFileAreCleanedUp() throws MavenInvocationException, IOE await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/deletion").contains("to be deleted")); + .until(() -> devModeClient.getHttpResponse("/app/deletion").contains("to be deleted")); // Remove InnerClass filter(source, Collections.singletonMap("public static class InnerClass {}", "")); @@ -791,7 +793,7 @@ public void testThatClassFileAreCleanedUp() throws MavenInvocationException, IOE await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/package", 200)); + .until(() -> devModeClient.getHttpResponse("/app/hello/package", 200)); // Verify that only ClassDeletionResource$InnerClass.class to be deleted assertThat(innerClassFile).doesNotExist(); @@ -805,7 +807,7 @@ public void testThatClassFileAreCleanedUp() throws MavenInvocationException, IOE await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/deletion", 404)); + .until(() -> devModeClient.getHttpResponse("/app/deletion", 404)); // Make sure that class files for the deleted source file have also been deleted assertThat(helloClassFile).doesNotExist(); @@ -823,7 +825,7 @@ public void testSourceModificationBeforeFirstCallWorks() throws MavenInvocationE filter(source, Collections.singletonMap("return \"hello\";", "return \"" + uuid + "\";")); // Check that the random string is returned - String greeting = DevModeTestUtils.getHttpResponse("/app/hello"); + String greeting = devModeClient.getHttpResponse("/app/hello"); assertThat(greeting).containsIgnoringCase(uuid); } @@ -837,12 +839,12 @@ public void testThatTheApplicationIsReloadedOnConfigChange() throws MavenInvocat running.execute(Arrays.asList("compile", "quarkus:dev", "-Dquarkus.analytics.disabled=true"), Collections.emptyMap(), mvnRunProps); - String resp = DevModeTestUtils.getHttpResponse(); + String resp = devModeClient.getHttpResponse(); assertThat(resp).containsIgnoringCase("ready").containsIgnoringCase("application").containsIgnoringCase("org.acme") .containsIgnoringCase("1.0-SNAPSHOT"); - String greeting = DevModeTestUtils.getHttpResponse("/app/hello/greeting"); + String greeting = devModeClient.getHttpResponse("/app/hello/greeting"); assertThat(greeting).containsIgnoringCase("bonjour"); File source = new File(testDir, "src/main/resources/application.properties"); @@ -858,7 +860,7 @@ public void testThatTheApplicationIsReloadedOnConfigChange() throws MavenInvocat await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greeting").contains(uuid)); + .until(() -> devModeClient.getHttpResponse("/app/hello/greeting").contains(uuid)); } @Test @@ -871,12 +873,12 @@ public void testThatAddingConfigFileWorksCorrectly() throws MavenInvocationExcep running.execute(Arrays.asList("compile", "quarkus:dev", "-Dquarkus.analytics.disabled=true"), Collections.emptyMap(), mvnRunProps); - String resp = DevModeTestUtils.getHttpResponse(); + String resp = devModeClient.getHttpResponse(); assertThat(resp).containsIgnoringCase("ready").containsIgnoringCase("application").containsIgnoringCase("org.acme") .containsIgnoringCase("1.0-SNAPSHOT"); - String greeting = DevModeTestUtils.getHttpResponse("/app/hello/greeting"); + String greeting = devModeClient.getHttpResponse("/app/hello/greeting"); assertThat(greeting).contains("initialValue"); File configurationFile = new File(testDir, "src/main/resources/application.properties"); @@ -896,7 +898,7 @@ public void testThatAddingConfigFileWorksCorrectly() throws MavenInvocationExcep await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(10, TimeUnit.SECONDS) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greeting").contains(uuid)); + .until(() -> devModeClient.getHttpResponse("/app/hello/greeting").contains(uuid)); } @Test @@ -921,7 +923,7 @@ public void testThatExternalConfigOverridesConfigInJar() throws MavenInvocationE await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(60, TimeUnit.SECONDS) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greeting").contains(uuid)); + .until(() -> devModeClient.getHttpResponse("/app/hello/greeting").contains(uuid)); } @Test @@ -937,7 +939,7 @@ public void testThatNewResourcesAreServed() throws MavenInvocationException, IOE await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/lorem.txt"), containsString("Lorem ipsum")); + .until(() -> devModeClient.getHttpResponse("/lorem.txt"), containsString("Lorem ipsum")); // Update the resource String uuid = UUID.randomUUID().toString(); @@ -945,14 +947,14 @@ public void testThatNewResourcesAreServed() throws MavenInvocationException, IOE await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/lorem.txt"), equalTo(uuid)); + .until(() -> devModeClient.getHttpResponse("/lorem.txt"), equalTo(uuid)); // Delete the resource source.delete(); await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/lorem.txt", 404)); + .until(() -> devModeClient.getHttpResponse("/lorem.txt", 404)); } @Test @@ -963,7 +965,7 @@ public void testThatConfigFileDeletionsAreDetected() throws MavenInvocationExcep await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greetings").contains("Bonjour")); + .until(() -> devModeClient.getHttpResponse("/app/hello/greetings").contains("Bonjour")); File source = new File(testDir, "src/main/resources/application.properties"); FileUtils.delete(source); @@ -971,7 +973,7 @@ public void testThatConfigFileDeletionsAreDetected() throws MavenInvocationExcep await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greetings").contains("Guten Morgen")); + .until(() -> devModeClient.getHttpResponse("/app/hello/greetings").contains("Guten Morgen")); } @Test @@ -991,7 +993,7 @@ private void testMultipleResourceDirectories() throws MavenInvocationException, await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greetings").contains("Bonjour/Other")); + .until(() -> devModeClient.getHttpResponse("/app/hello/greetings").contains("Bonjour/Other")); // Update the application.properties File source = new File(testDir, "src/main/resources-primary/application.properties"); @@ -999,7 +1001,7 @@ private void testMultipleResourceDirectories() throws MavenInvocationException, await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greetings").contains("Salut/Other")); + .until(() -> devModeClient.getHttpResponse("/app/hello/greetings").contains("Salut/Other")); // Add the application.yaml source = new File(testDir, "src/main/resources-secondary/application.yaml"); @@ -1008,7 +1010,7 @@ private void testMultipleResourceDirectories() throws MavenInvocationException, await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greetings").contains("Salut/Buenos dias")); + .until(() -> devModeClient.getHttpResponse("/app/hello/greetings").contains("Salut/Buenos dias")); // Update the application.yaml FileUtils.write(source, "other:\n" + @@ -1016,7 +1018,7 @@ private void testMultipleResourceDirectories() throws MavenInvocationException, await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greetings").contains("Salut/Hola")); + .until(() -> devModeClient.getHttpResponse("/app/hello/greetings").contains("Salut/Hola")); } @Test @@ -1034,7 +1036,7 @@ public void testThatApplicationRecoversCompilationIssue() throws MavenInvocation await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String content = DevModeTestUtils.getHttpResponse("/app/hello", true); + String content = devModeClient.getHttpResponse("/app/hello", true); last.set(content); return content.contains(uuid); }); @@ -1052,7 +1054,7 @@ public void testThatApplicationRecoversCompilationIssue() throws MavenInvocation // Wait until we get "uuid" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("carambar")); } @Test @@ -1069,7 +1071,7 @@ public void testThatApplicationRecoversStartupIssue() throws MavenInvocationExce await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String content = DevModeTestUtils.getHttpResponse("/app/hello", true); + String content = devModeClient.getHttpResponse("/app/hello", true); last.set(content); return content.contains("Error restarting Quarkus"); }); @@ -1081,7 +1083,7 @@ public void testThatApplicationRecoversStartupIssue() throws MavenInvocationExce await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String content = DevModeTestUtils.getHttpResponse("/app/hello", true); + String content = devModeClient.getHttpResponse("/app/hello", true); last.set(content); return content.equals("hello"); }); @@ -1117,7 +1119,7 @@ public void testThatNewBeanAreDiscovered() throws IOException, MavenInvocationEx // Wait until we get "uuid" await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("message")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("message")); await() .pollDelay(100, TimeUnit.MILLISECONDS) @@ -1128,7 +1130,7 @@ public void testThatNewBeanAreDiscovered() throws IOException, MavenInvocationEx await() .pollDelay(100, TimeUnit.MILLISECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("foobarbaz")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("foobarbaz")); } @Test @@ -1159,12 +1161,12 @@ public void testThatTheApplicationIsReloadedOnDotEnvConfigChange() throws MavenI running.execute(Arrays.asList("compile", "quarkus:dev", "-Dquarkus.analytics.disabled=true"), Collections.emptyMap(), mvnRunProps); - String resp = DevModeTestUtils.getHttpResponse(); + String resp = devModeClient.getHttpResponse(); assertThat(resp).containsIgnoringCase("ready").containsIgnoringCase("application").containsIgnoringCase("org.acme") .containsIgnoringCase("1.0-SNAPSHOT"); - String greeting = DevModeTestUtils.getHttpResponse("/app/hello/otherGreeting"); + String greeting = devModeClient.getHttpResponse("/app/hello/otherGreeting"); assertThat(greeting).containsIgnoringCase("Hola"); File source = new File(testDir, ".env"); @@ -1180,7 +1182,7 @@ public void testThatTheApplicationIsReloadedOnDotEnvConfigChange() throws MavenI await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/otherGreeting").contains(uuid)); + .until(() -> devModeClient.getHttpResponse("/app/hello/otherGreeting").contains(uuid)); } @Test @@ -1231,11 +1233,11 @@ public void testResourcesFromClasspath() throws MavenInvocationException, IOExce await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/cp/hello").equals("hello")); + .until(() -> devModeClient.getHttpResponse("/cp/hello").equals("hello")); // test that we don't get multiple instances of a resource when loading from the ClassLoader - assertThat(DevModeTestUtils.getHttpResponse("/cp/resourceCount/a.html")).isEqualTo("1"); - assertThat(DevModeTestUtils.getHttpResponse("/cp/resourceCount/entry")).isEqualTo("2"); + assertThat(devModeClient.getHttpResponse("/cp/resourceCount/a.html")).isEqualTo("1"); + assertThat(devModeClient.getHttpResponse("/cp/resourceCount/entry")).isEqualTo("2"); } @Test @@ -1249,7 +1251,7 @@ public void testModuleCompileOrder() throws IOException, MavenInvocationExceptio testDir = initProject("projects/multimodule-parent-dep", "projects/multimodule-compile-order"); runAndCheck("-Dquarkus.bootstrap.effective-model-builder"); - assertThat(DevModeTestUtils.getHttpResponse("/app/hello/")).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/app/hello/")).isEqualTo("hello"); // modify classes in all the modules and make sure they are compiled in a correct order File resource = new File(testDir, "level0/src/main/java/org/acme/level0/Level0Service.java"); @@ -1274,7 +1276,7 @@ public void testModuleCompileOrder() throws IOException, MavenInvocationExceptio await() .pollDelay(300, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("hello world")); + .until(() -> devModeClient.getHttpResponse("/app/hello").contains("hello world")); } @Test @@ -1293,8 +1295,8 @@ public void testThatGenerateCodeGoalIsNotTriggeredIfNotConfigured() throws IOExc public void testPropertyExpansion() throws IOException, MavenInvocationException { testDir = initProject("projects/property-expansion"); runAndCheck(); - assertThat(DevModeTestUtils.getHttpResponse("/app/hello/")).isEqualTo("hello"); - assertThat(DevModeTestUtils.getHttpResponse("/app/hello/applicationName")).isEqualTo("myapp"); + assertThat(devModeClient.getHttpResponse("/app/hello/")).isEqualTo("hello"); + assertThat(devModeClient.getHttpResponse("/app/hello/applicationName")).isEqualTo("myapp"); } @Test @@ -1302,7 +1304,7 @@ public void testMultiJarModuleDevModeMocks() throws MavenInvocationException, IO testDir = initProject("projects/multijar-module", "projects/multijar-module-devmode-mocks"); run(false, "clean", "package", "-DskipTests", "-Dqdev"); - String greeting = DevModeTestUtils.getHttpResponse("/hello"); + String greeting = devModeClient.getHttpResponse("/hello"); assertThat(greeting).contains("acme other mock-service"); // Update TestBean @@ -1311,7 +1313,7 @@ public void testMultiJarModuleDevModeMocks() throws MavenInvocationException, IO await() .pollDelay(300, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("acme other mock-service!")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("acme other mock-service!")); // Update AcmeBean resource = new File(testDir, "beans/src/main/java/org/acme/AcmeBean.java"); @@ -1319,7 +1321,7 @@ public void testMultiJarModuleDevModeMocks() throws MavenInvocationException, IO await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("acme! other mock-service!")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("acme! other mock-service!")); // Update Other bean resource = new File(testDir, "beans/src/main/java/org/acme/Other.java"); @@ -1327,7 +1329,7 @@ public void testMultiJarModuleDevModeMocks() throws MavenInvocationException, IO await() .pollDelay(300, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("acme! other! mock-service!")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("acme! other! mock-service!")); } @Test @@ -1335,7 +1337,7 @@ public void testMultiJarModuleDevMode() throws MavenInvocationException, IOExcep testDir = initProject("projects/multijar-module", "projects/multijar-module-devmode"); run(false, "clean", "package", "-DskipTests"); - String greeting = DevModeTestUtils.getHttpResponse("/hello"); + String greeting = devModeClient.getHttpResponse("/hello"); assertThat(greeting).contains("acme other acme-service"); // Update TestBean @@ -1344,7 +1346,7 @@ public void testMultiJarModuleDevMode() throws MavenInvocationException, IOExcep await() .pollDelay(300, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("acme other acme-service!")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("acme other acme-service!")); // Update AcmeBean resource = new File(testDir, "beans/src/main/java/org/acme/AcmeBean.java"); @@ -1352,7 +1354,7 @@ public void testMultiJarModuleDevMode() throws MavenInvocationException, IOExcep await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("acme! other acme-service!")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("acme! other acme-service!")); // Update Other bean resource = new File(testDir, "beans/src/main/java/org/acme/Other.java"); @@ -1360,7 +1362,7 @@ public void testMultiJarModuleDevMode() throws MavenInvocationException, IOExcep await() .pollDelay(300, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("acme! other! acme-service!")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("acme! other! acme-service!")); } @Test @@ -1373,7 +1375,7 @@ public void testThatWatchedAbsolutePathsAreNotDeleted() throws MavenInvocationEx await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Servus")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("Servus")); // Update the .env File source = new File(testDir, ".env"); @@ -1384,7 +1386,7 @@ public void testThatWatchedAbsolutePathsAreNotDeleted() throws MavenInvocationEx await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Hallo")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("Hallo")); assertTrue(source.exists()); } @@ -1408,7 +1410,7 @@ public void testExternalReloadableArtifacts() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Hello")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("Hello")); final File greetingJava = externalJarDir.toPath().resolve("src").resolve("main") .resolve("java").resolve("org").resolve("acme").resolve("lib") @@ -1431,7 +1433,7 @@ public void testExternalReloadableArtifacts() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Bonjour")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("Bonjour")); // Change bonjour() method content in Greeting.java filter(greetingJava, Map.of("Bonjour", "Bonjour!")); @@ -1443,6 +1445,6 @@ public void testExternalReloadableArtifacts() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("BONJOUR!")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("BONJOUR!")); } } diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/JarRunnerIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/JarRunnerIT.java index a334bf72490df..8a78cf9d62afd 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/JarRunnerIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/JarRunnerIT.java @@ -44,11 +44,12 @@ import io.quarkus.deployment.util.IoUtil; import io.quarkus.maven.it.verifier.MavenProcessInvocationResult; import io.quarkus.maven.it.verifier.RunningInvoker; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; import io.quarkus.utilities.JavaBinFinder; @DisableForNative public class JarRunnerIT extends MojoTestBase { + private DevModeClient devModeClient = new DevModeClient(); /** * Tests that a Quarkus project builds fine if the project is hosted in a directory @@ -78,7 +79,7 @@ public void testNonAsciiDir() throws Exception { // Wait until server up dumpFileContentOnFailure(() -> { await().pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello/package", 200)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello/package", 200)); return null; }, output, ConditionTimeoutException.class); } finally { @@ -107,7 +108,7 @@ public void testThatJarRunnerConsoleOutputWorksCorrectly() throws MavenInvocatio // Wait until server up await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello/package", 200)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello/package", 200)); String logs = FileUtils.readFileToString(output, "UTF-8"); @@ -141,7 +142,7 @@ public void testPlatformPropertiesOverridenInApplicationProperties() throws Exce Process process = doLaunch(new File(testDir, "app/target/quarkus-app"), Paths.get("quarkus-run.jar"), output, List.of()).start(); try { - Assertions.assertEquals("builder-image is customized", DevModeTestUtils.getHttpResponse("/hello")); + Assertions.assertEquals("builder-image is customized", devModeClient.getHttpResponse("/hello")); } finally { process.destroy(); } @@ -166,7 +167,7 @@ public void testPlatformPropertiesOverridenOnCommandLine() throws Exception { Process process = doLaunch(new File(testDir, "app/target/quarkus-app"), Paths.get("quarkus-run.jar"), output, List.of()).start(); try { - Assertions.assertEquals("builder-image is commandline", DevModeTestUtils.getHttpResponse("/hello")); + Assertions.assertEquals("builder-image is commandline", devModeClient.getHttpResponse("/hello")); } finally { process.destroy(); } @@ -237,7 +238,7 @@ public void testThatLegacyJarFormatWorks() throws Exception { dumpFileContentOnFailure(() -> { await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello/package", 200)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello/package", 200)); return null; }, output, ConditionTimeoutException.class); @@ -281,7 +282,7 @@ public void reaugmentationWithRemovedArtifacts() throws Exception { await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/cp/resourceCount/entry", false); + String ret = devModeClient.getHttpResponse("/cp/resourceCount/entry", false); response.set(ret); return true; }); @@ -309,7 +310,7 @@ public void reaugmentationWithRemovedArtifacts() throws Exception { await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/cp/resourceCount/entry", false); + String ret = devModeClient.getHttpResponse("/cp/resourceCount/entry", false); response.set(ret); return true; }); @@ -334,7 +335,7 @@ public void reaugmentationWithRemovedArtifacts() throws Exception { await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/cp/resourceCount/entry", false); + String ret = devModeClient.getHttpResponse("/cp/resourceCount/entry", false); response.set(ret); return true; }); @@ -374,7 +375,7 @@ public void reaugmentationWithRemovedArtifactsUsingSystemProperties() throws Exc await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/words/runtime", false); + String ret = devModeClient.getHttpResponse("/words/runtime", false); response.set(ret); return true; }); @@ -383,7 +384,7 @@ public void reaugmentationWithRemovedArtifactsUsingSystemProperties() throws Exc await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/words/buildtime", false); + String ret = devModeClient.getHttpResponse("/words/buildtime", false); response.set(ret); return true; }); @@ -409,7 +410,7 @@ public void reaugmentationWithRemovedArtifactsUsingSystemProperties() throws Exc await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/words/runtime", false); + String ret = devModeClient.getHttpResponse("/words/runtime", false); response.set(ret); return true; }); @@ -418,7 +419,7 @@ public void reaugmentationWithRemovedArtifactsUsingSystemProperties() throws Exc await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/words/buildtime", false); + String ret = devModeClient.getHttpResponse("/words/buildtime", false); response.set(ret); return true; }); @@ -441,7 +442,7 @@ public void reaugmentationWithRemovedArtifactsUsingSystemProperties() throws Exc await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/words/runtime", false); + String ret = devModeClient.getHttpResponse("/words/runtime", false); response.set(ret); return true; }); @@ -450,7 +451,7 @@ public void reaugmentationWithRemovedArtifactsUsingSystemProperties() throws Exc await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/words/buildtime", false); + String ret = devModeClient.getHttpResponse("/words/buildtime", false); response.set(ret); return true; }); @@ -494,7 +495,7 @@ private void assertThatMutableFastJarWorks(String targetDirSuffix, String provid dumpFileContentOnFailure(() -> { await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello/package", 200)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello/package", 200)); return null; }, output, ConditionTimeoutException.class); performRequest("/app/added", 404); @@ -531,7 +532,7 @@ private void assertThatMutableFastJarWorks(String targetDirSuffix, String provid // Wait until server up await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/moved/app/hello/package", 200)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/moved/app/hello/package", 200)); String logs = FileUtils.readFileToString(output, "UTF-8"); @@ -570,7 +571,7 @@ private void assertThatMutableFastJarWorks(String targetDirSuffix, String provid await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/anothermove/app/hello/package", 200)); + .until(() -> devModeClient.getHttpResponse("/anothermove/app/hello/package", 200)); String logs = FileUtils.readFileToString(output, "UTF-8"); @@ -617,7 +618,7 @@ public void testThatAppCDSAreUsable() throws Exception { dumpFileContentOnFailure(() -> { await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello/package", 200)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello/package", 200)); return null; }, output, ConditionTimeoutException.class); @@ -656,7 +657,7 @@ public void testArcExcludeDependencyOnLocalModule() throws Exception { await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String ret = DevModeTestUtils.getHttpResponse("/hello", true); + String ret = devModeClient.getHttpResponse("/hello", true); response.set(ret); return ret.contains("hello:"); }); @@ -826,7 +827,7 @@ private void assertThatFastJarFormatWorks(String outputDir) throws Exception { dumpFileContentOnFailure(() -> { await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello/package", 200)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello/package", 200)); return null; }, output, ConditionTimeoutException.class); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/NativeImageIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/NativeImageIT.java index 6515d475fdb24..fb6075804eddd 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/NativeImageIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/NativeImageIT.java @@ -19,11 +19,13 @@ import io.quarkus.maven.it.verifier.MavenProcessInvocationResult; import io.quarkus.maven.it.verifier.RunningInvoker; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; @EnableForNative public class NativeImageIT extends MojoTestBase { + private DevModeClient devModeClient = new DevModeClient(); + /** * Tests that the {@code java.library.path} can be overridden/configurable by passing the system property * when launching the generated application's native image. @@ -60,7 +62,7 @@ public void testJavaLibraryPathAtRuntime() throws Exception { final Process nativeImageRunWithAdditionalLibPath = runNativeImage(nativeImageRunner, new String[] { "-Djava.library.path=" + tmpDir.toString() }); try { - final String response = DevModeTestUtils.getHttpResponse("/hello/javaLibraryPath"); + final String response = devModeClient.getHttpResponse("/hello/javaLibraryPath"); Assertions.assertTrue(response.contains(tmpDir.toString()), "Response " + response + " for java.library.path was expected to contain the " + tmpDir + ", but didn't"); } finally { diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/RemoteDevMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/RemoteDevMojoIT.java index 9732478d18c47..ffd8cd2feb30a 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/RemoteDevMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/RemoteDevMojoIT.java @@ -18,7 +18,6 @@ import org.junit.jupiter.api.Test; import io.quarkus.maven.it.verifier.RunningInvoker; -import io.quarkus.test.devmode.util.DevModeTestUtils; /** * @author Clement Escoffier @@ -41,7 +40,7 @@ public void testThatTheApplicationIsReloadedOnJavaChange() // Wait until we get "uuid" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); await() .pollDelay(1, TimeUnit.SECONDS) @@ -53,11 +52,11 @@ public void testThatTheApplicationIsReloadedOnJavaChange() // Wait until we get "carambar" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("carambar")); //also verify that the dev ui console is disabled - DevModeTestUtils.getHttpResponse("/q/dev-v1", 404, 10, TimeUnit.SECONDS); - DevModeTestUtils.getHttpResponse("/q/dev-ui", 404, 10, TimeUnit.SECONDS); + devModeClient.getHttpResponse("/q/dev-v1", 404, 10, TimeUnit.SECONDS); + devModeClient.getHttpResponse("/q/dev-ui", 404, 10, TimeUnit.SECONDS); } @Test @@ -88,7 +87,7 @@ public void testThatTheApplicationIsReloadedOnNewResource() throws MavenInvocati // Wait until we get "bar" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/foo").contains("bar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/foo").contains("bar")); } @Test @@ -98,14 +97,14 @@ public void testThatTheApplicationIsReloadedOnConfigChange() throws MavenInvocat assertThat(testDir).isDirectory(); runAndCheck(); - String resp = DevModeTestUtils.getHttpResponse(); + String resp = devModeClient.getHttpResponse(); runningAgent = new RunningInvoker(agentDir, false); runningAgent.execute(Arrays.asList("compile", "quarkus:remote-dev"), Collections.emptyMap()); assertThat(resp).containsIgnoringCase("ready").containsIgnoringCase("application").containsIgnoringCase("org.acme") .containsIgnoringCase("1.0-SNAPSHOT"); - String greeting = DevModeTestUtils.getHttpResponse("/app/hello/greeting"); + String greeting = devModeClient.getHttpResponse("/app/hello/greeting"); assertThat(greeting).containsIgnoringCase("bonjour"); File source = new File(agentDir, "src/main/resources/application.properties"); @@ -121,7 +120,7 @@ public void testThatTheApplicationIsReloadedOnConfigChange() throws MavenInvocat await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/app/hello/greeting").contains(uuid)); + .until(() -> devModeClient.getHttpResponse("/app/hello/greeting").contains(uuid)); } @Test @@ -139,7 +138,7 @@ public void testThatNewResourcesAreServed() throws MavenInvocationException, IOE await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/lorem.txt").contains("Lorem ipsum")); + .until(() -> devModeClient.getHttpResponse("/lorem.txt").contains("Lorem ipsum")); // Update the resource String uuid = UUID.randomUUID().toString(); @@ -147,7 +146,7 @@ public void testThatNewResourcesAreServed() throws MavenInvocationException, IOE await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/lorem.txt").contains(uuid)); + .until(() -> devModeClient.getHttpResponse("/lorem.txt").contains(uuid)); // Delete the resource //TODO: not supported yet in remote dev @@ -174,7 +173,7 @@ public void testThatApplicationRecoversCompilationIssue() throws MavenInvocation await() .pollDelay(1, TimeUnit.SECONDS) .atMost(1, TimeUnit.MINUTES).until(() -> { - String content = DevModeTestUtils.getHttpResponse("/app/hello", true); + String content = devModeClient.getHttpResponse("/app/hello", true); last.set(content); return content.contains(uuid); }); @@ -192,7 +191,7 @@ public void testThatApplicationRecoversCompilationIssue() throws MavenInvocation // Wait until we get "uuid" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("carambar")); } @Test @@ -225,7 +224,7 @@ public void testThatNewBeanAreDiscovered() throws IOException, MavenInvocationEx // Wait until we get "uuid" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("message")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("message")); await() .pollDelay(1, TimeUnit.SECONDS) @@ -236,7 +235,7 @@ public void testThatNewBeanAreDiscovered() throws IOException, MavenInvocationEx await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("foobarbaz")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("foobarbaz")); } } diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/TestMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/TestMojoIT.java index 5911bd8dcdf6b..3b8fead904d54 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/TestMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/TestMojoIT.java @@ -9,7 +9,7 @@ import io.quarkus.runtime.LaunchMode; /** - * Tests the quarkus:test mojo. Most of the behaviour of quarkus:test is expected to also work with quarkus:test, so tests are + * Tests the quarkus:test mojo. Most of the behaviour of quarkus:dev is expected to also work with quarkus:test, so tests are * in a superclass. *

* NOTE to anyone diagnosing failures in this test, to run a single method use: diff --git a/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaDevModeIT.java b/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaDevModeIT.java index 3d18dc9829e8f..2183d2131bd3c 100644 --- a/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaDevModeIT.java +++ b/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaDevModeIT.java @@ -15,7 +15,6 @@ import com.google.common.collect.ImmutableMap; import io.quarkus.maven.it.RunAndCheckMojoTestBase; -import io.quarkus.test.devmode.util.DevModeTestUtils; public class ScalaDevModeIT extends RunAndCheckMojoTestBase { @@ -32,7 +31,7 @@ public void testThatTheApplicationIsReloadedOnScalaChange() throws MavenInvocati // Wait until we get "uuid" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); await() .pollDelay(1, TimeUnit.SECONDS) @@ -44,7 +43,7 @@ public void testThatTheApplicationIsReloadedOnScalaChange() throws MavenInvocati // Wait until we get "carambar" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("carambar")); } @Test @@ -64,7 +63,7 @@ public void testExternalReloadableArtifacts() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Hello")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("Hello")); final File greetingScala = externalJarDir.toPath().resolve("src").resolve("main") .resolve("scala").resolve("org").resolve("acme").resolve("lib") @@ -87,7 +86,7 @@ public void testExternalReloadableArtifacts() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Bonjour")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("Bonjour")); // Change bonjour() method content in Greeting.java filter(greetingScala, Map.of("Bonjour", "Bonjour!")); @@ -99,6 +98,6 @@ public void testExternalReloadableArtifacts() throws Exception { await() .pollDelay(100, TimeUnit.MILLISECONDS) .atMost(1, TimeUnit.MINUTES) - .until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("BONJOUR!")); + .until(() -> devModeClient.getHttpResponse("/hello").contains("BONJOUR!")); } } \ No newline at end of file diff --git a/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaRemoteDevModeIT.java b/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaRemoteDevModeIT.java index 7d09773d1ac58..cb4603cdb6303 100644 --- a/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaRemoteDevModeIT.java +++ b/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaRemoteDevModeIT.java @@ -13,7 +13,6 @@ import com.google.common.collect.ImmutableMap; import io.quarkus.maven.it.RunAndCheckWithAgentMojoTestBase; -import io.quarkus.test.devmode.util.DevModeTestUtils; public class ScalaRemoteDevModeIT extends RunAndCheckWithAgentMojoTestBase { @@ -32,7 +31,7 @@ public void testThatTheApplicationIsReloadedOnScalaChange() // Wait until we get "uuid" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains(uuid)); await() .pollDelay(1, TimeUnit.SECONDS) @@ -44,6 +43,6 @@ public void testThatTheApplicationIsReloadedOnScalaChange() // Wait until we get "carambar" await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar")); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/app/hello").contains("carambar")); } } diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/disable-unbind-executions b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/disable-unbind-executions new file mode 100644 index 0000000000000..60f805fc1dfda --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/disable-unbind-executions @@ -0,0 +1 @@ +This file disables the unbind-executions profile in the quarkus-integration-tests-parent. diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/pom.xml b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/pom.xml new file mode 100644 index 0000000000000..8bed2e8d5dd73 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/pom.xml @@ -0,0 +1,91 @@ + + + + integration-test-extension-that-defines-junit-test-extensions-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + integration-test-extension-that-defines-junit-test-extensions-deployment + Quarkus - Integration Tests - Test Extension - Extension - Deployment + + + 3.0.0 + + + + io.quarkus + quarkus-undertow-deployment + + + io.quarkus + quarkus-core-deployment + + + io.quarkus + quarkus-arc-deployment + + + io.quarkus + quarkus-jaxb-deployment + + + io.quarkus + integration-test-extension-that-defines-junit-test-extensions + ${project.version} + + + org.atteo + xml-combiner + ${xml-combiner.version} + + + + io.quarkus + quarkus-junit5-internal + test + + + io.quarkus + quarkus-junit5 + test + + + org.assertj + assertj-core + test + + + io.rest-assured + rest-assured + test + + + org.apache.commons + commons-lang3 + + + + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${project.version} + + + + + + + + diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/java/io/quarkiverse/acme/deployment/AnnotationAdjuster.java b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/java/io/quarkiverse/acme/deployment/AnnotationAdjuster.java new file mode 100644 index 0000000000000..5d4e93c4a9d63 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/java/io/quarkiverse/acme/deployment/AnnotationAdjuster.java @@ -0,0 +1,30 @@ +package io.quarkiverse.acme.deployment; + +import org.acme.AnnotationAddedByExtension; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.Type; + +import io.quarkus.gizmo.Gizmo; + +public class AnnotationAdjuster extends ClassVisitor { + + private static final String SIMPLE_ANNOTATION_TYPENAME = "L" + AnnotationAddedByExtension.class.getName().replace('.', '/') + + ";"; + + public AnnotationAdjuster(ClassVisitor visitor, String className) { + super(Gizmo.ASM_API_VERSION, visitor); + + } + + @Override + public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { + AnnotationVisitor av = visitAnnotation(SIMPLE_ANNOTATION_TYPENAME, true); + Type value = Type.getType(AnnotationAddedByExtension.class); + if (av != null) { + av.visit("value", value); + } + super.visit(version, access, name, signature, superName, interfaces); + } + +} diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/java/io/quarkiverse/acme/deployment/ExtensionProcessor.java b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/java/io/quarkiverse/acme/deployment/ExtensionProcessor.java new file mode 100644 index 0000000000000..fec441d09c5b2 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/java/io/quarkiverse/acme/deployment/ExtensionProcessor.java @@ -0,0 +1,51 @@ +package io.quarkiverse.acme.deployment; + +import org.jboss.jandex.DotName; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +class ExtensionProcessor { + + private static final String FEATURE = "extension-that-has-capability-for-tests"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + BytecodeTransformerBuildItem reworkClassLoadingOfParameterizedSourceTest2() { + // Ideally, we would not hardcode class names, but this is a reproducer so we can shortcut + DotName simple = DotName.createSimple("org.acme.ParameterizedTest"); + return new BytecodeTransformerBuildItem.Builder() + .setClassToTransform(simple.toString()) + .setVisitorFunction((ignored, visitor) -> new AnnotationAdjuster(visitor, + simple.toString())) + .build(); + + } + + @BuildStep + BytecodeTransformerBuildItem reworkClassLoadingOfParameterizedSourceQuarkusTest() { + // Ideally, we would not hardcode class names, but this is a reproducer so we can shortcut + DotName simple = DotName.createSimple("org.acme.ParameterizedQuarkusTest"); + return new BytecodeTransformerBuildItem.Builder() + .setClassToTransform(simple.toString()) + .setVisitorFunction((ignored, visitor) -> new AnnotationAdjuster(visitor, + simple.toString())) + .build(); + } + + @BuildStep + BytecodeTransformerBuildItem reworkClassLoadingOfNormalSourceQuarkusTest() { + // Ideally, we would not hardcode class names, but this is a reproducer so we can shortcut + DotName simple = DotName.createSimple("org.acme.NormalQuarkusTest"); + return new BytecodeTransformerBuildItem.Builder() + .setClassToTransform(simple.toString()) + .setVisitorFunction((ignored, visitor) -> new AnnotationAdjuster(visitor, + simple.toString())) + .build(); + } +} diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/resources/application.properties b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/resources/application.properties new file mode 100644 index 0000000000000..67fd6161b289b --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/deployment/src/main/resources/application.properties @@ -0,0 +1,193 @@ +# Log settings +# log level in lower case for testing +quarkus.log.level=info +quarkus.log.file.enable=true +quarkus.log.file.level=INFO +quarkus.log.file.format=%d{HH:mm:ss} %-5p [%c{2.}]] (%t) %s%e%n + +# Resource path to DSAPublicKey base64 encoded bytes +quarkus.root.dsa-key-location=/DSAPublicKey.encoded + +# Have the TestProcessor validate the build time configuration below +quarkus.root.validate-build-config=true + + +### Configuration settings for the TestBuildTimeConfig config root +quarkus.bt.bt-string-opt=btStringOptValue +quarkus.bt.bt-sbv=StringBasedValue +# This is not set so that we should get the @ConfigItem defaultValue +#quarkus.bt.bt-sbv-with-default=StringBasedValue +quarkus.bt.all-values.oov=configPart1+configPart2 +quarkus.bt.all-values.ovo=configPart1+configPart2 +# This is not set so that we should get the @ConfigItem defaultValue +#quarkus.bt.bt-oov-with-default=ObjectOfValue +quarkus.bt.all-values.long-primitive=1234567891 +quarkus.bt.all-values.double-primitive=3.1415926535897932384 +quarkus.bt.all-values.long-value=1234567892 +quarkus.bt.all-values.opt-long-value=1234567893 +quarkus.bt.all-values.opt-double-value=3.1415926535897932384 +quarkus.bt.all-values.optional-long-value=1234567894 +quarkus.bt.all-values.nested-config-map.key1.nested-value=value1 +quarkus.bt.all-values.nested-config-map.key1.oov=value1.1+value1.2 +quarkus.bt.all-values.nested-config-map.key2.nested-value=value2 +quarkus.bt.all-values.nested-config-map.key2.oov=value2.1+value2.2 +quarkus.bt.all-values.string-list=value1,value2 +quarkus.bt.all-values.long-list=1,2,3 +quarkus.bt.bt-config-value=${test.record.expansion} +test.record.expansion=value +quarkus.bt.bt-config-value-empty= + +### Duplicate settings for the TestBuildAndRunTimeConfig. May be able to drop if ConfigRoot inheritance is added +quarkus.btrt.bt-string-opt=btStringOptValue +quarkus.btrt.bt-sbv=StringBasedValue +quarkus.btrt.all-values.oov=configPart1+configPart2 +quarkus.btrt.all-values.ovo=configPart1+configPart2 +quarkus.btrt.all-values.long-primitive=1234567891 +quarkus.btrt.all-values.double-primitive=3.1415926535897932384 +quarkus.btrt.all-values.long-value=1234567892 +quarkus.btrt.all-values.opt-long-value=1234567893 +quarkus.btrt.all-values.opt-double-value=3.1415926535897932384 +quarkus.btrt.all-values.optional-long-value=1234567894 +quarkus.btrt.all-values.nested-config-map.key1.nested-value=value1 +quarkus.btrt.all-values.nested-config-map.key1.oov=value1.1+value1.2 +quarkus.btrt.all-values.nested-config-map.key2.nested-value=value2 +quarkus.btrt.all-values.nested-config-map.key2.oov=value2.1+value2.2 +quarkus.btrt.all-values.string-list=value1,value2 +quarkus.btrt.all-values.long-list=1,2,3 +# The expansion value is not available in runtime so we need to set it directly. +quarkus.btrt.all-values.expanded-default=1234 + +### Configuration settings for the TestRunTimeConfig config root +quarkus.rt.rt-string-opt=rtStringOptValue +quarkus.rt.rt-string-opt-with-default=rtStringOptWithDefaultValue +quarkus.rt.all-values.oov=configPart1+configPart2 +quarkus.rt.all-values.ovo=configPart1+configPart2 +quarkus.rt.all-values.long-primitive=12345678911 +quarkus.rt.all-values.double-primitive=3.1415926535897932384 +quarkus.rt.all-values.long-value=12345678921 +quarkus.rt.all-values.opt-long-value=12345678931 +quarkus.rt.all-values.opt-double-value=3.1415926535897932384 +quarkus.rt.all-values.optional-long-value=12345678941 +quarkus.rt.all-values.nested-config-map.key1.nested-value=value1 +quarkus.rt.all-values.nested-config-map.key1.oov=value1.1+value1.2 +quarkus.rt.all-values.nested-config-map.key2.nested-value=value2 +quarkus.rt.all-values.nested-config-map.key2.oov=value2.1+value2.2 +quarkus.rt.all-values.string-list=value1,value2 +quarkus.rt.all-values.long-list=1,2,3 +# A nested map of properties +quarkus.rt.all-values.string-map.key1=value1 +quarkus.rt.all-values.string-map.key2=value2 +quarkus.rt.all-values.string-map.key3=value3 +# And list form +quarkus.rt.all-values.string-list-map.key1=value1,value2,value3 +quarkus.rt.all-values.string-list-map.key2=value4,value5 +quarkus.rt.all-values.string-list-map.key3=value6 +# A root map of properties +quarkus.rt.string-map.key1=value1 +quarkus.rt.string-map.key2=value2 +quarkus.rt.string-map.key3=value3 +# And list form +quarkus.rt.string-list-map.key1=value1 +quarkus.rt.string-list-map.key2=value2,value3 +quarkus.rt.string-list-map.key3=value4,value5,value6 + +### run time configuration using enhanced converters +quarkus.rt.my-enum=enum-two +quarkus.rt.my-enums=enum-one,enum-two +quarkus.rt.my-optional-enums=optional +quarkus.rt.no-hyphenate-first-enum=ENUM_ONE +quarkus.rt.no-hyphenate-second-enum=Enum_Two +quarkus.rt.primitive-boolean=YES +quarkus.rt.object-boolean=NO +quarkus.rt.primitive-integer=two +quarkus.rt.object-integer=nine +quarkus.rt.one-to-nine=one,two,three,four,five,six,seven,eight,nine +quarkus.rt.map-of-numbers.key1=one +quarkus.rt.map-of-numbers.key2=two + +### map configurations +quarkus.rt.leaf-map.key.first=first-key-value +quarkus.rt.leaf-map.key.second=second-key-value +quarkus.rt.config-group-map.key.group.nested-value=value +quarkus.rt.config-group-map.key.group.oov=value2.1+value2.2 + +### build time and run time configuration using enhanced converters +quarkus.btrt.map-of-numbers.key1=one +quarkus.btrt.map-of-numbers.key2=two +quarkus.btrt.my-enum=optional +quarkus.btrt.my-enums=optional,enum-one,enum-two + +### anonymous root property +quarkus.test-property=foo + +### map of map of strings +quarkus.rt.map-map.outer-key.inner-key=1234 +quarkus.btrt.map-map.outer-key.inner-key=1234 +quarkus.bt.map-map.outer-key.inner-key=1234 + +# Test config root with "RuntimeConfig" suffix +quarkus.foo.bar=huhu + +### named map with profiles +quarkus.btrt.map-map.main-profile.property=1234 +%test.quarkus.btrt.map-map.test-profile.property=5678 + +### ordinal and default values source +config_ordinal=1000 +my.prop=1234 +%prod.my.prop=1234 +%dev.my.prop=5678 +%test.my.prop=1234 + +### Unknown properties +quarkus.unknown.prop=1234 +quarkus.http.non-application-root-path=/1234 +quarkus.http.ssl-port=4443 +# This is how Env Source will output property names (for maps) +QUARKUS_HTTP_NON_APPLICATION_ROOT_PATH=/1234 +quarkus.http.non.application.root.path=/1234 +QUARKUS_HTTP_SSL_PORT=4443 +quarkus.http.ssl.port=4443 +quarkus.arc.unremovable-types=foo +# The YAML source may add an indexed property (depending on how the YAML is laid out). This is not supported by @ConfigRoot +quarkus.arc.unremovable-types[0]=foo + +### Do not record env values in build time +bt.do.not.record=properties +%test.bt.profile.record=properties + +### mappings +quarkus.mapping.bt.value=value +quarkus.mapping.bt.group.value=value +quarkus.mapping.bt.present.value=present +quarkus.mapping.bt.groups[0].value=first +quarkus.mapping.bt.groups[1].value=second + +quarkus.mapping.btrt.value=value +quarkus.mapping.btrt.group.value=value + +quarkus.mapping.rt.value=value +quarkus.mapping.rt.group.value=value + +### prefix +my.prefix.prop=1234 +my.prefix.map.prop=1234 +my.prefix.nested.nested-value=nested-1234 +my.prefix.nested.oov=nested-1234+nested-5678 +my.prefix.named.prop=1234 +my.prefix.named.map.prop=1234 +my.prefix.named.nested.nested-value=nested-1234 +my.prefix.named.nested.oov=nested-1234+nested-5678 + +my.prefix.bt.prop=1234 +my.prefix.bt.nested.nested-value=nested-1234 +my.prefix.bt.nested.oov=nested-1234+nested-5678 + +another.another-prefix.prop=5678 +another.another-prefix.map.prop=5678 + +proprietary.root.config.value=1234 +proprietary.mapping.config.value=1234 +proprietary.should.not.report.unknown=1234 + +unremoveable.value=1234 diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/disable-unbind-executions b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/disable-unbind-executions new file mode 100644 index 0000000000000..60f805fc1dfda --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/disable-unbind-executions @@ -0,0 +1 @@ +This file disables the unbind-executions profile in the quarkus-integration-tests-parent. diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/pom.xml b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/pom.xml new file mode 100644 index 0000000000000..6b988bd6524d4 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/pom.xml @@ -0,0 +1,39 @@ + + + + quarkus-integration-test-test-extension + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + integration-test-extension-that-defines-junit-test-extensions-parent + Quarkus - Integration Tests - Test Extension - Extension + pom + + + true + true + + + + deployment + runtime + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + ${nexus-staging-maven-plugin.version} + + true + + + + + + diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/disable-unbind-executions b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/disable-unbind-executions new file mode 100644 index 0000000000000..60f805fc1dfda --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/disable-unbind-executions @@ -0,0 +1 @@ +This file disables the unbind-executions profile in the quarkus-integration-tests-parent. diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/pom.xml b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/pom.xml new file mode 100644 index 0000000000000..b45a0c0957c20 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/pom.xml @@ -0,0 +1,139 @@ + + + + integration-test-extension-that-defines-junit-test-extensions-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + integration-test-extension-that-defines-junit-test-extensions + Quarkus - Integration Tests - Test Extension - Extension - Runtime + + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-undertow + + + io.quarkus + quarkus-jaxb + + + org.graalvm.sdk + graal-sdk + provided + + + io.quarkus.http + quarkus-http-servlet + + + org.jboss.spec.javax.servlet + jboss-servlet-api_4.0_spec + + + + + jakarta.servlet + jakarta.servlet-api + + + io.quarkus + quarkus-core + + + + + io.quarkus + quarkus-arc-deployment + ${project.version} + pom + test + + + * + * + + + + + io.quarkus + quarkus-core-deployment + ${project.version} + pom + test + + + * + * + + + + + io.quarkus + quarkus-jaxb-deployment + ${project.version} + pom + test + + + * + * + + + + + io.quarkus + quarkus-undertow-deployment + ${project.version} + pom + test + + + * + * + + + + + + org.junit.jupiter + junit-jupiter-api + + + + + + + io.quarkus + quarkus-extension-maven-plugin + + + io.quarkus.test-extension + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${project.version} + + + + + + + + diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/AnnotationAddedByExtension.java b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/AnnotationAddedByExtension.java new file mode 100644 index 0000000000000..576629d96b013 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/AnnotationAddedByExtension.java @@ -0,0 +1,11 @@ +package org.acme; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface AnnotationAddedByExtension { +} diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/AnnotationCountingTestCase.java b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/AnnotationCountingTestCase.java new file mode 100644 index 0000000000000..cc07a9108654f --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/AnnotationCountingTestCase.java @@ -0,0 +1,28 @@ +package org.acme; + +import java.lang.annotation.Annotation; +import java.util.Arrays; + +public class AnnotationCountingTestCase { + public AnnotationCountingTestCase(Annotation[] annotations, ClassLoader classloader) { + this.annotations = annotations; + this.classloader = classloader; + displayString = Arrays.toString(annotations); + } + + public String getDisplayString() { + return displayString; + } + + public Annotation[] getAnnotations() { + return annotations; + } + + private final ClassLoader classloader; + private String displayString; + private Annotation[] annotations; + + public ClassLoader getClassloader() { + return classloader; + } +} \ No newline at end of file diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/Callback.java b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/Callback.java new file mode 100644 index 0000000000000..991d9080a0289 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/Callback.java @@ -0,0 +1,11 @@ +package org.acme; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Callback { +} diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/CallbackInvokingInterceptor.java b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/CallbackInvokingInterceptor.java new file mode 100644 index 0000000000000..659f93762b5f4 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/CallbackInvokingInterceptor.java @@ -0,0 +1,41 @@ +package org.acme; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; + +public class CallbackInvokingInterceptor implements BeforeEachCallback { + @Override + public void beforeEach(ExtensionContext context) throws Exception { + + Class testClass = context.getRequiredTestClass(); + + // Find everything annotated @Callback + List callbacks = getMethodsAnnotatedWith(testClass, Callback.class); + for (Method m : callbacks) { + m.invoke(context.getRequiredTestInstance()); + } + + } + + protected static List getMethodsAnnotatedWith(Class clazz, final Class annotationClass) { + final List methods = new ArrayList(); + while (clazz != Object.class) { + for (final Method method : clazz.getDeclaredMethods()) { + // Check by name since we could have some classloader mismatches + Annotation[] allAnnotations = method.getAnnotations(); + for (Annotation annotation : allAnnotations) { + if (annotation.annotationType().getName().equals(annotationClass.getName())) + methods.add(method); + } + } + // move to the upper class in the hierarchy in search for more methods + clazz = clazz.getSuperclass(); + } + return methods; + } +} diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/InjectableParameter.java b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/InjectableParameter.java new file mode 100644 index 0000000000000..d4ea70a901f81 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/InjectableParameter.java @@ -0,0 +1,18 @@ +package org.acme; + +import java.math.BigInteger; +import java.util.concurrent.CopyOnWriteArrayList; + +public class InjectableParameter { + // Add some private classes to exercise serialization + private BigInteger integer; + + CopyOnWriteArrayList concurrent; + + InjectableParameter() { + integer = new BigInteger(String.valueOf(Math.round(Math.random() * 100000))); + concurrent = new CopyOnWriteArrayList<>(); + concurrent.add(integer); + } + +} diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/MyContextProvider.java b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/MyContextProvider.java new file mode 100644 index 0000000000000..fe06208c53496 --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/MyContextProvider.java @@ -0,0 +1,59 @@ +package org.acme; + +import static java.util.Arrays.asList; + +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.extension.Extension; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolutionException; +import org.junit.jupiter.api.extension.ParameterResolver; +import org.junit.jupiter.api.extension.TestTemplateInvocationContext; +import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider; + +public class MyContextProvider implements TestTemplateInvocationContextProvider { + + @Override + public boolean supportsTestTemplate(ExtensionContext extensionContext) { + return true; + } + + @Override + public Stream provideTestTemplateInvocationContexts(ExtensionContext extensionContext) { + Class testClass = extensionContext.getTestClass().get(); + + return Stream.of( + context(new AnnotationCountingTestCase(testClass.getAnnotations(), testClass.getClassLoader()))); + + } + + private TestTemplateInvocationContext context(AnnotationCountingTestCase testCase) { + return new TestTemplateInvocationContext() { + @Override + public String getDisplayName(int invocationIndex) { + return testCase.getDisplayString(); + } + + @Override + public List getAdditionalExtensions() { + return asList( + new ParameterResolver() { + @Override + public boolean supportsParameter(ParameterContext parameterContext, + ExtensionContext extensionContext) throws ParameterResolutionException { + return true; + } + + @Override + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + return extensionContext; + } + }); + } + + }; + } +} diff --git a/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/MyParameterResolver.java b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/MyParameterResolver.java new file mode 100644 index 0000000000000..6877e695a19fa --- /dev/null +++ b/integration-tests/test-extension/extension-that-defines-junit-test-extensions/runtime/src/main/java/org/acme/MyParameterResolver.java @@ -0,0 +1,20 @@ +package org.acme; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolutionException; +import org.junit.jupiter.api.extension.ParameterResolver; + +public class MyParameterResolver implements ParameterResolver { + @Override + public boolean supportsParameter(ParameterContext parameterContext, + ExtensionContext extensionContext) throws ParameterResolutionException { + return parameterContext.getParameter().getType() == InjectableParameter.class; + } + + @Override + public Object resolveParameter(ParameterContext parameterContext, + ExtensionContext extensionContext) throws ParameterResolutionException { + return new InjectableParameter(); + } +} diff --git a/integration-tests/test-extension/pom.xml b/integration-tests/test-extension/pom.xml index 7f7b0b051bc16..c12667cf3285a 100644 --- a/integration-tests/test-extension/pom.xml +++ b/integration-tests/test-extension/pom.xml @@ -15,6 +15,7 @@ extension + extension-that-defines-junit-test-extensions tests diff --git a/integration-tests/test-extension/tests/pom.xml b/integration-tests/test-extension/tests/pom.xml index d5f7e2312f5cf..1d0c77e9d08e6 100644 --- a/integration-tests/test-extension/tests/pom.xml +++ b/integration-tests/test-extension/tests/pom.xml @@ -78,6 +78,11 @@ + + io.quarkus + quarkus-test-maven + test + @@ -87,6 +92,15 @@ true + + + src/test/resources-filtered + true + + **/target/** + + + diff --git a/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestCallbackDevModeIT.java b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestCallbackDevModeIT.java new file mode 100644 index 0000000000000..537b3eaa0371d --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestCallbackDevModeIT.java @@ -0,0 +1,65 @@ +package io.quarkus.it.extension.it; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.apache.maven.shared.invoker.MavenInvocationException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; + +import io.quarkus.maven.it.RunAndCheckMojoTestBase; +import io.quarkus.maven.it.continuoustesting.ContinuousTestingMavenTestUtils; + +/** + * Be aware! This test will not run if the name does not start with 'Test'. + *

+ * NOTE to anyone diagnosing failures in this test, to run a single method use: + *

+ * mvn install -Dit.test=TestTemplateDevModeIT#methodName + */ +@DisabledIfSystemProperty(named = "quarkus.test.native", matches = "true") +@Disabled // Tracked by #22611 +public class TestCallbackDevModeIT extends RunAndCheckMojoTestBase { + + /* + * We have a few tests that will run in parallel, so set a unique port + */ + protected int getPort() { + return 8094; + } + + protected void runAndCheck(boolean performCompile, String... options) + throws MavenInvocationException, FileNotFoundException { + run(performCompile, options); + + try { + String resp = devModeClient.getHttpResponse(); + assertThat(resp).containsIgnoringCase("ready").containsIgnoringCase("application") + .containsIgnoringCase("SNAPSHOT"); + } catch (Exception e) { + e.printStackTrace(); + } + + // There's no json endpoints, so nothing else to check + } + + @Test + public void testThatTheTestsPassed() throws MavenInvocationException, IOException { + //we also check continuous testing + String executionDir = "projects/project-using-test-callback-from-extension-processed"; + testDir = initProject("projects/project-using-test-callback-from-extension", executionDir); + runAndCheck(); + + ContinuousTestingMavenTestUtils testingTestUtils = new ContinuousTestingMavenTestUtils(getPort()); + ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion(); + // This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures, + // so we need to check the pass count explicitly + Assertions.assertEquals(0, results.getTestsFailed()); + Assertions.assertEquals(2, results.getTestsPassed()); + } + +} diff --git a/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestCallbackTestModeIT.java b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestCallbackTestModeIT.java new file mode 100644 index 0000000000000..9a45bfa1fd1bc --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestCallbackTestModeIT.java @@ -0,0 +1,75 @@ +package io.quarkus.it.extension.it; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.apache.maven.shared.invoker.MavenInvocationException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; + +import io.quarkus.maven.it.RunAndCheckMojoTestBase; +import io.quarkus.maven.it.continuoustesting.ContinuousTestingMavenTestUtils; +import io.quarkus.maven.it.continuoustesting.TestModeContinuousTestingMavenTestUtils; +import io.quarkus.runtime.LaunchMode; + +/** + * Be aware! This test will not run if the name does not start with 'Test'. + *

+ * This tests test templates, in test mode. + */ +@Disabled // Tracked by #22611 +@DisabledIfSystemProperty(named = "quarkus.test.native", matches = "true") +public class TestCallbackTestModeIT extends RunAndCheckMojoTestBase { + + /* + * We have a few tests that will run in parallel, so set a unique port + */ + protected int getPort() { + return 8096; + } + + @Override + protected LaunchMode getDefaultLaunchMode() { + return LaunchMode.TEST; + } + + @Override + public void shutdownTheApp() { + if (running != null) { + running.stop(); + } + + // There's no http server, so there's nothing to check to make sure we're stopped, except by the maven invoker itself, or the logs + } + + /** + * This is actually more like runAndDoNotCheck, because + * we can't really check anything via a HTTP get, because this is a test mode application + */ + @Override + protected void runAndCheck(boolean performCompile, LaunchMode mode, String... options) + throws FileNotFoundException, MavenInvocationException { + run(performCompile, mode, options); + + // We don't need to try and pause, because the continuous testing utils will wait for tests to finish + + } + + @Test + public void testThatTheTestsPassed() throws MavenInvocationException, IOException { + //we also check continuous testing + String executionDir = "projects/project-using-test-callback-from-extension-processed"; + testDir = initProject("projects/project-using-test-callback-from-extension", executionDir); + runAndCheck(); + + ContinuousTestingMavenTestUtils testingTestUtils = new TestModeContinuousTestingMavenTestUtils(running); + ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion(); + // This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures, + // so we need to check the pass count explicitly + Assertions.assertEquals(0, results.getTestsFailed()); + Assertions.assertEquals(9, results.getTestsPassed()); + } + +} diff --git a/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestParameterDevModeIT.java b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestParameterDevModeIT.java new file mode 100644 index 0000000000000..08717caa64c40 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestParameterDevModeIT.java @@ -0,0 +1,59 @@ +package io.quarkus.it.extension.it; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.apache.maven.shared.invoker.MavenInvocationException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; + +import io.quarkus.maven.it.RunAndCheckMojoTestBase; +import io.quarkus.maven.it.continuoustesting.ContinuousTestingMavenTestUtils; + +/** + * Be aware! This test will not run if the name does not start with 'Test'. + *

+ * NOTE to anyone diagnosing failures in this test, to run a single method use: + *

+ * mvn install -Dit.test=DevMojoIT#methodName + */ +@Disabled // because of https://github.com/quarkiverse/quarkus-pact/issues/73 +@DisabledIfSystemProperty(named = "quarkus.test.native", matches = "true") +public class TestParameterDevModeIT extends RunAndCheckMojoTestBase { + + protected int getPort() { + return 8098; + } + + protected void runAndCheck(boolean performCompile, String... options) + throws MavenInvocationException, FileNotFoundException { + run(performCompile, options); + + String resp = devModeClient.getHttpResponse(); + + assertThat(resp).containsIgnoringCase("ready").containsIgnoringCase("application") + .containsIgnoringCase("1.0-SNAPSHOT"); + + // There's no json endpoints, so nothing else to check + } + + @Test + public void testThatTheTestsPassed() throws MavenInvocationException, IOException { + //we also check continuous testing + String executionDir = "projects/project-using-test-parameter-injection-processed"; + testDir = initProject("projects/project-using-test-parameter-injection", executionDir); + runAndCheck(); + + ContinuousTestingMavenTestUtils testingTestUtils = new ContinuousTestingMavenTestUtils(getPort()); + ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion(); + // This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures, + // so we need to check the pass count explicitly + Assertions.assertEquals(0, results.getTestsFailed()); + Assertions.assertEquals(1, results.getTestsPassed()); + } + +} diff --git a/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestParameterTestModeIT.java b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestParameterTestModeIT.java new file mode 100644 index 0000000000000..1a9867be18681 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestParameterTestModeIT.java @@ -0,0 +1,69 @@ +package io.quarkus.it.extension.it; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.apache.maven.shared.invoker.MavenInvocationException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; + +import io.quarkus.maven.it.RunAndCheckMojoTestBase; +import io.quarkus.maven.it.continuoustesting.ContinuousTestingMavenTestUtils; +import io.quarkus.runtime.LaunchMode; + +/** + * Be aware! This test will not run if the name does not start with 'Test'. + *

+ * NOTE to anyone diagnosing failures in this test, to run a single method use: + *

+ * mvn install -Dit.test=DevMojoIT#methodName + */ +@Disabled // because of https://github.com/quarkiverse/quarkus-pact/issues/73 +@DisabledIfSystemProperty(named = "quarkus.test.native", matches = "true") +public class TestParameterTestModeIT extends RunAndCheckMojoTestBase { + + @Override + protected LaunchMode getDefaultLaunchMode() { + return LaunchMode.TEST; + } + + @Override + public void shutdownTheApp() { + if (running != null) { + running.stop(); + } + + // There's no http server, so there's nothing to check to make sure we're stopped, except by the maven invoker itself, or the logs + } + + /** + * This is actually more like runAndDoNotCheck, because + * we can't really check anything via a HTTP get, because this is a test mode application + */ + @Override + protected void runAndCheck(boolean performCompile, LaunchMode mode, String... options) + throws FileNotFoundException, MavenInvocationException { + run(performCompile, mode, options); + + // We don't need to try and pause, because the continuous testing utils will wait for tests to finish + + } + + @Test + public void testThatTheTestsPassed() throws MavenInvocationException, IOException { + //we also check continuous testing + String executionDir = "projects/project-using-test-parameter-injection-processed"; + testDir = initProject("projects/project-using-test-parameter-injection", executionDir); + runAndCheck(); + + ContinuousTestingMavenTestUtils testingTestUtils = new ContinuousTestingMavenTestUtils(getPort()); + ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion(); + // This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures, + // so we need to check the pass count explicitly + Assertions.assertEquals(0, results.getTestsFailed()); + Assertions.assertEquals(1, results.getTestsPassed()); + } + +} diff --git a/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestTemplateDevModeIT.java b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestTemplateDevModeIT.java new file mode 100644 index 0000000000000..db8a2f637092e --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestTemplateDevModeIT.java @@ -0,0 +1,65 @@ +package io.quarkus.it.extension.it; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.apache.maven.shared.invoker.MavenInvocationException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; + +import io.quarkus.maven.it.RunAndCheckMojoTestBase; +import io.quarkus.maven.it.continuoustesting.ContinuousTestingMavenTestUtils; + +/** + * Be aware! This test will not run if the name does not start with 'Test'. + *

+ * NOTE to anyone diagnosing failures in this test, to run a single method use: + *

+ * mvn install -Dit.test=TestTemplateDevModeIT#methodName + */ +@DisabledIfSystemProperty(named = "quarkus.test.native", matches = "true") +@Disabled // Tracked by #27821 +public class TestTemplateDevModeIT extends RunAndCheckMojoTestBase { + + /* + * We have a few tests that will run in parallel, so set a unique port + */ + protected int getPort() { + return 8090; + } + + protected void runAndCheck(boolean performCompile, String... options) + throws MavenInvocationException, FileNotFoundException { + run(performCompile, options); + + try { + String resp = devModeClient.getHttpResponse(); + assertThat(resp).containsIgnoringCase("ready").containsIgnoringCase("application") + .containsIgnoringCase("SNAPSHOT"); + } catch (Exception e) { + e.printStackTrace(); + } + + // There's no json endpoints, so nothing else to check + } + + @Test + public void testThatTheTestsPassed() throws MavenInvocationException, IOException { + //we also check continuous testing + String executionDir = "projects/project-using-test-template-from-extension-processed"; + testDir = initProject("projects/project-using-test-template-from-extension", executionDir); + runAndCheck(); + + ContinuousTestingMavenTestUtils testingTestUtils = new ContinuousTestingMavenTestUtils(getPort()); + ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion(); + // This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures, + // so we need to check the pass count explicitly + Assertions.assertEquals(0, results.getTestsFailed()); + Assertions.assertEquals(9, results.getTestsPassed()); + } + +} diff --git a/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestTemplateTestModeIT.java b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestTemplateTestModeIT.java new file mode 100644 index 0000000000000..594bab163a6d1 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestTemplateTestModeIT.java @@ -0,0 +1,75 @@ +package io.quarkus.it.extension.it; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.apache.maven.shared.invoker.MavenInvocationException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; + +import io.quarkus.maven.it.RunAndCheckMojoTestBase; +import io.quarkus.maven.it.continuoustesting.ContinuousTestingMavenTestUtils; +import io.quarkus.maven.it.continuoustesting.TestModeContinuousTestingMavenTestUtils; +import io.quarkus.runtime.LaunchMode; + +/** + * Be aware! This test will not run if the name does not start with 'Test'. + *

+ * This tests test templates, in test mode. + */ +@Disabled // Tracked by #27821 +@DisabledIfSystemProperty(named = "quarkus.test.native", matches = "true") +public class TestTemplateTestModeIT extends RunAndCheckMojoTestBase { + + /* + * We have a few tests that will run in parallel, so set a unique port + */ + protected int getPort() { + return 8092; + } + + @Override + protected LaunchMode getDefaultLaunchMode() { + return LaunchMode.TEST; + } + + @Override + public void shutdownTheApp() { + if (running != null) { + running.stop(); + } + + // There's no http server, so there's nothing to check to make sure we're stopped, except by the maven invoker itself, or the logs + } + + /** + * This is actually more like runAndDoNotCheck, because + * we can't really check anything via a HTTP get, because this is a test mode application + */ + @Override + protected void runAndCheck(boolean performCompile, LaunchMode mode, String... options) + throws FileNotFoundException, MavenInvocationException { + run(performCompile, mode, options); + + // We don't need to try and pause, because the continuous testing utils will wait for tests to finish + + } + + @Test + public void testThatTheTestsPassed() throws MavenInvocationException, IOException { + //we also check continuous testing + String executionDir = "projects/project-using-test-template-from-extension-processed"; + testDir = initProject("projects/project-using-test-template-from-extension", executionDir); + runAndCheck(); + + ContinuousTestingMavenTestUtils testingTestUtils = new TestModeContinuousTestingMavenTestUtils(running); + ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion(); + // This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures, + // so we need to check the pass count explicitly + Assertions.assertEquals(0, results.getTestsFailed()); + Assertions.assertEquals(9, results.getTestsPassed()); + } + +} diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/pom.xml b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/pom.xml new file mode 100644 index 0000000000000..51e300f48813e --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + org.acme + project-using-test-template-from-extension + 999-SNAPSHOT + + ${compiler-plugin.version} + false + quarkus-bom + 11 + UTF-8 + UTF-8 + ${surefire-plugin.version} + @project.version + + + + + io.quarkus + ${quarkus.bom.artifact-id} + ${quarkus.version} + pom + import + + + + + + io.quarkus + quarkus-vertx-http + + + + io.quarkus + quarkus-rest-client-reactive-jackson + + + io.quarkus + quarkus-junit5 + test + + + + io.quarkus + integration-test-extension-that-defines-junit-test-extensions + \${project.version} + test + + + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus.version} + true + + + + build + generate-code + generate-code-tests + + + + + + maven-compiler-plugin + \${compiler-plugin.version} + + + -parameters + + + + + maven-surefire-plugin + \${surefire-plugin.version} + + + org.jboss.logmanager.LogManager + \${maven.home} + + + + + + + + native + + + native + + + + + + maven-failsafe-plugin + \${surefire-plugin.version} + + + + integration-test + verify + + + + \${project.build.directory}/${project.build.finalName}-runner + org.jboss.logmanager.LogManager + \${maven.home} + + + + + + + + + native + + + + diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/java/org/acme/InjectableBean.java b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/java/org/acme/InjectableBean.java new file mode 100644 index 0000000000000..5a79fad09d5c7 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/java/org/acme/InjectableBean.java @@ -0,0 +1,7 @@ +package org.acme; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class InjectableBean { +} diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/resources/META-INF/resources/index.html b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000000000..b80fe3dc62642 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,16 @@ + + + + + + getting-started - 1.0-SNAPSHOT + + + +

+ The application is ready. +
+ + + + \ No newline at end of file diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/resources/application.properties b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/resources/application.properties new file mode 100644 index 0000000000000..442095ca8410c --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/main/resources/application.properties @@ -0,0 +1 @@ +quarkus.test.continuous-testing=enabled \ No newline at end of file diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/test/java/org/acme/QuarkusTestAccessingBeanInCallback.java b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/test/java/org/acme/QuarkusTestAccessingBeanInCallback.java new file mode 100644 index 0000000000000..cba8e4ff906cd --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-callback-from-extension/src/test/java/org/acme/QuarkusTestAccessingBeanInCallback.java @@ -0,0 +1,42 @@ +package org.acme; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import jakarta.inject.Inject; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@ExtendWith(CallbackInvokingInterceptor.class) +public class QuarkusTestAccessingBeanInCallback { + + @Inject + InjectableBean bean; + + // Crude validation that the callback happened; if we are run with different phases in different classloaders this will fail, but that's a problem anyway + boolean callbackHappened = false; + + @Callback + public void callback() { + // Callbacks invoked by test frameworks should be able to see injected beans + assertNotNull(bean, "A method invoked by a test interceptor should have access to CDI beans"); + + } + + // Checks that if a template isn't used, we can see the bean + @Test + public void beansShouldBeInjected() { + // The main interest here is in the callback, but do a sense check of the injected bean + assertNotNull(bean, "With no test framework involved, the injected bean should be present"); + } + + @Test + public void callbackShouldBeInvoked() { + assertTrue(callbackHappened, "Either the callback did not happen, or it happened in a different classloader"); + } + +} diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/README.md b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/README.md new file mode 100644 index 0000000000000..088e734eb0b04 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/README.md @@ -0,0 +1,21 @@ +You can run this sample project independently to debug issues. This project is a filtered resource, so you will need to +run from the filtered output directory, not the source directory ( +usually `target/test-classes/projects/happy-knitter-processed`). + +Use + +```bash +mvn verify +``` + +or, for continuous testing and dev mode, + +```bash +mvn quarkus:dev +``` + +If you do want to run in the source directory, you will need to edit `pom.xml` to add temporary versions for these +properties: + +- `quarkus.version` +- `project.version` \ No newline at end of file diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/pom.xml b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/pom.xml new file mode 100644 index 0000000000000..9e4b6efe79432 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + test-application + project-using-test-parameter-injection + 999-SNAPSHOT + + + ${compiler-plugin.version} + false + 11 + UTF-8 + UTF-8 + quarkus-bom + ${surefire-plugin.version} + @project.version + + + + + io.quarkus + ${quarkus.bom.artifact-id} + ${quarkus.version} + pom + import + + + + + + io.quarkus + quarkus-vertx-http + + + + io.quarkus + quarkus-rest-client-reactive-jackson + + + io.quarkus + quarkus-junit5 + test + + + io.quarkus + integration-test-extension-that-defines-junit-test-extensions + ${quarkus.version} + test + + + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus.version} + true + + + + build + + + + + + maven-compiler-plugin + \${compiler-plugin.version} + + + -parameters + + + + + maven-surefire-plugin + \${surefire-plugin.version} + + + org.jboss.logmanager.LogManager + + \${maven.home} + + + + + + + + native + + + native + + + + + + maven-failsafe-plugin + \${surefire-plugin.version} + + + + integration-test + verify + + + + \${project.build.directory}/\${project.build.finalName}-runner + org.jboss.logmanager.LogManager + + \${maven.home} + + + + + + + + + native + + + + diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/main/resources/META-INF/resources/index.html b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000000000..d9204260dfb37 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,15 @@ + + + + + getting-started - 1.0-SNAPSHOT + + + +
+ The application is ready. +
+ + + + \ No newline at end of file diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/main/resources/application.properties b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/main/resources/application.properties new file mode 100644 index 0000000000000..9e0b5c5fcead3 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/main/resources/application.properties @@ -0,0 +1,2 @@ +quarkus.test.continuous-testing=enabled +quarkus.rest-client.alpaca-api.url=http://localhost:8085/ diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/test/java/org/acme/InjectableQuarkusTest.java b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/test/java/org/acme/InjectableQuarkusTest.java new file mode 100644 index 0000000000000..5dec9aca20e3c --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-parameter-injection/src/test/java/org/acme/InjectableQuarkusTest.java @@ -0,0 +1,18 @@ +package org.acme; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@ExtendWith(MyParameterResolver.class) +public class InjectableQuarkusTest { + + @Test + public void testParameterIsPassedIn(InjectableParameter param) { + assertNotNull(param); + } +} diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/pom.xml b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/pom.xml new file mode 100644 index 0000000000000..62f14c2968090 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + org.acme + project-using-test-template-from-extension + 999-SNAPSHOT + + ${compiler-plugin.version} + false + quarkus-bom + 11 + UTF-8 + UTF-8 + ${surefire-plugin.version} + @project.version + + + + + io.quarkus + ${quarkus.bom.artifact-id} + ${quarkus.version} + pom + import + + + + + + io.quarkus + quarkus-vertx-http + + + + io.quarkus + quarkus-rest-client-reactive-jackson + + + io.quarkus + quarkus-junit5 + test + + + + io.quarkus + integration-test-extension-that-defines-junit-test-extensions + ${quarkus.version} + test + + + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus.version} + true + + + + build + generate-code + generate-code-tests + + + + + + maven-compiler-plugin + \${compiler-plugin.version} + + + -parameters + + + + + maven-surefire-plugin + \${surefire-plugin.version} + + + org.jboss.logmanager.LogManager + \${maven.home} + + + + + + + + native + + + native + + + + + + maven-failsafe-plugin + \${surefire-plugin.version} + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + org.jboss.logmanager.LogManager + \${maven.home} + + + + + + + + + native + + + + diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/main/resources/META-INF/resources/index.html b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000000000..b80fe3dc62642 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,16 @@ + + + + + + getting-started - 1.0-SNAPSHOT + + + +
+ The application is ready. +
+ + + + \ No newline at end of file diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/main/resources/application.properties b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/main/resources/application.properties new file mode 100644 index 0000000000000..442095ca8410c --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/main/resources/application.properties @@ -0,0 +1 @@ +quarkus.test.continuous-testing=enabled \ No newline at end of file diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/NormalQuarkusTest.java b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/NormalQuarkusTest.java new file mode 100644 index 0000000000000..74c7976a691a0 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/NormalQuarkusTest.java @@ -0,0 +1,23 @@ +package org.acme; + +import java.lang.annotation.Annotation; +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; + +/** + * Sense check - do we see the added annotation without parameterization? + */ +@QuarkusTest +public class NormalQuarkusTest { + + @Test + void executionAnnotationCheckingTestTemplate() { + Annotation[] myAnnotations = this.getClass().getAnnotations(); + Assertions.assertTrue(Arrays.toString(myAnnotations).contains("AnnotationAddedByExtension"), + "The test execution does not see the annotation, only sees " + Arrays.toString(myAnnotations)); + } +} diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/TemplatedNormalTest.java b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/TemplatedNormalTest.java new file mode 100644 index 0000000000000..e58a235635a33 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/TemplatedNormalTest.java @@ -0,0 +1,67 @@ +package org.acme; + +import java.lang.annotation.Annotation; +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.ExtensionContext; + +// No QuarkusTest annotation + +/** + * It's likely we would never expect this to work; unit tests which don't have a @QuarkusTest + * annotation would not be able to + * benefit from bytecode manipulations from extensions. + */ +public class TemplatedNormalTest { + + @TestTemplate + @ExtendWith(MyContextProvider.class) + void verificationTestTemplate(ExtensionContext context) { + Annotation[] contextAnnotations = context.getRequiredTestClass() + .getAnnotations(); + Annotation[] myAnnotations = this.getClass() + .getAnnotations(); + + Assertions.assertEquals(myAnnotations.length, contextAnnotations.length, + "The test template sees a different version of the class than the test execution" + + Arrays.toString(myAnnotations) + " vs " + Arrays.toString( + contextAnnotations)); + } + + @TestTemplate + @ExtendWith(MyContextProvider.class) + void classloaderIntrospectionTestTemplate(ExtensionContext context) { + ClassLoader loader = this.getClass() + .getClassLoader(); + ClassLoader contextLoader = context.getRequiredTestClass() + .getClassLoader(); + + Assertions.assertEquals(loader, contextLoader, + "The test template is using a different classloader to the actual test."); + } + + @TestTemplate + @ExtendWith(MyContextProvider.class) + void contextAnnotationCheckingTestTemplate(ExtensionContext context) { + Annotation[] contextAnnotations = context.getRequiredTestClass() + .getAnnotations(); + Assertions.assertTrue(Arrays.toString(contextAnnotations) + .contains("AnnotationAddedByExtension"), + "The JUnit extension context does not see the annotation, only sees " + Arrays.toString( + contextAnnotations)); + } + + @TestTemplate + @ExtendWith(MyContextProvider.class) + void executionAnnotationCheckingTestTemplate(ExtensionContext context) { + Annotation[] myAnnotations = this.getClass() + .getAnnotations(); + Assertions.assertTrue(Arrays.toString(myAnnotations) + .contains("AnnotationAddedByExtension"), + "The test execution does not see the annotation, only sees " + Arrays.toString( + myAnnotations)); + } +} diff --git a/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/TemplatedQuarkusTest.java b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/TemplatedQuarkusTest.java new file mode 100644 index 0000000000000..1858ba4bb78a9 --- /dev/null +++ b/integration-tests/test-extension/tests/src/test/resources-filtered/projects/project-using-test-template-from-extension/src/test/java/org/acme/TemplatedQuarkusTest.java @@ -0,0 +1,54 @@ +package org.acme; + +import java.lang.annotation.Annotation; +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.ExtensionContext; + +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class TemplatedQuarkusTest { + + @TestTemplate + @ExtendWith(MyContextProvider.class) + void verificationTestTemplate(ExtensionContext context) { + Annotation[] contextAnnotations = context.getRequiredTestClass().getAnnotations(); + Annotation[] myAnnotations = this.getClass().getAnnotations(); + + Assertions.assertEquals(myAnnotations.length, contextAnnotations.length, + "The test template sees a different version of the class than the test execution" + + Arrays.toString(myAnnotations) + " (execution) vs " + Arrays.toString(contextAnnotations) + + " (context)"); + } + + @TestTemplate + @ExtendWith(MyContextProvider.class) + void classloaderIntrospectionTestTemplate(ExtensionContext context) { + ClassLoader loader = this.getClass().getClassLoader(); + ClassLoader contextLoader = context.getRequiredTestClass().getClassLoader(); + + Assertions.assertEquals(loader, contextLoader, + "The test template is using a different classloader to the actual test. Execution loader: " + loader + + " vs template context loader " + contextLoader); + } + + @TestTemplate + @ExtendWith(MyContextProvider.class) + void contextAnnotationCheckingTestTemplate(ExtensionContext context) { + Annotation[] contextAnnotations = context.getRequiredTestClass().getAnnotations(); + Assertions.assertTrue(Arrays.toString(contextAnnotations).contains("AnnotationAddedByExtension"), + "The JUnit extension context does not see the annotation, only sees " + Arrays.toString(contextAnnotations)); + } + + @TestTemplate + @ExtendWith(MyContextProvider.class) + void executionAnnotationCheckingTestTemplate(ExtensionContext context) { + Annotation[] myAnnotations = this.getClass().getAnnotations(); + Assertions.assertTrue(Arrays.toString(myAnnotations).contains("AnnotationAddedByExtension"), + "The test execution does not see the annotation, only sees " + Arrays.toString(myAnnotations)); + } +} diff --git a/test-framework/devmode-test-utils/src/main/java/io/quarkus/test/devmode/util/DevModeTestUtils.java b/test-framework/devmode-test-utils/src/main/java/io/quarkus/test/devmode/util/DevModeClient.java similarity index 83% rename from test-framework/devmode-test-utils/src/main/java/io/quarkus/test/devmode/util/DevModeTestUtils.java rename to test-framework/devmode-test-utils/src/main/java/io/quarkus/test/devmode/util/DevModeClient.java index 22c21602bc37d..a364f8fd0b3b0 100644 --- a/test-framework/devmode-test-utils/src/main/java/io/quarkus/test/devmode/util/DevModeTestUtils.java +++ b/test-framework/devmode-test-utils/src/main/java/io/quarkus/test/devmode/util/DevModeClient.java @@ -20,7 +20,17 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -public class DevModeTestUtils { +public class DevModeClient { + + private final int port; + + public DevModeClient() { + this(8080); + } + + public DevModeClient(int port) { + this.port = port; + } public static List killDescendingProcesses() { // Warning: Do not try to evaluate ProcessHandle.Info.arguments() or .commandLine() as those are always empty on Windows: @@ -51,7 +61,7 @@ public static void filter(File input, Map variables) throws IOEx FileUtils.write(input, data, "UTF-8"); } - public static void awaitUntilServerDown() { + public void awaitUntilServerDown() { await().atMost(1, TimeUnit.MINUTES).until(() -> { try { get(); // Ignore result on purpose @@ -62,11 +72,11 @@ public static void awaitUntilServerDown() { }); } - public static String getHttpResponse() { + public String getHttpResponse() { return getHttpResponse(() -> null); } - public static String getHttpResponse(Supplier brokenReason) { + public String getHttpResponse(Supplier brokenReason) { AtomicReference resp = new AtomicReference<>(); await() .pollDelay(1, TimeUnit.SECONDS) @@ -90,11 +100,11 @@ public static String getHttpResponse(Supplier brokenReason) { return resp.get(); } - public static String getHttpErrorResponse() { + public String getHttpErrorResponse() { return getHttpErrorResponse(() -> null); } - public static String getHttpErrorResponse(Supplier brokenReason) { + public String getHttpErrorResponse(Supplier brokenReason) { AtomicReference resp = new AtomicReference<>(); await() .pollDelay(1, TimeUnit.SECONDS) @@ -117,23 +127,23 @@ public static String getHttpErrorResponse(Supplier brokenReason) { return resp.get(); } - public static String getHttpResponse(String path) { + public String getHttpResponse(String path) { return getHttpResponse(path, false); } - public static String getHttpResponse(String path, Supplier brokenReason) { + public String getHttpResponse(String path, Supplier brokenReason) { return getHttpResponse(path, false, brokenReason); } - public static String getHttpResponse(String path, boolean allowError) { + public String getHttpResponse(String path, boolean allowError) { return getHttpResponse(path, allowError, () -> null); } - public static String getHttpResponse(String path, boolean allowError, Supplier brokenReason) { + public String getHttpResponse(String path, boolean allowError, Supplier brokenReason) { return getHttpResponse(path, allowError, brokenReason, 1, TimeUnit.MINUTES); } - public static String getHttpResponse(String path, boolean allowError, Supplier brokenReason, long timeout, + public String getHttpResponse(String path, boolean allowError, Supplier brokenReason, long timeout, TimeUnit tu) { AtomicReference resp = new AtomicReference<>(); await() @@ -145,7 +155,7 @@ public static String getHttpResponse(String path, boolean allowError, Supplier { try { - URL url = new URL("http://localhost:8080" + ((path.startsWith("/") ? path : "/" + path))); + URL url = new URL("http://localhost:" + port + ((path.startsWith("/") ? path : "/" + path))); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // the default Accept header used by HttpURLConnection is not compatible with RESTEasy negotiation as it uses q=.2 connection.setRequestProperty("Accept", "text/html, *; q=0.2, */*; q=0.2"); @@ -195,13 +205,13 @@ public static boolean getHttpResponse(String path, int expectedStatus, long time } // will fail if it receives any http response except the expected one - public static boolean getStrictHttpResponse(String path, int expectedStatus) { + public boolean getStrictHttpResponse(String path, int expectedStatus) { AtomicBoolean code = new AtomicBoolean(); await() .pollDelay(1, TimeUnit.SECONDS) .atMost(5, TimeUnit.MINUTES).until(() -> { try { - URL url = new URL("http://localhost:8080" + ((path.startsWith("/") ? path : "/" + path))); + URL url = new URL("http://localhost:" + port + ((path.startsWith("/") ? path : "/" + path))); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // the default Accept header used by HttpURLConnection is not compatible with RESTEasy negotiation as it uses q=.2 connection.setRequestProperty("Accept", "text/html, *; q=0.2, */*; q=0.2"); @@ -215,17 +225,17 @@ public static boolean getStrictHttpResponse(String path, int expectedStatus) { return code.get(); } - public static String get() throws IOException { - return get("http://localhost:8080"); + public String get() throws IOException { + return get("http://localhost:" + port); } - public static String get(String urlStr) throws IOException { + public String get(String urlStr) throws IOException { return IOUtils.toString(new URL(urlStr), StandardCharsets.UTF_8); } - public static boolean isCode(String path, int code) { + public boolean isCode(String path, int code) { try { - URL url = new URL("http://localhost:8080" + ((path.startsWith("/") ? path : "/" + path))); + URL url = new URL("http://localhost:" + port + ((path.startsWith("/") ? path : "/" + path))); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // the default Accept header used by HttpURLConnection is not compatible with // RESTEasy negotiation as it uses q=.2 diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java index a8b09609f4eff..36dd27b173e87 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java @@ -29,7 +29,7 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import io.quarkus.devtools.testing.RegistryClientTestHelper; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public class MojoTestBase { @@ -128,7 +128,7 @@ public static File initProject(String name, String output) { } public static void filter(File input, Map variables) throws IOException { - DevModeTestUtils.filter(input, variables); + DevModeClient.filter(input, variables); } public Map getEnv() { diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckMojoTestBase.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckMojoTestBase.java index f766699a1b8dd..80bf2c3118d5a 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckMojoTestBase.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckMojoTestBase.java @@ -17,12 +17,21 @@ import io.quarkus.maven.it.verifier.MavenProcessInvocationResult; import io.quarkus.maven.it.verifier.RunningInvoker; import io.quarkus.runtime.LaunchMode; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; public class RunAndCheckMojoTestBase extends MojoTestBase { protected RunningInvoker running; protected File testDir; + protected DevModeClient devModeClient = new DevModeClient(getPort()); + private static final int DEFAULT_PORT = 8080; + + /** + * Default to port 8080, but allow subtests to override. + */ + protected int getPort() { + return DEFAULT_PORT; + } @AfterEach public void cleanup() { @@ -33,7 +42,7 @@ public void shutdownTheApp() { if (running != null) { running.stop(); } - DevModeTestUtils.awaitUntilServerDown(); + devModeClient.awaitUntilServerDown(); } /** @@ -67,6 +76,15 @@ protected void run(boolean performCompile, LaunchMode mode, boolean skipAnalytic if (skipAnalytics) { args.add("-Dquarkus.analytics.disabled=true"); } + + // If the test has set a different port, pass that on to the application + if (getPort() != DEFAULT_PORT) { + int port = getPort(); + int testPort = getPort() + 1; + args.add("-Dquarkus.http.port=" + port); + args.add("-Dquarkus.http.test-port=" + testPort); + } + boolean hasDebugOptions = false; for (String option : options) { args.add(option); @@ -104,12 +122,12 @@ protected void runAndCheck(boolean performCompile, LaunchMode mode, String... op throws FileNotFoundException, MavenInvocationException { run(performCompile, mode, options); - String resp = DevModeTestUtils.getHttpResponse(); + String resp = devModeClient.getHttpResponse(); assertThat(resp).containsIgnoringCase("ready").containsIgnoringCase("application").containsIgnoringCase("org.acme") .containsIgnoringCase("1.0-SNAPSHOT"); - String greeting = DevModeTestUtils.getHttpResponse("/app/hello"); + String greeting = devModeClient.getHttpResponse("/app/hello"); assertThat(greeting).containsIgnoringCase("hello"); } @@ -120,7 +138,7 @@ protected void runAndExpectError() throws MavenInvocationException { mvnRunProps.setProperty("debug", "false"); running.execute(Arrays.asList("compile", "quarkus:dev"), Map.of(), mvnRunProps); - DevModeTestUtils.getHttpErrorResponse(); + devModeClient.getHttpErrorResponse(); } protected void install(final File baseDir, final boolean performClean) throws Exception { @@ -137,11 +155,11 @@ protected void install(final File baseDir, final boolean performClean) throws Ex } public String getHttpErrorResponse() { - return DevModeTestUtils.getHttpErrorResponse(getBrokenReason()); + return devModeClient.getHttpErrorResponse(getBrokenReason()); } public String getHttpResponse() { - return DevModeTestUtils.getHttpResponse(getBrokenReason()); + return devModeClient.getHttpResponse(getBrokenReason()); } protected Supplier getBrokenReason() { diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckWithAgentMojoTestBase.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckWithAgentMojoTestBase.java index 97134d1c05084..290e0db39764a 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckWithAgentMojoTestBase.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/RunAndCheckWithAgentMojoTestBase.java @@ -21,7 +21,7 @@ import io.quarkus.maven.it.verifier.MavenProcessInvocationResult; import io.quarkus.maven.it.verifier.RunningInvoker; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; import io.quarkus.utilities.JavaBinFinder; public class RunAndCheckWithAgentMojoTestBase extends MojoTestBase { @@ -31,6 +31,8 @@ public class RunAndCheckWithAgentMojoTestBase extends MojoTestBase { protected File agentDir; protected File testDir; + protected DevModeClient devModeClient = new DevModeClient(); + @AfterEach public void cleanup() throws IOException { try { @@ -43,7 +45,7 @@ public void cleanup() throws IOException { if (runningAgent != null) { runningAgent.stop(); } - DevModeTestUtils.awaitUntilServerDown(); + devModeClient.awaitUntilServerDown(); } } @@ -70,7 +72,7 @@ protected void runAndCheck(String... options) throws FileNotFoundException, Mave // Wait until server up await() .pollDelay(1, TimeUnit.SECONDS) - .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/", 200)); + .atMost(1, TimeUnit.MINUTES).until(() -> devModeClient.getHttpResponse("/", 200)); runningAgent = new RunningInvoker(agentDir, false); runningAgent.execute(Arrays.asList("compile", "quarkus:remote-dev"), Collections.emptyMap()); diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/continuoustesting/ContinuousTestingMavenTestUtils.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/continuoustesting/ContinuousTestingMavenTestUtils.java index a83b92193abc4..969adc811bd77 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/continuoustesting/ContinuousTestingMavenTestUtils.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/continuoustesting/ContinuousTestingMavenTestUtils.java @@ -16,22 +16,26 @@ */ public class ContinuousTestingMavenTestUtils { - static final URL DEFAULT; + private static final int DEFAULT_PORT = 8080; - static { + long runtToWaitFor = 1; + ObjectMapper objectMapper = new ObjectMapper(); + final URL url; + + protected static URL getDefaultUrl(int port) { try { - DEFAULT = new URL("http://localhost:8080/q/dev-v1/io.quarkus.quarkus-vertx-http/tests/status"); + return new URL("http://localhost:" + port + "/q/dev-v1/io.quarkus.quarkus-vertx-http/tests/status"); } catch (MalformedURLException e) { throw new RuntimeException(e); } } - long runtToWaitFor = 1; - ObjectMapper objectMapper = new ObjectMapper(); - final URL url; - public ContinuousTestingMavenTestUtils() { - this(DEFAULT); + this(getDefaultUrl(DEFAULT_PORT)); + } + + public ContinuousTestingMavenTestUtils(int port) { + this(getDefaultUrl(port)); } public ContinuousTestingMavenTestUtils(URL url) { diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java index 8577b26662456..204662b1d7406 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java @@ -21,7 +21,7 @@ import org.apache.maven.shared.invoker.PrintStreamLogger; import io.quarkus.maven.it.MojoTestBase; -import io.quarkus.test.devmode.util.DevModeTestUtils; +import io.quarkus.test.devmode.util.DevModeClient; /** * Implementation of verifier using a forked process that is still running while verifying. The process is stop when @@ -97,7 +97,7 @@ public void stop() { // Kill all processes that were (indirectly) spawned by the current process. // It's important to do it this way (instead of calling result.destroy() first) // because otherwise children of that process can become orphaned zombies. - DevModeTestUtils.killDescendingProcesses(); + DevModeClient.killDescendingProcesses(); // This is now more or less "symbolic" since the previous call should have also killed that result's process. result.destroy(); }