Skip to content

Commit 80974a0

Browse files
authored
drop mockito-inline dependency (#1753)
* drop dependency * fix tests * checkstyle * clean-up
1 parent ba5d26b commit 80974a0

File tree

13 files changed

+45
-57
lines changed

13 files changed

+45
-57
lines changed

pom.xml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
<surefire-reports-directory>surefire-reports</surefire-reports-directory>
7070
<failsafe-reports-directory>failsafe-reports</failsafe-reports-directory>
7171
<!-- Dependency Versions -->
72-
<mockito-inline.version>4.8.1</mockito-inline.version>
7372
<spring-cloud-commons.version>4.1.5-SNAPSHOT</spring-cloud-commons.version>
7473
<spring-cloud-config.version>4.1.4-SNAPSHOT</spring-cloud-config.version>
7574
<spring-cloud-bus.version>4.1.3-SNAPSHOT</spring-cloud-bus.version>
@@ -155,19 +154,6 @@
155154
<scope>import</scope>
156155
</dependency>
157156

158-
<!--Spring Boot 3.1 uses Mockito 5.x. Mockito 5.x has removed support for mockito-inline.-->
159-
<!--https://github.com/mockito/mockito/issues/2877-->
160-
<!--We need to support both Boot 3.0.x and Boot 3.1.x with Spring Cloud K8s 3.0.x-->
161-
<!--To maintain compatibility we manage the version ourselves-->
162-
<!-- TODO Remove this and all references to mockito-inline in the next minor -->
163-
<dependency>
164-
<groupId>org.mockito</groupId>
165-
<artifactId>mockito-bom</artifactId>
166-
<version>${mockito-inline.version}</version>
167-
<type>pom</type>
168-
<scope>import</scope>
169-
</dependency>
170-
171157
<dependency>
172158
<groupId>org.codehaus.groovy</groupId>
173159
<artifactId>groovy-all</artifactId>

spring-cloud-kubernetes-client-autoconfig/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</dependency>
5252
<dependency>
5353
<groupId>org.mockito</groupId>
54-
<artifactId>mockito-inline</artifactId>
54+
<artifactId>mockito-core</artifactId>
5555
<scope>test</scope>
5656
</dependency>
5757
<dependency>

spring-cloud-kubernetes-client-config/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
</dependency>
107107
<dependency>
108108
<groupId>org.mockito</groupId>
109-
<artifactId>mockito-inline</artifactId>
109+
<artifactId>mockito-core</artifactId>
110110
<scope>test</scope>
111111
</dependency>
112112
<dependency>

spring-cloud-kubernetes-client-loadbalancer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
<dependency>
4747
<groupId>org.mockito</groupId>
48-
<artifactId>mockito-inline</artifactId>
48+
<artifactId>mockito-core</artifactId>
4949
<scope>test</scope>
5050
</dependency>
5151

spring-cloud-kubernetes-commons/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
</dependency>
100100
<dependency>
101101
<groupId>org.mockito</groupId>
102-
<artifactId>mockito-inline</artifactId>
102+
<artifactId>mockito-core</artifactId>
103103
<scope>test</scope>
104104
</dependency>
105105
<dependency>

spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@
3333
<dependency>
3434
<groupId>org.springframework.boot</groupId>
3535
<artifactId>spring-boot-starter-test</artifactId>
36-
<!-- in favor of mockito-inline -->
37-
<exclusions>
38-
<exclusion>
39-
<groupId>org.mockito</groupId>
40-
<artifactId>mockito-core</artifactId>
41-
</exclusion>
42-
</exclusions>
4336
<scope>test</scope>
4437
</dependency>
4538
<dependency>
@@ -49,7 +42,7 @@
4942
</dependency>
5043
<dependency>
5144
<groupId>org.mockito</groupId>
52-
<artifactId>mockito-inline</artifactId>
45+
<artifactId>mockito-core</artifactId>
5346
<scope>test</scope>
5447
</dependency>
5548
<dependency>

spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configuration-watcher/pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@
4242
<groupId>org.springframework.boot</groupId>
4343
<artifactId>spring-boot-starter-test</artifactId>
4444
<scope>test</scope>
45-
<!-- In favor of mockito-inline -->
46-
<exclusions>
47-
<exclusion>
48-
<groupId>org.mockito</groupId>
49-
<artifactId>mockito-core</artifactId>
50-
</exclusion>
51-
</exclusions>
5245
</dependency>
5346
<dependency>
5447
<groupId>org.wiremock</groupId>
@@ -68,7 +61,7 @@
6861
</dependency>
6962
<dependency>
7063
<groupId>org.mockito</groupId>
71-
<artifactId>mockito-inline</artifactId>
64+
<artifactId>mockito-core</artifactId>
7265
<scope>test</scope>
7366
</dependency>
7467
<dependency>

spring-cloud-kubernetes-fabric8-autoconfig/pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@
8484
<dependency>
8585
<groupId>org.springframework.boot</groupId>
8686
<artifactId>spring-boot-starter-test</artifactId>
87-
<!-- in favor of mockito-inline -->
88-
<exclusions>
89-
<exclusion>
90-
<groupId>org.mockito</groupId>
91-
<artifactId>mockito-core</artifactId>
92-
</exclusion>
93-
</exclusions>
9487
<scope>test</scope>
9588
</dependency>
9689
<dependency>
@@ -122,7 +115,7 @@
122115

123116
<dependency>
124117
<groupId>org.mockito</groupId>
125-
<artifactId>mockito-inline</artifactId>
118+
<artifactId>mockito-core</artifactId>
126119
<scope>test</scope>
127120
</dependency>
128121
<dependency>

spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/locator_retry/config_retry_enabled/ConfigDataConfigRetryEnabledTests.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
import io.fabric8.kubernetes.client.KubernetesClient;
2020
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
2121
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
22+
import org.junit.jupiter.api.AfterEach;
2223
import org.junit.jupiter.api.BeforeAll;
2324
import org.junit.jupiter.api.BeforeEach;
25+
import org.mockito.Mockito;
26+
import org.mockito.internal.util.MockUtil;
2427

2528
import org.springframework.beans.factory.annotation.Autowired;
2629
import org.springframework.boot.test.mock.mockito.MockBean;
@@ -56,8 +59,20 @@ static void setup() {
5659
@BeforeEach
5760
void beforeEach() {
5861
psl = propertySourceLocator;
59-
verifiablePsl = spy(propertySourceLocator.getConfigMapPropertySourceLocator());
60-
propertySourceLocator.setConfigMapPropertySourceLocator(verifiablePsl);
62+
// latest Mockito does not allow to do something like Mockito.spy(spy)
63+
// so this works around that
64+
if (!MockUtil.isSpy(propertySourceLocator.getConfigMapPropertySourceLocator())) {
65+
verifiablePsl = spy(propertySourceLocator.getConfigMapPropertySourceLocator());
66+
propertySourceLocator.setConfigMapPropertySourceLocator(verifiablePsl);
67+
}
68+
else {
69+
verifiablePsl = propertySourceLocator.getConfigMapPropertySourceLocator();
70+
}
71+
}
72+
73+
@AfterEach
74+
void afterEach() {
75+
Mockito.reset(verifiablePsl);
6176
}
6277

6378
}

spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/retry/secrets_enabled/BootstrapSecretsRetryEnabledTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void setup() {
4343
private Fabric8SecretsPropertySourceLocator propertySourceLocator;
4444

4545
@BeforeEach
46-
public void beforeEach() {
46+
void beforeEach() {
4747
psl = propertySourceLocator;
4848
verifiablePsl = propertySourceLocator;
4949
}

0 commit comments

Comments
 (0)