Skip to content

Commit

Permalink
Merge pull request #42811 from gsmet/3.14.1-backports-1
Browse files Browse the repository at this point in the history
[3.14] 3.14.1 backports 1
  • Loading branch information
gsmet authored Aug 28, 2024
2 parents e14797b + c48cb11 commit 253bee8
Show file tree
Hide file tree
Showing 256 changed files with 691 additions and 595 deletions.
8 changes: 4 additions & 4 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<opentracing-mongo.version>0.1.5</opentracing-mongo.version>
<opentelemetry.version>1.39.0</opentelemetry.version>
<opentelemetry-alpha.version>2.5.0-alpha</opentelemetry-alpha.version>
<opentelemetry-semconv.version>1.25.0-alpha</opentelemetry-semconv.version>
<opentelemetry-semconv.version>1.26.0-alpha</opentelemetry-semconv.version>
<quarkus-http.version>5.3.1</quarkus-http.version>
<micrometer.version>1.12.5</micrometer.version><!-- keep in sync with hdrhistogram -->
<hdrhistogram.version>2.1.12</hdrhistogram.version><!-- keep in sync with micrometer -->
Expand All @@ -55,7 +55,7 @@
<smallrye-health.version>4.1.0</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.10.0</smallrye-open-api.version>
<smallrye-graphql.version>2.9.1</smallrye-graphql.version>
<smallrye-graphql.version>2.9.2</smallrye-graphql.version>
<smallrye-fault-tolerance.version>6.4.0</smallrye-fault-tolerance.version>
<smallrye-jwt.version>4.5.3</smallrye-jwt.version>
<smallrye-context-propagation.version>2.1.2</smallrye-context-propagation.version>
Expand Down Expand Up @@ -120,10 +120,10 @@
<cronutils.version>9.2.1</cronutils.version>
<quartz.version>2.3.2</quartz.version>
<h2.version>2.3.232</h2.version> <!-- When updating, needs to be matched in io.quarkus.hibernate.orm.runtime.config.DialectVersions -->
<postgresql-jdbc.version>42.7.3</postgresql-jdbc.version>
<postgresql-jdbc.version>42.7.4</postgresql-jdbc.version>
<mariadb-jdbc.version>3.4.1</mariadb-jdbc.version>
<mysql-jdbc.version>8.3.0</mysql-jdbc.version>
<mssql-jdbc.version>12.8.0.jre11</mssql-jdbc.version>
<mssql-jdbc.version>12.8.1.jre11</mssql-jdbc.version>
<adal4j.version>1.6.7</adal4j.version>
<oracle-jdbc.version>23.5.0.24.07</oracle-jdbc.version>
<derby-jdbc.version>10.16.1.1</derby-jdbc.version>
Expand Down
11 changes: 10 additions & 1 deletion devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ public Optional<String> checkMissingCommand(CommandLine root, String[] args) {
.collect(Collectors.toList());
if (!unmatchedSubcommands.isEmpty()) {
missingCommand.append("-").append(unmatchedSubcommands.get(0));
return Optional.of(missingCommand.toString());
// We don't want the root itself to be added to the result
return Optional.of(stripRootPrefix(missingCommand.toString(), root.getCommandName() + "-"));
}

currentParseResult = currentParseResult.subcommand();
Expand All @@ -193,6 +194,14 @@ public Optional<String> checkMissingCommand(CommandLine root, String[] args) {
}
}

private static String stripRootPrefix(String command, String rootPrefix) {
if (!command.startsWith(rootPrefix)) {
return command;
}

return command.substring(rootPrefix.length());
}

@Override
public Integer call() throws Exception {
output.info("%n@|bold Quarkus CLI|@ version %s", Version.clientVersion());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.acme;

import io.quarkus.test.common.WithTestResource;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import io.quarkus.test.junit.QuarkusTest;

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/config-secrets.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Use the Quarkus CLI command to add a new encrypted value or encrypt an existent
****
[source, bash]
----
quarkus config set --encrypt --name=my.secret --value=1234
quarkus config set --encrypt my.secret 1234
----
_For more information about how to install the Quarkus CLI and use it, please refer to xref:cli-tooling.adoc[the Quarkus CLI guide]._
Expand Down
8 changes: 4 additions & 4 deletions docs/src/main/asciidoc/datasource.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,8 @@ This will allow you to test your application even when it is compiled into a nat

. Add the following specific annotation on any class in your integration tests for running integration tests in both JVM or native executables:
+
* `@WithTestResource(H2DatabaseTestResource.class)`
* `@WithTestResource(DerbyDatabaseTestResource.class)`
* `@QuarkusTestResource(H2DatabaseTestResource.class)`
* `@QuarkusTestResource(DerbyDatabaseTestResource.class)`
+
This ensures that the test suite starts and terminates the managed database in a separate process as required for test execution.
+
Expand All @@ -710,10 +710,10 @@ This ensures that the test suite starts and terminates the managed database in a
----
package my.app.integrationtests.db;
import io.quarkus.test.common.WithTestResource;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.h2.H2DatabaseTestResource;
@WithTestResource(H2DatabaseTestResource.class)
@QuarkusTestResource(H2DatabaseTestResource.class)
public class TestResources {
}
----
Expand Down
32 changes: 15 additions & 17 deletions docs/src/main/asciidoc/getting-started-testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public class MockGreetingProfile implements QuarkusTestProfile { <1>
* Additional {@link QuarkusTestResourceLifecycleManager} classes (along with their init params) to be used from this
* specific test profile.
*
* If this method is not overridden, then only the {@link QuarkusTestResourceLifecycleManager} classes enabled via the {@link io.quarkus.test.common.WithTestResource} class
* If this method is not overridden, then only the {@link QuarkusTestResourceLifecycleManager} classes enabled via the {@link io.quarkus.test.common.QuarkusTestResource} class
* annotation will be used for the tests using this profile (which is the same behavior as tests that don't use a profile at all).
*/
@Override
Expand Down Expand Up @@ -603,7 +603,7 @@ public class MockGreetingProfile implements QuarkusTestProfile { <1>
public boolean disableApplicationLifecycleObservers() {
return false;
}
@Produces <2>
public ExternalService mockExternalService() {
return new ExternalService("mock");
Expand Down Expand Up @@ -1086,17 +1086,15 @@ If you are using Quarkus Security, check out the xref:security-testing.adoc[Test
[[quarkus-test-resource]]
== Starting services before the Quarkus application starts

A very common need is to start some services on which your Quarkus application depends, before the Quarkus application starts for testing. To address this need, Quarkus provides `@io.quarkus.test.common.WithTestResource` and `io.quarkus.test.common.QuarkusTestResourceLifecycleManager`.

When a test annotated with `@WithTestResource`, Quarkus will run the corresponding `QuarkusTestResourceLifecycleManager` before the test.
A very common need is to start some services on which your Quarkus application depends, before the Quarkus application starts for testing. To address this need, Quarkus provides `@io.quarkus.test.common.QuarkusTestResource` and `io.quarkus.test.common.QuarkusTestResourceLifecycleManager`.

IMPORTANT: By default, `@WithTestResource` applies only to the test on which the annotation is placed. Each test that is annotated with `@WithTestResource` will result in the application being re-augmented and restarted
(in a similar fashion as happens in dev-mode when a change is detected) in order to incorporate the settings configured by the annotation. This means that if there are many instances of the annotation used throughout the testsuite,
test execution speed will be impacted by these restarts.
By simply annotating any test in the test suite with `@QuarkusTestResource`, Quarkus will run the corresponding `QuarkusTestResourceLifecycleManager` before any tests are run.
A test suite is also free to utilize multiple `@QuarkusTestResource` annotations, in which case all the corresponding `QuarkusTestResourceLifecycleManager` objects will be run before the tests.

NOTE: Test resources are applied for a given test class or custom profile. To activate for all tests you can use `@WithTestResource(restrictToAnnotatedClass = false)`.
NOTE: Test resources are global, even if they are defined on a test class or custom profile, which means they will all be activated for all tests, even though we do
remove duplicates. If you want to only enable a test resource on a single test class or test profile, you can use `@QuarkusTestResource(restrictToAnnotatedClass = true)`.

NOTE: When using multiple test resources they can be started concurrently. For that you need to set `@WithTestResource(parallel = true)`.
NOTE: When using multiple test resources, they can be started concurrently. For that you need to set `@QuarkusTestResource(parallel = true)`.

Quarkus provides a few implementations of `QuarkusTestResourceLifecycleManager` out of the box (see `io.quarkus.test.h2.H2DatabaseTestResource` which starts an H2 database, or `io.quarkus.test.kubernetes.client.KubernetesServerTestResource` which starts a mock Kubernetes API server),
but it is common to create custom implementations to address specific application needs.
Expand All @@ -1113,7 +1111,7 @@ If for example you have a test like the following:
[source,java]
----
@QuarkusTest
@WithTestResource(MyWireMockResource.class)
@QuarkusTestResource(MyWireMockResource.class)
public class MyTest {
@InjectWireMock // this a custom annotation you are defining in your own application
Expand Down Expand Up @@ -1164,15 +1162,15 @@ any necessary injections into the test class.

=== Annotation-based test resources

It is possible to write test resources that are enabled and configured using annotations. This is enabled by placing the `@WithTestResource`
It is possible to write test resources that are enabled and configured using annotations. This is enabled by placing the `@QuarkusTestResource`
on an annotation which will be used to enable and configure the test resource.

For example, this defines the `@WithKubernetesTestServer` annotation, which you can use on your tests to activate the `KubernetesServerTestResource`,
but only for the annotated test class. You can also place them on your `QuarkusTestProfile` test profiles.

[source,java]
----
@WithTestResource(KubernetesServerTestResource.class)
@QuarkusTestResource(KubernetesServerTestResource.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface WithKubernetesTestServer {
Expand Down Expand Up @@ -1216,12 +1214,12 @@ public class KubernetesServerTestResource
}
----

If you want to make the annotation repeatable, the containing annotation type must be annotated with `@WithTestResourceRepeatable`.
If you want to make the annotation repeatable, the containing annotation type must be annotated with `@QuarkusTestResourceRepeatable`.
For example, this would define a repeatable `@WithRepeatableTestResource` annotation.

[source,java]
----
@WithTestResource(KubernetesServerTestResource.class)
@QuarkusTestResource(KubernetesServerTestResource.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Repeatable(WithRepeatableTestResource.List.class)
Expand All @@ -1231,7 +1229,7 @@ public @interface WithRepeatableTestResource {
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@WithTestResourceRepeatable(WithRepeatableTestResource.class)
@QuarkusTestResourceRepeatable(WithRepeatableTestResource.class)
@interface List {
WithRepeatableTestResource[] value();
}
Expand Down Expand Up @@ -1416,7 +1414,7 @@ public class CustomResource implements QuarkusTestResourceLifecycleManager, DevS
}
----

`CustomResource` would be activated on a `@QuarkusIntegrationTest` using `@WithTestResource` as is described in the corresponding section of this doc.
`CustomResource` would be activated on a `@QuarkusIntegrationTest` using `@QuarkusTestResource` as is described in the corresponding section of this doc.

=== Executing against a running application

Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/kafka-schema-registry-avro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ what we send.
----
package org.acme.kafka;
import io.quarkus.test.common.WithTestResource;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
Expand Down Expand Up @@ -607,7 +607,7 @@ public class KafkaAndSchemaRegistryTestResource implements QuarkusTestResourceLi
[source,java]
----
@QuarkusTest
@WithTestResource(KafkaAndSchemaRegistryTestResource.class)
@QuarkusTestResource(KafkaAndSchemaRegistryTestResource.class)
public class MovieResourceTest {
...
}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/kafka-schema-registry-json-schema.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ what we send.
----
package org.acme.kafka;
import io.quarkus.test.common.WithTestResource;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
Expand Down Expand Up @@ -635,7 +635,7 @@ public class KafkaAndSchemaRegistryTestResource implements QuarkusTestResourceLi
[source,java]
----
@QuarkusTest
@WithTestResource(KafkaAndSchemaRegistryTestResource.class)
@QuarkusTestResource(KafkaAndSchemaRegistryTestResource.class)
public class MovieResourceTest {
...
}
Expand Down
12 changes: 6 additions & 6 deletions docs/src/main/asciidoc/kafka.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,7 @@ Create a Quarkus Test using the test resource created above:
import static org.awaitility.Awaitility.await;
@QuarkusTest
@WithTestResource(KafkaTestResourceLifecycleManager.class)
@QuarkusTestResource(KafkaTestResourceLifecycleManager.class)
class BaristaTest {
@Inject
Expand Down Expand Up @@ -2295,7 +2295,7 @@ public class BeverageProcessor {
import static org.awaitility.Awaitility.await;
@QuarkusTest
@WithTestResource(KafkaTestResourceLifecycleManager.class)
@QuarkusTestResource(KafkaTestResourceLifecycleManager.class)
class BaristaTest {
@Inject
Expand Down Expand Up @@ -2380,7 +2380,7 @@ For using `KafkaCompanion` API in tests, start by adding the following dependenc

which provides `io.quarkus.test.kafka.KafkaCompanionResource` - an implementation of `io.quarkus.test.common.QuarkusTestResourceLifecycleManager`.

Then use `@WithTestResource` to configure the Kafka Companion in tests, for example:
Then use `@QuarkusTestResource` to configure the Kafka Companion in tests, for example:

[source, java]
----
Expand All @@ -2391,15 +2391,15 @@ import java.util.UUID;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.junit.jupiter.api.Test;
import io.quarkus.test.common.WithTestResource;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.kafka.InjectKafkaCompanion;
import io.quarkus.test.kafka.KafkaCompanionResource;
import io.smallrye.reactive.messaging.kafka.companion.ConsumerTask;
import io.smallrye.reactive.messaging.kafka.companion.KafkaCompanion;
@QuarkusTest
@WithTestResource(KafkaCompanionResource.class)
@QuarkusTestResource(KafkaCompanionResource.class)
public class OrderProcessorTest {
@InjectKafkaCompanion // <1>
Expand Down Expand Up @@ -2430,7 +2430,7 @@ If the Kafka Dev Service is available during tests, `KafkaCompanionResource` use
The configuration of the created Kafka broker can be customized using `@ResourceArg`, for example:
[source,java]
----
@WithTestResource(value = KafkaCompanionResource.class, initArgs = {
@QuarkusTestResource(value = KafkaCompanionResource.class, initArgs = {
@ResourceArg(name = "strimzi.kafka.image", value = "quay.io/strimzi-test-container/test-container:0.106.0-kafka-3.7.0"), // Image name
@ResourceArg(name = "kafka.port", value = "9092"), // Fixed port for kafka, by default it will be exposed on a random port
@ResourceArg(name = "kraft", value = "true"), // Enable Kraft mode
Expand Down
6 changes: 3 additions & 3 deletions docs/src/main/asciidoc/kubernetes-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public class MyTest {
}
----

Alternately, you can create an extension of the `KubernetesServerTestResource` class to ensure all your `@QuarkusTest` enabled test classes share the same mock server setup via the `WithTestResource` annotation:
Alternately, you can create an extension of the `KubernetesServerTestResource` class to ensure all your `@QuarkusTest` enabled test classes share the same mock server setup via the `QuarkusTestResource` annotation:

[source%nowrap,java]
----
Expand All @@ -278,7 +278,7 @@ public class CustomKubernetesMockServerTestResource extends KubernetesServerTest
and use this in your other test classes as follows:
[source%nowrap,java]
----
@WithTestResource(CustomKubernetesMockServerTestResource.class)
@QuarkusTestResource(CustomKubernetesMockServerTestResource.class)
@QuarkusTest
public class KubernetesClientTest {
Expand Down Expand Up @@ -478,7 +478,7 @@ Mock support is also provided in a similar fashion:

[source, java]
----
@WithTestResource(OpenShiftMockServerTestResource.class)
@QuarkusTestResource(OpenShiftMockServerTestResource.class)
@QuarkusTest
public class OpenShiftClientTest {
Expand Down
7 changes: 5 additions & 2 deletions docs/src/main/asciidoc/logging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,13 @@ This includes the globally configured handlers and formatters.
====
[source, properties]
----
quarkus.log.handlers=console,mylog
quarkus.log.handlers=con,mylog
quarkus.log.handler.console.con.enable=true
quarkus.log.handler.file.mylog.enable=true
----
In this example, the root category is configured to use two handlers: `console` and `mylog`.
In this example, the root category is configured to use two named handlers: `con` and `mylog`.
====

.An example of a per-category configuration:
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/messaging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ Create a `@QuarkusTest` using the test resource created above:

[source, java]
----
import io.quarkus.test.common.WithTestResource;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.smallrye.reactive.messaging.memory.InMemoryConnector;
import io.smallrye.reactive.messaging.memory.InMemorySink;
Expand All @@ -718,7 +718,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.awaitility.Awaitility.await;
@QuarkusTest
@WithTestResource(InMemoryConnectorLifecycleManager.class)
@QuarkusTestResource(InMemoryConnectorLifecycleManager.class)
class MyMessagingApplicationTest {
@Inject
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/mongodb.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,14 @@ To set the desired port MongoDB will listen to when it is launched, the followin
[source,java]
----
@WithTestResource(value = MongoTestResource.class, initArgs = @ResourceArg(name = MongoTestResource.PORT, value = "27017"))
@QuarkusTestResource(value = MongoTestResource.class, initArgs = @ResourceArg(name = MongoTestResource.PORT, value = "27017"))
----
To set the desired MongoDB version that will be launched, the following code should be used:
[source,java]
----
@WithTestResource(value = MongoTestResource.class, initArgs = @ResourceArg(name = MongoTestResource.VERSION, value = "V5_0"))
@QuarkusTestResource(value = MongoTestResource.class, initArgs = @ResourceArg(name = MongoTestResource.VERSION, value = "V5_0"))
----
The string value used can be any of one of the `de.flapdoodle.embed.mongo.distribution.Version` or `de.flapdoodle.embed.mongo.distribution.Version.Main` enums.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/native-and-ssl.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ which configures our REST client to connect to an SSL REST service.
For the purposes of this guide, we also need to remove the configuration that starts the embedded WireMock server that stubs REST client responses so the tests actually propagate calls to the https://stage.code.quarkus.io/api. Update the test file `src/test/java/org/acme/rest/client/ExtensionsResourceTest.java` and remove the line:
[source,java]
----
@WithTestResource(WireMockExtensions.class)
@QuarkusTestResource(WireMockExtensions.class)
----
from the `ExtensionsResourceTest` class.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/observability-devservices-lgtm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ And for the least 'auto-magical' usage in the tests, simply disable both (Dev Re
quarkus.observability.enabled=false
----

And then explicitly list LGTM Dev Resource in the test as a `@WithTestResource` resource:
And then explicitly list LGTM Dev Resource in the test as a `@QuarkusTestResource` resource:
[source, java]
----
@QuarkusTest
@WithTestResource(LgtmResource.class)
@QuarkusTestResource(value = LgtmResource.class, restrictToAnnotatedClass = true)
@TestProfile(QuarkusTestResourceTestProfile.class)
public class LgtmLifecycleTest extends LgtmTestBase {
}
Expand Down
Loading

0 comments on commit 253bee8

Please sign in to comment.