Don't use MockitoJUnitRunner
Replace `@RunWith(MockitoJUnitRunner.class)` with direct Mockito initialization since the running doesn't support parallel test execution.
This commit is contained in:
parent
77f6b4c983
commit
99c6194e17
|
|
@ -22,9 +22,8 @@ import org.junit.Before;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
|
@ -34,7 +33,6 @@ import static org.mockito.BDDMockito.given;
|
|||
*
|
||||
* @author Mattias Severson
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DiskSpaceHealthIndicatorTests {
|
||||
|
||||
static final long THRESHOLD_BYTES = 1024;
|
||||
|
|
@ -49,6 +47,7 @@ public class DiskSpaceHealthIndicatorTests {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
given(this.fileMock.exists()).willReturn(true);
|
||||
given(this.fileMock.canRead()).willReturn(true);
|
||||
this.healthIndicator = new DiskSpaceHealthIndicator(
|
||||
|
|
|
|||
|
|
@ -34,10 +34,9 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
|
|||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
|
@ -48,7 +47,6 @@ import static org.mockito.Matchers.any;
|
|||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ElasticsearchHealthIndicatorTests {
|
||||
|
||||
@Mock
|
||||
|
|
@ -66,9 +64,9 @@ public class ElasticsearchHealthIndicatorTests {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
given(this.client.admin()).willReturn(this.admin);
|
||||
given(this.admin.cluster()).willReturn(this.cluster);
|
||||
|
||||
this.indicator = new ElasticsearchHealthIndicator(this.client, this.properties);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
package org.springframework.boot.actuate.metrics.writer;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
@ -31,7 +31,6 @@ import static org.mockito.Mockito.verify;
|
|||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DefaultCounterServiceTests {
|
||||
|
||||
private final MetricWriter repository = mock(MetricWriter.class);
|
||||
|
|
@ -42,6 +41,11 @@ public class DefaultCounterServiceTests {
|
|||
@Captor
|
||||
private ArgumentCaptor<Delta<Number>> captor;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incrementWithExistingCounter() {
|
||||
this.service.increment("counter.foo");
|
||||
|
|
|
|||
|
|
@ -20,9 +20,8 @@ import java.util.List;
|
|||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
|
|
@ -48,7 +47,6 @@ import static org.mockito.BDDMockito.given;
|
|||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class EnableAutoConfigurationImportSelectorTests {
|
||||
|
||||
private final EnableAutoConfigurationImportSelector importSelector = new EnableAutoConfigurationImportSelector();
|
||||
|
|
@ -64,7 +62,8 @@ public class EnableAutoConfigurationImportSelectorTests {
|
|||
private AnnotationAttributes annotationAttributes;
|
||||
|
||||
@Before
|
||||
public void configureImportSelector() {
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.importSelector.setBeanFactory(this.beanFactory);
|
||||
this.importSelector.setEnvironment(this.environment);
|
||||
this.importSelector.setResourceLoader(new DefaultResourceLoader());
|
||||
|
|
|
|||
|
|
@ -22,9 +22,8 @@ import java.lang.annotation.RetentionPolicy;
|
|||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
|
|
@ -44,7 +43,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
|||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ImportAutoConfigurationImportSelectorTests {
|
||||
|
||||
private final ImportAutoConfigurationImportSelector importSelector = new ImportAutoConfigurationImportSelector();
|
||||
|
|
@ -55,7 +53,8 @@ public class ImportAutoConfigurationImportSelectorTests {
|
|||
private Environment environment;
|
||||
|
||||
@Before
|
||||
public void configureImportSelector() {
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.importSelector.setBeanFactory(this.beanFactory);
|
||||
this.importSelector.setEnvironment(this.environment);
|
||||
this.importSelector.setResourceLoader(new DefaultResourceLoader());
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ package org.springframework.boot.cli.compiler.dependencies;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
|
@ -31,7 +31,6 @@ import static org.mockito.BDDMockito.given;
|
|||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CompositeDependencyManagementTests {
|
||||
|
||||
@Mock
|
||||
|
|
@ -40,6 +39,11 @@ public class CompositeDependencyManagementTests {
|
|||
@Mock
|
||||
private DependencyManagement dependencyManagement2;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownSpringBootVersion() {
|
||||
given(this.dependencyManagement1.getSpringBootVersion()).willReturn(null);
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ import org.eclipse.aether.RepositorySystem;
|
|||
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
|
||||
import org.eclipse.aether.repository.LocalRepository;
|
||||
import org.eclipse.aether.repository.LocalRepositoryManager;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -43,7 +43,6 @@ import static org.mockito.Mockito.verify;
|
|||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GrapeRootRepositorySystemSessionAutoConfigurationTests {
|
||||
|
||||
private DefaultRepositorySystemSession session = MavenRepositorySystemUtils
|
||||
|
|
@ -52,6 +51,11 @@ public class GrapeRootRepositorySystemSessionAutoConfigurationTests {
|
|||
@Mock
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noLocalRepositoryWhenNoGrapeRoot() {
|
||||
given(this.repositorySystem.newLocalRepositoryManager(eq(this.session),
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ import org.eclipse.aether.repository.LocalRepository;
|
|||
import org.eclipse.aether.repository.LocalRepositoryManager;
|
||||
import org.eclipse.aether.repository.Proxy;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.boot.cli.testutil.SystemProperties;
|
||||
|
|
@ -50,7 +50,6 @@ import static org.mockito.Matchers.eq;
|
|||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
|
||||
|
||||
@Rule
|
||||
|
|
@ -59,6 +58,11 @@ public class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
|
|||
@Mock
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicSessionCustomization() throws SettingsBuildingException {
|
||||
assertSessionCustomization("src/test/resources/maven-settings/basic");
|
||||
|
|
|
|||
|
|
@ -22,9 +22,8 @@ import org.junit.Before;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestExecution;
|
||||
|
|
@ -41,7 +40,6 @@ import static org.mockito.BDDMockito.given;
|
|||
* @author Rob Winch
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class HttpHeaderInterceptorTests {
|
||||
|
||||
@Rule
|
||||
|
|
@ -66,7 +64,8 @@ public class HttpHeaderInterceptorTests {
|
|||
private MockHttpServletRequest httpRequest;
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
public void setup() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.body = new byte[] {};
|
||||
this.httpRequest = new MockHttpServletRequest();
|
||||
this.request = new ServletServerHttpRequest(this.httpRequest);
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package org.springframework.boot.test.mock.mockito;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.test.context.ContextCustomizer;
|
||||
|
||||
|
|
@ -29,11 +29,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MockitoContextCustomizerFactoryTests {
|
||||
|
||||
private final MockitoContextCustomizerFactory factory = new MockitoContextCustomizerFactory();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getContextCustomizerWithoutAnnotationReturnsCustomizer()
|
||||
throws Exception {
|
||||
|
|
@ -57,8 +61,8 @@ public class MockitoContextCustomizerFactoryTests {
|
|||
ContextCustomizer same = this.factory
|
||||
.createContextCustomizer(WithSameMockBeanAnnotation.class, null);
|
||||
assertThat(customizer).isNotNull();
|
||||
ContextCustomizer different = this.factory.createContextCustomizer(
|
||||
WithDifferentMockBeanAnnotation.class, null);
|
||||
ContextCustomizer different = this.factory
|
||||
.createContextCustomizer(WithDifferentMockBeanAnnotation.class, null);
|
||||
assertThat(different).isNotNull();
|
||||
assertThat(customizer.hashCode()).isEqualTo(same.hashCode());
|
||||
assertThat(customizer.hashCode()).isNotEqualTo(different.hashCode());
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ package org.springframework.boot;
|
|||
import java.io.PrintStream;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.boot.Banner.Mode;
|
||||
import org.springframework.boot.testutil.InternalOutputCapture;
|
||||
|
|
@ -47,7 +47,6 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Michael Stummvoll
|
||||
* @author Michael Simons
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class BannerTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
|
@ -65,6 +64,11 @@ public class BannerTests {
|
|||
@Captor
|
||||
private ArgumentCaptor<Class<?>> sourceClassCaptor;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultBanner() throws Exception {
|
||||
SpringApplication application = new SpringApplication(Config.class);
|
||||
|
|
|
|||
Loading…
Reference in New Issue