Merge branch '3.1.x'

This commit is contained in:
Ryan Baxter
2024-10-05 08:51:12 -04:00
13 changed files with 46 additions and 57 deletions

15
pom.xml
View File

@@ -19,7 +19,7 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -155,19 +155,6 @@
<scope>import</scope>
</dependency>
<!--Spring Boot 3.1 uses Mockito 5.x. Mockito 5.x has removed support for mockito-inline.-->
<!--https://github.com/mockito/mockito/issues/2877-->
<!--We need to support both Boot 3.0.x and Boot 3.1.x with Spring Cloud K8s 3.0.x-->
<!--To maintain compatibility we manage the version ourselves-->
<!-- TODO Remove this and all references to mockito-inline in the next minor -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-bom</artifactId>
<version>${mockito-inline.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>

View File

@@ -51,7 +51,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -106,7 +106,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -45,7 +45,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

View File

@@ -99,7 +99,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -33,13 +33,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<!-- in favor of mockito-inline -->
<exclusions>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
@@ -49,7 +42,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -42,13 +42,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<!-- In favor of mockito-inline -->
<exclusions>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
@@ -68,7 +61,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -84,13 +84,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<!-- in favor of mockito-inline -->
<exclusions>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
@@ -122,7 +115,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -19,8 +19,11 @@ package org.springframework.cloud.kubernetes.fabric8.config.locator_retry.config
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mockito;
import org.mockito.internal.util.MockUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
@@ -56,8 +59,20 @@ class ConfigDataConfigRetryEnabledTests extends ConfigRetryEnabled {
@BeforeEach
void beforeEach() {
psl = propertySourceLocator;
verifiablePsl = spy(propertySourceLocator.getConfigMapPropertySourceLocator());
propertySourceLocator.setConfigMapPropertySourceLocator(verifiablePsl);
// latest Mockito does not allow to do something like Mockito.spy(spy)
// so this works around that
if (!MockUtil.isSpy(propertySourceLocator.getConfigMapPropertySourceLocator())) {
verifiablePsl = spy(propertySourceLocator.getConfigMapPropertySourceLocator());
propertySourceLocator.setConfigMapPropertySourceLocator(verifiablePsl);
}
else {
verifiablePsl = propertySourceLocator.getConfigMapPropertySourceLocator();
}
}
@AfterEach
void afterEach() {
Mockito.reset(verifiablePsl);
}
}

View File

@@ -43,7 +43,7 @@ class BootstrapSecretsRetryEnabledTests extends SecretsRetryEnabled {
private Fabric8SecretsPropertySourceLocator propertySourceLocator;
@BeforeEach
public void beforeEach() {
void beforeEach() {
psl = propertySourceLocator;
verifiablePsl = propertySourceLocator;
}

View File

@@ -19,8 +19,11 @@ package org.springframework.cloud.kubernetes.fabric8.config.retry.secrets_enable
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mockito;
import org.mockito.internal.util.MockUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.kubernetes.commons.config.ConfigDataRetryableSecretsPropertySourceLocator;
@@ -49,10 +52,22 @@ class ConfigDataSecretsRetryEnabledTests extends SecretsRetryEnabled {
}
@BeforeEach
public void beforeEach() {
void beforeEach() {
psl = configDataRetryableSecretsPropertySourceLocator;
verifiablePsl = spy(configDataRetryableSecretsPropertySourceLocator.getSecretsPropertySourceLocator());
configDataRetryableSecretsPropertySourceLocator.setSecretsPropertySourceLocator(verifiablePsl);
// latest Mockito does not allow to do something like Mockito.spy(spy)
// so this works around that
if (!MockUtil.isSpy(configDataRetryableSecretsPropertySourceLocator.getSecretsPropertySourceLocator())) {
verifiablePsl = spy(configDataRetryableSecretsPropertySourceLocator.getSecretsPropertySourceLocator());
configDataRetryableSecretsPropertySourceLocator.setSecretsPropertySourceLocator(verifiablePsl);
}
else {
verifiablePsl = configDataRetryableSecretsPropertySourceLocator.getSecretsPropertySourceLocator();
}
}
@AfterEach
void afterEach() {
Mockito.reset(verifiablePsl);
}
}

View File

@@ -53,18 +53,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<!-- in favor of mockito-inline -->
<exclusions>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

View File

@@ -50,7 +50,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>