Skip to content

Commit 5f59b85

Browse files
authored
Merge pull request #46871 from gsmet/junit-5.12
Upgrade to JUnit 5.12.1
2 parents efda381 + 85ce4f5 commit 5f59b85

File tree

27 files changed

+1070
-1011
lines changed

27 files changed

+1070
-1011
lines changed

bom/application/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
<db2-jdbc.version>12.1.0.0</db2-jdbc.version>
129129
<shrinkwrap.version>1.2.6</shrinkwrap.version>
130130
<hamcrest.version>2.2</hamcrest.version><!-- The version needs to be compatible with both REST Assured and Awaitility -->
131-
<junit.jupiter.version>5.10.5</junit.jupiter.version>
131+
<junit.jupiter.version>5.12.1</junit.jupiter.version>
132132
<infinispan.version>15.0.14.Final</infinispan.version>
133133
<infinispan.protostream.version>5.0.13.Final</infinispan.protostream.version>
134134
<caffeine.version>3.2.0</caffeine.version>
@@ -174,7 +174,7 @@
174174
<quarkus-spring-data-api.version>3.4</quarkus-spring-data-api.version>
175175
<quarkus-spring-security-api.version>6.4</quarkus-spring-security-api.version>
176176
<quarkus-spring-boot-api.version>3.4</quarkus-spring-boot-api.version>
177-
<mockito.version>5.12.0</mockito.version>
177+
<mockito.version>5.16.1</mockito.version>
178178
<jna.version>5.8.0</jna.version><!-- should satisfy both testcontainers and mongodb -->
179179
<quarkus-security.version>2.2.1</quarkus-security.version>
180180
<keycloak-client.version>26.0.4</keycloak-client.version>

devtools/gradle/gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugin-publish = "1.3.1"
55
kotlin = "2.0.21"
66
smallrye-config = "3.12.4"
77

8-
junit5 = "5.10.5"
8+
junit5 = "5.12.1"
99
assertj = "3.27.3"
1010

1111
[plugins]

extensions/devservices/oidc/src/main/java/io/quarkus/devservices/oidc/OidcDevServicesProcessor.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ private static boolean shouldNotStartServer(OidcDevServicesConfig devServicesCon
145145
LOG.debug("Not starting Dev Services for OIDC as it has been disabled in the config");
146146
return true;
147147
}
148-
if (devServicesConfig.enabled().isEmpty() && dockerStatusBuildItem.isContainerRuntimeAvailable()) {
149-
LOG.debug("Not starting Dev Services for OIDC as detected support the container functionality");
150-
return true;
151-
}
152148
if (!isOidcEnabled()) {
153149
LOG.debug("Not starting Dev Services for OIDC as OIDC extension has been disabled in the config");
154150
return true;
@@ -165,6 +161,11 @@ private static boolean shouldNotStartServer(OidcDevServicesConfig devServicesCon
165161
LOG.debug("Not starting Dev Services for OIDC as 'quarkus.oidc.provider' has been provided");
166162
return true;
167163
}
164+
if (devServicesConfig.enabled().isEmpty() && dockerStatusBuildItem.isContainerRuntimeAvailable()) {
165+
LOG.debug(
166+
"Not starting Dev Services for OIDC as a container runtime is available and a Keycloak Dev Services will be started");
167+
return true;
168+
}
168169
return false;
169170
}
170171

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package io.quarkus.restclient.configuration;
2+
3+
import java.util.Set;
4+
5+
import jakarta.enterprise.inject.spi.Bean;
6+
import jakarta.enterprise.inject.spi.BeanManager;
7+
import jakarta.inject.Singleton;
8+
9+
import org.eclipse.microprofile.rest.client.inject.RestClient;
10+
import org.junit.jupiter.api.Assertions;
11+
import org.junit.jupiter.api.Test;
12+
13+
import io.quarkus.arc.Arc;
14+
15+
/**
16+
* Tests clients configured with MicroProfile-style configuration.
17+
*/
18+
abstract class AbstractRestClientsTest {
19+
20+
@RestClient
21+
EchoClientWithConfigKey clientWithConfigKey;
22+
23+
@RestClient
24+
EchoClient fullClassNameClient;
25+
26+
@Test
27+
public void clientWithConfigKeyShouldConnect() {
28+
Assertions.assertEquals("Hello", clientWithConfigKey.echo("Hello"));
29+
}
30+
31+
@Test
32+
void clientWithConfigShouldHaveSingletonScope() {
33+
verifyClientScope(EchoClientWithConfigKey.class, Singleton.class);
34+
}
35+
36+
@Test
37+
public void fullClassNameClientShouldConnect() {
38+
Assertions.assertEquals("Hello", fullClassNameClient.echo("Hello"));
39+
}
40+
41+
@Test
42+
void fullClassNameClientShouldHaveSingletonScope() {
43+
verifyClientScope(EchoClient.class, Singleton.class);
44+
}
45+
46+
static void verifyClientScope(Class clientInterface, Class expectedScope) {
47+
BeanManager beanManager = Arc.container().beanManager();
48+
Set<Bean<?>> beans = beanManager.getBeans(clientInterface, RestClient.LITERAL);
49+
Bean<?> resolvedBean = beanManager.resolve(beans);
50+
Assertions.assertEquals(expectedScope, resolvedBean.getScope());
51+
}
52+
53+
}
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,18 @@
11
package io.quarkus.restclient.configuration;
22

3-
import java.util.Set;
4-
5-
import jakarta.enterprise.inject.spi.Bean;
6-
import jakarta.enterprise.inject.spi.BeanManager;
7-
import jakarta.inject.Singleton;
8-
9-
import org.eclipse.microprofile.rest.client.inject.RestClient;
10-
import org.junit.jupiter.api.Assertions;
11-
import org.junit.jupiter.api.Test;
123
import org.junit.jupiter.api.extension.RegisterExtension;
134

14-
import io.quarkus.arc.Arc;
155
import io.quarkus.test.QuarkusUnitTest;
166

177
/**
188
* Tests clients configured with MicroProfile-style configuration.
199
*/
20-
public class MPRestClientsTest {
10+
public class MPRestClientsTest extends AbstractRestClientsTest {
2111

2212
@RegisterExtension
2313
static final QuarkusUnitTest config = new QuarkusUnitTest()
2414
.withApplicationRoot((jar) -> jar
2515
.addClasses(EchoResource.class,
2616
EchoClient.class, EchoClientWithConfigKey.class, ShortNameEchoClient.class))
2717
.withConfigurationResource("mp-restclients-test-application.properties");
28-
29-
@RestClient
30-
EchoClientWithConfigKey clientWithConfigKey;
31-
32-
@RestClient
33-
EchoClient fullClassNameClient;
34-
35-
@Test
36-
public void clientWithConfigKeyShouldConnect() {
37-
Assertions.assertEquals("Hello", clientWithConfigKey.echo("Hello"));
38-
}
39-
40-
@Test
41-
void clientWithConfigShouldHaveSingletonScope() {
42-
verifyClientScope(EchoClientWithConfigKey.class, Singleton.class);
43-
}
44-
45-
@Test
46-
public void fullClassNameClientShouldConnect() {
47-
Assertions.assertEquals("Hello", fullClassNameClient.echo("Hello"));
48-
}
49-
50-
@Test
51-
void fullClassNameClientShouldHaveSingletonScope() {
52-
verifyClientScope(EchoClient.class, Singleton.class);
53-
}
54-
55-
static void verifyClientScope(Class clientInterface, Class expectedScope) {
56-
BeanManager beanManager = Arc.container().beanManager();
57-
Set<Bean<?>> beans = beanManager.getBeans(clientInterface, RestClient.LITERAL);
58-
Bean<?> resolvedBean = beanManager.resolve(beans);
59-
Assertions.assertEquals(expectedScope, resolvedBean.getScope());
60-
}
61-
6218
}

extensions/resteasy-classic/resteasy-client/deployment/src/test/java/io/quarkus/restclient/configuration/QuarkusRestClientsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Tests clients configured with Quarkus-style configuration.
1414
*/
15-
public class QuarkusRestClientsTest extends MPRestClientsTest {
15+
public class QuarkusRestClientsTest extends AbstractRestClientsTest {
1616

1717
@RegisterExtension
1818
static final QuarkusUnitTest config = new QuarkusUnitTest()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package io.quarkus.resteasy.reactive.jackson.deployment.test;
2+
3+
import jakarta.inject.Singleton;
4+
5+
import org.hamcrest.Matchers;
6+
import org.junit.jupiter.api.Test;
7+
8+
import com.fasterxml.jackson.annotation.JsonInclude;
9+
import com.fasterxml.jackson.databind.DeserializationFeature;
10+
import com.fasterxml.jackson.databind.ObjectMapper;
11+
12+
import io.quarkus.jackson.ObjectMapperCustomizer;
13+
import io.restassured.RestAssured;
14+
15+
public abstract class AbstractNonAbsentSerializationTest {
16+
17+
@Singleton
18+
public static class NonAbsentObjectMapperCustomizer implements ObjectMapperCustomizer {
19+
20+
@Override
21+
public void customize(ObjectMapper objectMapper) {
22+
objectMapper
23+
.enable(DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES)
24+
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
25+
.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
26+
}
27+
}
28+
29+
@Test
30+
public void testObject() {
31+
RestAssured.get("/json-include/my-object")
32+
.then()
33+
.statusCode(200)
34+
.contentType("application/json")
35+
.body("name", Matchers.equalTo("name"))
36+
.body("description", Matchers.equalTo("description"))
37+
.body("map.test", Matchers.equalTo(1))
38+
.body("strings[0]", Matchers.equalTo("test"));
39+
}
40+
41+
@Test
42+
public void testEmptyObject() {
43+
RestAssured.get("/json-include/my-object-empty")
44+
.then()
45+
.statusCode(200)
46+
.contentType("application/json")
47+
.body("name", Matchers.nullValue())
48+
.body("description", Matchers.nullValue())
49+
.body("map", Matchers.anEmptyMap())
50+
.body("strings", Matchers.hasSize(0));
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package io.quarkus.resteasy.reactive.jackson.deployment.test;
2+
3+
import jakarta.inject.Singleton;
4+
5+
import org.hamcrest.Matchers;
6+
import org.junit.jupiter.api.Test;
7+
8+
import com.fasterxml.jackson.annotation.JsonInclude;
9+
import com.fasterxml.jackson.databind.DeserializationFeature;
10+
import com.fasterxml.jackson.databind.ObjectMapper;
11+
12+
import io.quarkus.jackson.ObjectMapperCustomizer;
13+
import io.restassured.RestAssured;
14+
15+
public abstract class AbstractNonEmptySerializationTest {
16+
17+
@Singleton
18+
public static class NonEmptyObjectMapperCustomizer implements ObjectMapperCustomizer {
19+
20+
@Override
21+
public void customize(ObjectMapper objectMapper) {
22+
objectMapper
23+
.enable(DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES)
24+
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
25+
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
26+
}
27+
}
28+
29+
@Test
30+
public void testObject() {
31+
RestAssured.get("/json-include/my-object")
32+
.then()
33+
.statusCode(200)
34+
.contentType("application/json")
35+
.body("name", Matchers.equalTo("name"))
36+
.body("description", Matchers.equalTo("description"))
37+
.body("map.test", Matchers.equalTo(1))
38+
.body("strings[0]", Matchers.equalTo("test"));
39+
}
40+
41+
@Test
42+
public void testEmptyObject() {
43+
RestAssured.get("/json-include/my-object-empty")
44+
.then()
45+
.statusCode(200)
46+
.contentType("application/json")
47+
.body(Matchers.is("{}"));
48+
}
49+
}

0 commit comments

Comments
 (0)