Skip to content

Commit a9e8116

Browse files
committed
Only check for Mockito once
Update `MockReset` so that checking for Mockito only happens once. Closes gh-14260
1 parent 02f2f62 commit a9e8116

File tree

1 file changed

+5
-2
lines changed
  • spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito

1 file changed

+5
-2
lines changed

spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockReset.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,6 +53,9 @@ public enum MockReset {
5353
*/
5454
NONE;
5555

56+
private static final boolean MOCKITO_PRESENT = ClassUtils
57+
.isPresent("org.mockito.internal.util.MockUtil", null);
58+
5659
/**
5760
* Create {@link MockSettings settings} to be used with mocks where reset should occur
5861
* before each test method runs.
@@ -103,7 +106,7 @@ public static MockSettings apply(MockReset reset, MockSettings settings) {
103106
@SuppressWarnings("rawtypes")
104107
static MockReset get(Object mock) {
105108
MockReset reset = MockReset.NONE;
106-
if (ClassUtils.isPresent("org.mockito.internal.util.MockUtil", null)) {
109+
if (MOCKITO_PRESENT) {
107110
if (Mockito.mockingDetails(mock).isMock()) {
108111
MockCreationSettings settings = MockitoApi.get().getMockSettings(mock);
109112
List listeners = settings.getInvocationListeners();

0 commit comments

Comments
 (0)