diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/AdhocTestSuite.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/AdhocTestSuite.java deleted file mode 100644 index a3558df4..00000000 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/AdhocTestSuite.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud; - -import org.junit.Ignore; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import org.springframework.cloud.client.discovery.EnableDiscoveryClientMissingImplTests; -import org.springframework.cloud.client.hypermedia.CloudHypermediaAutoConfigurationIntegrationTests; - -/** - * A test suite for probing weird ordering problems in the tests. - * - * @author Dave Syer - */ -@RunWith(Suite.class) -@SuiteClasses({ EnableDiscoveryClientMissingImplTests.class, CloudHypermediaAutoConfigurationIntegrationTests.class }) -@Ignore -public class AdhocTestSuite { - -} diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelectorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelectorTests.java index 31ec9442..23fbf573 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelectorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelectorTests.java @@ -16,8 +16,8 @@ package org.springframework.cloud.client.discovery; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -43,7 +43,7 @@ public class EnableDiscoveryClientImportSelectorTests { @Mock private AnnotationAttributes annotationAttributes; - @Before + @BeforeEach public void setup() { MockitoAnnotations.initMocks(this); this.importSelector.setBeanClassLoader(getClass().getClassLoader()); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/DiscoveredResourceUnitTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/DiscoveredResourceUnitTests.java index 66fe6325..35484df7 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/DiscoveredResourceUnitTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/DiscoveredResourceUnitTests.java @@ -16,11 +16,11 @@ package org.springframework.cloud.client.hypermedia; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.hateoas.Link; @@ -32,6 +32,7 @@ import static org.assertj.core.api.BDDAssertions.then; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -40,7 +41,7 @@ import static org.mockito.Mockito.when; * @author Oliver Gierke * @author Tim Ysewyn */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class DiscoveredResourceUnitTests { @Mock @@ -57,9 +58,9 @@ public class DiscoveredResourceUnitTests { DiscoveredResource resource; - @Before + @BeforeEach public void setUp() { - when(this.traversal.buildTraversal(any(Traverson.class))).thenReturn(this.builder); + lenient().when(this.traversal.buildTraversal(any(Traverson.class))).thenReturn(this.builder); this.resource = new DiscoveredResource(this.provider, this.traversal); this.resource.setRestOperations(this.operations); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/DynamicServiceInstanceProviderUnitTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/DynamicServiceInstanceProviderUnitTests.java index 1585c5a2..eec0c01c 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/DynamicServiceInstanceProviderUnitTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/DynamicServiceInstanceProviderUnitTests.java @@ -18,10 +18,10 @@ package org.springframework.cloud.client.hypermedia; import java.util.Arrays; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -34,7 +34,7 @@ import static org.mockito.Mockito.when; /** * @author Oliver Gierke */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class DynamicServiceInstanceProviderUnitTests { @Mock diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AutoServiceRegistrationAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AutoServiceRegistrationAutoConfigurationTests.java index bdeb4073..a93a302b 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AutoServiceRegistrationAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AutoServiceRegistrationAutoConfigurationTests.java @@ -20,10 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Map; -import org.hamcrest.Matchers; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.boot.test.util.TestPropertyValues; @@ -32,6 +29,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.util.StringUtils; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.BDDAssertions.then; /** @@ -39,9 +37,6 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class AutoServiceRegistrationAutoConfigurationTests { - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void hasAutoServiceRegistration() { try (AnnotationConfigApplicationContext context = setup(HasAutoServiceRegistrationConfiguration.class)) { @@ -52,12 +47,12 @@ public class AutoServiceRegistrationAutoConfigurationTests { @Test public void noAutoServiceRegistrationAndFailFast() { - this.exception.expect(BeanCreationException.class); - this.exception.expectMessage(Matchers.containsString("no AutoServiceRegistration")); - try (AnnotationConfigApplicationContext context = setup( - "spring.cloud.service-registry.auto-registration.failFast=true")) { - assertNoBean(context); - } + assertThatThrownBy(() -> { + try (AnnotationConfigApplicationContext context = setup( + "spring.cloud.service-registry.auto-registration.failFast=true")) { + assertNoBean(context); + } + }).isInstanceOf(BeanCreationException.class).hasMessageContaining("no AutoServiceRegistration"); } @Test diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/AdhocTestSuite.java b/spring-cloud-context/src/test/java/org/springframework/cloud/AdhocTestSuite.java deleted file mode 100644 index f9cf24cc..00000000 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/AdhocTestSuite.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2012-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud; - -import org.junit.Ignore; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * A test suite for probing weird ordering problems in the tests. - * - * @author Dave Syer - */ -@RunWith(Suite.class) -@SuiteClasses({ org.springframework.cloud.health.RefreshScopeHealthIndicatorTests.class, - org.springframework.cloud.logging.LoggingRebinderTests.class, - org.springframework.cloud.bootstrap.BootstrapSourcesOrderingTests.class, - org.springframework.cloud.bootstrap.BootstrapDisabledAutoConfigurationIntegrationTests.class, - org.springframework.cloud.bootstrap.encrypt.RsaDisabledTests.class, - org.springframework.cloud.bootstrap.encrypt.EncryptorFactoryTests.class, - org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializerTests.class, - org.springframework.cloud.bootstrap.encrypt.EncryptionBootstrapConfigurationTests.class, - org.springframework.cloud.bootstrap.encrypt.EncryptionIntegrationTests.class, - org.springframework.cloud.bootstrap.BootstrapOrderingSpringApplicationJsonIntegrationTests.class, - org.springframework.cloud.bootstrap.config.BootstrapConfigurationTests.class, - org.springframework.cloud.bootstrap.config.BootstrapListenerHierarchyIntegrationTests.class, - org.springframework.cloud.bootstrap.BootstrapOrderingAutoConfigurationIntegrationTests.class, - org.springframework.cloud.bootstrap.MessageSourceConfigurationTests.class, - org.springframework.cloud.bootstrap.BootstrapOrderingCustomPropertySourceIntegrationTests.class, - org.springframework.cloud.endpoint.RefreshEndpointTests.class, - org.springframework.cloud.context.properties.ConfigurationPropertiesRebinderIntegrationTests.class, - org.springframework.cloud.context.properties.ConfigurationPropertiesRebinderProxyIntegrationTests.class, - org.springframework.cloud.context.properties.ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.class, - org.springframework.cloud.context.properties.ConfigurationPropertiesRebinderListIntegrationTests.class, - org.springframework.cloud.context.properties.ConfigurationPropertiesRebinderLifecycleIntegrationTests.class, - org.springframework.cloud.context.named.NamedContextFactoryTests.class, - org.springframework.cloud.context.refresh.ContextRefresherOrderingIntegrationTests.class, - org.springframework.cloud.context.refresh.ContextRefresherIntegrationTests.class, - org.springframework.cloud.context.refresh.ContextRefresherTests.class, - org.springframework.cloud.context.environment.EnvironmentManagerTest.class, - org.springframework.cloud.context.environment.EnvironmentManagerIntegrationTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeConfigurationTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeNullBeanIntegrationTests.class, - org.springframework.cloud.context.scope.refresh.MoreRefreshScopeIntegrationTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeIntegrationTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeConcurrencyTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeScaleTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeLazyIntegrationTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopePureScaleTests.class, - org.springframework.cloud.context.scope.refresh.ImportRefreshScopeIntegrationTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeSerializationTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeListBindingIntegrationTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeWebIntegrationTests.class, - org.springframework.cloud.context.scope.refresh.RefreshScopeConfigurationScaleTests.class, - org.springframework.cloud.context.scope.refresh.RefreshEndpointIntegrationTests.class, - org.springframework.cloud.context.restart.RestartIntegrationTests.class, - org.springframework.cloud.autoconfigure.RefreshAutoConfigurationTests.class, - org.springframework.cloud.autoconfigure.LifecycleMvcAutoConfigurationTests.class, - org.springframework.cloud.autoconfigure.RefreshAutoConfigurationClassPathTests.class, - org.springframework.cloud.autoconfigure.RefreshAutoConfigurationMoreClassPathTests.class }) -@Ignore -public class AdhocTestSuite { - -} diff --git a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/CachingServiceInstanceListSupplierTests.java b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/CachingServiceInstanceListSupplierTests.java index 916432a0..91251b46 100644 --- a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/CachingServiceInstanceListSupplierTests.java +++ b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/CachingServiceInstanceListSupplierTests.java @@ -17,7 +17,6 @@ package org.springframework.cloud.loadbalancer.core; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -36,7 +35,6 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.web.reactive.function.client.WebClient; import static java.time.Duration.ofMillis; @@ -49,7 +47,6 @@ import static org.springframework.cloud.loadbalancer.core.ServiceInstanceListSup * @author Olga Maciaszek-Sharma */ @SpringBootTest(classes = CachingServiceInstanceListSupplierTests.TestConfig.class) -@ExtendWith(SpringExtension.class) class CachingServiceInstanceListSupplierTests { public static final String SERVICE_ID = "test"; diff --git a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/HealthCheckServiceInstanceListSupplierTests.java b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/HealthCheckServiceInstanceListSupplierTests.java index 2dc62798..6814a54a 100644 --- a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/HealthCheckServiceInstanceListSupplierTests.java +++ b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/HealthCheckServiceInstanceListSupplierTests.java @@ -29,7 +29,6 @@ import org.awaitility.Awaitility; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -44,7 +43,6 @@ import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -67,7 +65,6 @@ import static org.springframework.cloud.loadbalancer.core.ServiceInstanceListSup * @author Roman Chigvintsev * @author Sabyasachi Bhattacharya */ -@ExtendWith(SpringExtension.class) @SpringBootTest(classes = HealthCheckServiceInstanceListSupplierTests.TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class HealthCheckServiceInstanceListSupplierTests { diff --git a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSupplierBuilderTests.java b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSupplierBuilderTests.java index 48d47c00..41fa87c0 100644 --- a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSupplierBuilderTests.java +++ b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSupplierBuilderTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.loadbalancer.core; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; @@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import; import org.springframework.web.reactive.function.client.WebClient; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; public class ServiceInstanceListSupplierBuilderTests {