From ea459cee64ebd12f306999738d49126c77216f4d Mon Sep 17 00:00:00 2001 From: Robert McNees <86265089+robertmcnees@users.noreply.github.com> Date: Mon, 12 Jul 2021 16:14:49 -0400 Subject: [PATCH] Issue 973 - Update Unit version - spring-cloud-context (#977) * Upgraded more JUnit test versions --- .../CommonsClientAutoConfigurationTests.java | 2 +- ...HostInfoEnvironmentPostProcessorTests.java | 2 +- ...veCommonsClientAutoConfigurationTests.java | 2 +- .../actuator/FeaturesEndpointTests.java | 10 ++--- .../circuitbreaker/CustomizerTests.java | 2 +- .../AutoRegisterPropertyFalseTests.java | 5 +-- ...DiscoveryClientAutoRegisterFalseTests.java | 5 +-- ...EnableDiscoveryClientMissingImplTests.java | 2 +- ...DiscoveryClientAutoConfigurationTests.java | 5 +-- .../CompositeDiscoveryClientOrderTest.java | 5 +-- .../CompositeDiscoveryClientTests.java | 5 +-- .../event/HeartbeatMonitorTests.java | 2 +- .../DiscoveryClientHealthIndicatorTests.java | 5 +-- ...coveryCompositeHealthContributorTests.java | 2 +- ...ryClientAutoConfigurationDefaultTests.java | 5 +-- ...overyPropertiesAutoConfigurationTests.java | 5 +-- ...overyPropertiesAutoConfigurationTests.java | 5 +-- ...DiscoveryClientPropertiesMappingTests.java | 5 +-- .../simple/SimpleDiscoveryClientTests.java | 6 +-- ...ediaAutoConfigurationIntegrationTests.java | 2 +- ...yncLoadBalancerAutoConfigurationTests.java | 2 +- ...ntHttpResponseStatusCodeExceptionTest.java | 8 ++-- .../InterceptorRetryPolicyTest.java | 16 ++++---- .../LoadBalancedRetryContextTest.java | 16 ++++---- ...ancerRequestFactoryConfigurationTests.java | 12 +++--- .../LoadBalancerRequestFactoryTests.java | 12 +++--- ...tryLoadBalancerAutoConfigurationTests.java | 2 +- .../RetryLoadBalancerInterceptorTests.java | 41 +++++++++++-------- ...oServiceRegistrationMgmtDisabledTests.java | 5 +-- .../AbstractAutoServiceRegistrationTests.java | 5 +-- ...ceRegistryEndpointNoRegistrationTests.java | 5 +-- .../ServiceRegistryEndpointTests.java | 5 +-- ...omHttpClientBuilderConfigurationTests.java | 5 +-- .../CustomHttpClientConfigurationTests.java | 5 +-- ...OkHttpClientBuilderConfigurationTests.java | 5 +-- .../DefaultApacheHttpClientFactoryTests.java | 2 +- .../DefaultHttpClientConfigurationTests.java | 5 +-- ...OkHttpClientConnectionPoolFactoryTest.java | 2 +- .../DefaultOkHttpClientFactoryTest.java | 2 +- .../FluxFirstNonEmptyEmittingTests.java | 2 +- ...erverTokenRelayAutoConfigurationTests.java | 6 +-- .../ResourceServerTokenRelayTests.java | 5 +-- .../cloud/commons/util/IdUtilsTests.java | 10 ++--- .../cloud/commons/util/InetUtilsTests.java | 2 +- .../SpringFactoryImportSelectorTests.java | 2 +- ...ibilityVerifierAutoConfigurationTests.java | 5 +-- ...erifierDisabledAutoConfigurationTests.java | 5 +-- ...VerifierFailureAutoConfigurationTests.java | 7 +--- .../CompatibilityVerifierTests.java | 15 ++++--- .../configuration/SSHContextFactoryTests.java | 10 ++--- .../SpringBootDependencyTests.java | 2 +- .../pom.xml | 5 --- .../RefreshEndpointIntegrationTests.java | 5 +-- .../LifecycleMvcAutoConfigurationTests.java | 2 +- .../RefreshAutoConfigurationTests.java | 15 ++++--- ...bledAutoConfigurationIntegrationTests.java | 5 +-- ...ringAutoConfigurationIntegrationTests.java | 5 +-- ...rrideSystemPropertiesIntegrationTests.java | 5 +-- ...gCustomPropertySourceIntegrationTests.java | 5 +-- ...SpringApplicationJsonIntegrationTests.java | 13 +++--- .../BootstrapSourcesOrderingTests.java | 5 +-- .../MessageSourceConfigurationTests.java | 5 +-- .../config/BootstrapConfigurationTests.java | 24 +++++------ ...trapListenerHierarchyIntegrationTests.java | 2 +- ...EncryptionBootstrapConfigurationTests.java | 2 +- .../encrypt/EncryptionIntegrationTests.java | 2 +- .../encrypt/EncryptorFactoryTests.java | 9 ++-- ...entDecryptApplicationInitializerTests.java | 19 ++++----- .../EnvironmentManagerIntegrationTests.java | 5 +-- .../environment/EnvironmentManagerTest.java | 2 +- .../named/NamedContextFactoryTests.java | 2 +- ...ionPropertiesRebinderIntegrationTests.java | 5 +-- ...tiesRebinderLifecycleIntegrationTests.java | 5 +-- ...ropertiesRebinderListIntegrationTests.java | 9 ++-- ...opertiesRebinderProxyIntegrationTests.java | 5 +-- ...sRebinderRefreshScopeIntegrationTests.java | 5 +-- .../ContextRefresherIntegrationTests.java | 5 +-- ...textRefresherOrderingIntegrationTests.java | 13 +++--- .../refresh/ContextRefresherTests.java | 10 ++--- .../restart/RestartIntegrationTests.java | 6 +-- .../ImportRefreshScopeIntegrationTests.java | 5 +-- .../MoreRefreshScopeIntegrationTests.java | 13 +++--- .../RefreshEndpointIntegrationTests.java | 6 +-- .../refresh/RefreshScopeConcurrencyTests.java | 5 +-- .../RefreshScopeConfigurationScaleTests.java | 5 +-- .../RefreshScopeConfigurationTests.java | 11 ++--- .../refresh/RefreshScopeIntegrationTests.java | 22 +++++----- .../RefreshScopeLazyIntegrationTests.java | 13 +++--- ...freshScopeListBindingIntegrationTests.java | 5 +-- .../RefreshScopeNullBeanIntegrationTests.java | 5 +-- .../refresh/RefreshScopePureScaleTests.java | 5 +-- .../scope/refresh/RefreshScopeScaleTests.java | 5 +-- .../RefreshScopeSerializationTests.java | 2 +- .../RefreshScopeWebIntegrationTests.java | 5 +-- .../RefreshScopeHealthIndicatorTests.java | 6 +-- .../cloud/logging/LoggingRebinderTests.java | 6 +-- 96 files changed, 238 insertions(+), 389 deletions(-) diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java index 12b97677..96d04f36 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigurations; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessorTests.java index d2155fb0..a319673f 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessorTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.SpringApplication; import org.springframework.core.env.ConfigurableEnvironment; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java index 0e424e05..4922b980 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.FilteredClassLoader; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/actuator/FeaturesEndpointTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/actuator/FeaturesEndpointTests.java index 0998a648..22b399ca 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/actuator/FeaturesEndpointTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/actuator/FeaturesEndpointTests.java @@ -19,9 +19,9 @@ package org.springframework.cloud.client.actuator; import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; @@ -39,14 +39,14 @@ public class FeaturesEndpointTests { private AnnotationConfigApplicationContext context; - @Before + @BeforeEach public void setup() { this.context = new AnnotationConfigApplicationContext(); this.context.register(JacksonAutoConfiguration.class, FeaturesConfig.class, Config.class); this.context.refresh(); } - @After + @AfterEach public void close() { if (this.context != null) { this.context.close(); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/circuitbreaker/CustomizerTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/circuitbreaker/CustomizerTests.java index 80b399b6..5462abbe 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/circuitbreaker/CustomizerTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/circuitbreaker/CustomizerTests.java @@ -19,7 +19,7 @@ package org.springframework.cloud.client.circuitbreaker; import java.util.concurrent.atomic.AtomicInteger; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CustomizerTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/AutoRegisterPropertyFalseTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/AutoRegisterPropertyFalseTests.java index cf3bf270..a2ad236e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/AutoRegisterPropertyFalseTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/AutoRegisterPropertyFalseTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.client.discovery; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -27,14 +26,12 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(properties = { "spring.cloud.service-registry.auto-registration.enabled: false" }) public class AutoRegisterPropertyFalseTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientAutoRegisterFalseTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientAutoRegisterFalseTests.java index 34845c69..9aeca7f2 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientAutoRegisterFalseTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientAutoRegisterFalseTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.client.discovery; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -27,14 +26,12 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest public class EnableDiscoveryClientAutoRegisterFalseTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java index 28badd15..3176cb8b 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client.discovery; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java index 328d1528..f2000500 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfigurationTests.java @@ -18,8 +18,7 @@ package org.springframework.cloud.client.discovery.composite; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -29,7 +28,6 @@ import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; @@ -39,7 +37,6 @@ import static org.assertj.core.api.BDDAssertions.then; * @author Biju Kunjummen */ -@RunWith(SpringRunner.class) @SpringBootTest public class CompositeDiscoveryClientAutoConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientOrderTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientOrderTest.java index 084de0ed..2905b3ee 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientOrderTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientOrderTest.java @@ -18,14 +18,12 @@ package org.springframework.cloud.client.discovery.composite; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClientTestsConfig.CUSTOM_DISCOVERY_CLIENT; @@ -39,7 +37,6 @@ import static org.springframework.cloud.client.discovery.composite.CompositeDisc * * @author Olga Maciaszek-Sharma */ -@RunWith(SpringRunner.class) @SpringBootTest(properties = "spring.cloud.discovery.client.simple.order:2", classes = { CompositeDiscoveryClientTestsConfig.class }) public class CompositeDiscoveryClientOrderTest { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java index fe4f774f..530fb869 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientTests.java @@ -18,14 +18,12 @@ package org.springframework.cloud.client.discovery.composite; import java.net.URI; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClientTestsConfig.CUSTOM_SERVICE_ID; @@ -36,7 +34,6 @@ import static org.springframework.cloud.client.discovery.composite.CompositeDisc * @author Biju Kunjummen */ -@RunWith(SpringRunner.class) @SpringBootTest( properties = { "spring.application.name=service0", "spring.cloud.discovery.client.simple.instances.service1[0].uri=http://s11:8080", diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/event/HeartbeatMonitorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/event/HeartbeatMonitorTests.java index 17476bea..7536a6ba 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/event/HeartbeatMonitorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/event/HeartbeatMonitorTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client.discovery.event; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.BDDAssertions.then; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicatorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicatorTests.java index b1aa4bc4..5836107e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicatorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicatorTests.java @@ -18,8 +18,7 @@ package org.springframework.cloud.client.discovery.health; import java.util.Arrays; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.health.CompositeHealthContributor; @@ -34,7 +33,6 @@ import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.mockito.BDDMockito.given; @@ -43,7 +41,6 @@ import static org.mockito.Mockito.mock; /** * @author Spencer Gibb */ -@RunWith(SpringRunner.class) // @checkstyle:off @SpringBootTest(classes = { DiscoveryClientHealthIndicatorTests.Config.class, CommonsClientAutoConfiguration.class }, properties = "spring.cloud.discovery.client.health-indicator.include-description:true") diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthContributorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthContributorTests.java index e0a96841..325c1b85 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthContributorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthContributorTests.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthContributor; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/DiscoveryClientAutoConfigurationDefaultTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/DiscoveryClientAutoConfigurationDefaultTests.java index 15fed0af..16bc9a06 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/DiscoveryClientAutoConfigurationDefaultTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/DiscoveryClientAutoConfigurationDefaultTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.client.discovery.simple; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -25,7 +24,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; @@ -34,7 +32,6 @@ import static org.assertj.core.api.BDDAssertions.then; * * @author Biju Kunjummen */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = DiscoveryClientAutoConfigurationDefaultTests.Config.class) public class DiscoveryClientAutoConfigurationDefaultTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.java index 7b90a4e5..4c0c0205 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.java @@ -16,22 +16,19 @@ package org.springframework.cloud.client.discovery.simple; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = ReactiveSimpleDiscoveryPropertiesAutoConfigurationTests.Config.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = "spring.main.web-application-type=reactive") diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ServletSimpleDiscoveryPropertiesAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ServletSimpleDiscoveryPropertiesAutoConfigurationTests.java index 53feda84..68cd500e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ServletSimpleDiscoveryPropertiesAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/ServletSimpleDiscoveryPropertiesAutoConfigurationTests.java @@ -16,22 +16,19 @@ package org.springframework.cloud.client.discovery.simple; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = ServletSimpleDiscoveryPropertiesAutoConfigurationTests.Config.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ServletSimpleDiscoveryPropertiesAutoConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java index 3d1a4188..8530fbdf 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientPropertiesMappingTests.java @@ -18,15 +18,13 @@ package org.springframework.cloud.client.discovery.simple; import java.net.URI; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.client.ServiceInstance; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; @@ -36,7 +34,6 @@ import static org.assertj.core.api.BDDAssertions.then; * @author Biju Kunjummen */ -@RunWith(SpringRunner.class) @SpringBootTest(properties = { "spring.application.name=service0", "spring.cloud.discovery.client.simple.instances.service1[0].uri=http://s11:8080", "spring.cloud.discovery.client.simple.instances.service1[1].uri=https://s12:8443", diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientTests.java index 00f84cc9..82944a11 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientTests.java @@ -22,8 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; @@ -38,7 +38,7 @@ public class SimpleDiscoveryClientTests { private SimpleDiscoveryClient simpleDiscoveryClient; - @Before + @BeforeEach public void setUp() { SimpleDiscoveryProperties simpleDiscoveryProperties = new SimpleDiscoveryProperties(); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/CloudHypermediaAutoConfigurationIntegrationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/CloudHypermediaAutoConfigurationIntegrationTests.java index 0de4896c..10b38141 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/CloudHypermediaAutoConfigurationIntegrationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/hypermedia/CloudHypermediaAutoConfigurationIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.client.hypermedia; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfigurationTests.java index 252a4b61..af07292d 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfigurationTests.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.Map; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.WebApplicationType; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/ClientHttpResponseStatusCodeExceptionTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/ClientHttpResponseStatusCodeExceptionTest.java index 1bccb927..19607e80 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/ClientHttpResponseStatusCodeExceptionTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/ClientHttpResponseStatusCodeExceptionTest.java @@ -20,9 +20,9 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpHeaders; import org.springframework.http.client.AbstractClientHttpResponse; @@ -34,7 +34,7 @@ import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ClientHttpResponseStatusCodeExceptionTest { @Test diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/InterceptorRetryPolicyTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/InterceptorRetryPolicyTest.java index 3301b525..e30ec30b 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/InterceptorRetryPolicyTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/InterceptorRetryPolicyTest.java @@ -16,11 +16,11 @@ package org.springframework.cloud.client.loadbalancer; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +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.junit.jupiter.MockitoExtension; import org.springframework.http.HttpRequest; import org.springframework.retry.RetryContext; @@ -36,7 +36,7 @@ import static org.mockito.Mockito.when; * @author Ryan Baxter * @author Olga Maciaszek-Sharma */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class InterceptorRetryPolicyTest { private HttpRequest request; @@ -47,7 +47,7 @@ public class InterceptorRetryPolicyTest { private String serviceName; - @Before + @BeforeEach public void setup() { request = mock(HttpRequest.class); policy = mock(LoadBalancedRetryPolicy.class); @@ -55,7 +55,7 @@ public class InterceptorRetryPolicyTest { serviceName = "foo"; } - @After + @AfterEach public void teardown() { request = null; policy = null; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRetryContextTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRetryContextTest.java index e99ab74f..d5c277cf 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRetryContextTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRetryContextTest.java @@ -16,11 +16,11 @@ package org.springframework.cloud.client.loadbalancer; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +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.junit.jupiter.MockitoExtension; import org.springframework.cloud.client.ServiceInstance; import org.springframework.http.HttpRequest; @@ -32,20 +32,20 @@ import static org.mockito.Mockito.mock; /** * @author Ryan Baxter */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class LoadBalancedRetryContextTest { private RetryContext context; private HttpRequest request; - @Before + @BeforeEach public void setUp() throws Exception { this.context = mock(RetryContext.class); this.request = mock(HttpRequest.class); } - @After + @AfterEach public void tearDown() throws Exception { this.context = null; this.request = null; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryConfigurationTests.java index f072c25f..08e5edc3 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryConfigurationTests.java @@ -16,12 +16,12 @@ package org.springframework.cloud.client.loadbalancer; -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.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -42,7 +42,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class LoadBalancerRequestFactoryConfigurationTests { @Mock @@ -68,7 +68,7 @@ public class LoadBalancerRequestFactoryConfigurationTests { private LoadBalancerRequest lbRequest; - @Before + @BeforeEach public void setup() { this.httpRequestCaptor = ArgumentCaptor.forClass(HttpRequest.class); } diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryTests.java index 28426eb0..8d450a3e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequestFactoryTests.java @@ -20,12 +20,12 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -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.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.cloud.client.ServiceInstance; import org.springframework.http.HttpRequest; @@ -38,7 +38,7 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class LoadBalancerRequestFactoryTests { @Mock @@ -69,7 +69,7 @@ public class LoadBalancerRequestFactoryTests { private ArgumentCaptor httpRequestCaptor; - @Before + @BeforeEach public void setup() { this.httpRequestCaptor = ArgumentCaptor.forClass(HttpRequest.class); } diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerAutoConfigurationTests.java index 501bb75e..2f1336e6 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerAutoConfigurationTests.java @@ -18,7 +18,7 @@ package org.springframework.cloud.client.loadbalancer; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.http.client.ClientHttpRequestInterceptor; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerInterceptorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerInterceptorTests.java index 3a8126c9..94ad3f8e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerInterceptorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/RetryLoadBalancerInterceptorTests.java @@ -27,12 +27,13 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; @@ -68,7 +69,7 @@ import static org.mockito.Mockito.when; * @author Olga Maciaszek-Sharma */ @SuppressWarnings({ "unchecked", "rawtypes" }) -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class RetryLoadBalancerInterceptorTests { private LoadBalancerClient client; @@ -82,7 +83,7 @@ public class RetryLoadBalancerInterceptorTests { private ReactiveLoadBalancer.Factory lbFactory; - @Before + @BeforeEach public void setUp() { client = mock(LoadBalancerClient.class); lbRequestFactory = mock(LoadBalancerRequestFactory.class); @@ -90,12 +91,12 @@ public class RetryLoadBalancerInterceptorTests { lbFactory = mock(ReactiveLoadBalancer.Factory.class); } - @After + @AfterEach public void tearDown() { client = null; } - @Test(expected = IOException.class) + @Test public void interceptDisableRetry() throws Throwable { HttpRequest request = mock(HttpRequest.class); when(request.getURI()).thenReturn(new URI("http://foo")); @@ -111,11 +112,13 @@ public class RetryLoadBalancerInterceptorTests { when(lbRequestFactory.createRequest(any(), any(), any())).thenReturn(mock(LoadBalancerRequest.class)); - interceptor.intercept(request, body, execution); + Assertions.assertThrows(IOException.class, () -> { + interceptor.intercept(request, body, execution); + }); verify(lbRequestFactory).createRequest(request, body, execution); } - @Test(expected = IllegalStateException.class) + @Test public void interceptInvalidHost() throws Throwable { HttpRequest request = mock(HttpRequest.class); when(request.getURI()).thenReturn(new URI("http://foo_underscore")); @@ -124,7 +127,9 @@ public class RetryLoadBalancerInterceptorTests { lbRequestFactory, loadBalancedRetryFactory, lbFactory); byte[] body = new byte[] {}; ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class); - interceptor.intercept(request, body, execution); + Assertions.assertThrows(IllegalStateException.class, () -> { + interceptor.intercept(request, body, execution); + }); } @Test @@ -258,7 +263,7 @@ public class RetryLoadBalancerInterceptorTests { then(backOffPolicy.getBackoffAttempts()).isEqualTo(1); } - @Test(expected = IOException.class) + @Test public void interceptFailedRetry() throws Exception { HttpRequest request = mock(HttpRequest.class); when(request.getURI()).thenReturn(new URI("http://foo")); @@ -275,7 +280,9 @@ public class RetryLoadBalancerInterceptorTests { lbRequestFactory, new MyLoadBalancedRetryFactory(policy), lbFactory); byte[] body = new byte[] {}; ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class); - interceptor.intercept(request, body, execution); + Assertions.assertThrows(IOException.class, () -> { + interceptor.intercept(request, body, execution); + }); verify(lbRequestFactory).createRequest(request, body, execution); } @@ -337,7 +344,7 @@ public class RetryLoadBalancerInterceptorTests { then(backOffPolicy.getBackoffAttempts()).isEqualTo(1); } - @Test(expected = TerminatedRetryException.class) + @Test public void retryListenerTestNoRetry() throws Throwable { HttpRequest request = mock(HttpRequest.class); when(request.getURI()).thenReturn(new URI("http://noRetry")); @@ -355,7 +362,9 @@ public class RetryLoadBalancerInterceptorTests { new MyLoadBalancedRetryFactory(policy, backOffPolicy, new RetryListener[] { myRetryListener }), lbFactory); ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class); - interceptor.intercept(request, new byte[] {}, execution); + Assertions.assertThrows(TerminatedRetryException.class, () -> { + interceptor.intercept(request, new byte[] {}, execution); + }); } @Test diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationMgmtDisabledTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationMgmtDisabledTests.java index 830372a2..734ac98e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationMgmtDisabledTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationMgmtDisabledTests.java @@ -21,15 +21,13 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -37,7 +35,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Spencer Gibb * @author Tim Ysewyn */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = AbstractAutoServiceRegistrationMgmtDisabledTests.Config.class, properties = { "management.port=0", "spring.cloud.service-registry.auto-registration.register-management=false" }, diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationTests.java index f5f820f4..87f3b1bd 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistrationTests.java @@ -20,8 +20,7 @@ import java.net.URI; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort; @@ -33,7 +32,6 @@ import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -42,7 +40,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Spencer Gibb * @author Tim Ysewyn */ -@RunWith(SpringRunner.class) // @checkstyle:off @SpringBootTest(classes = AbstractAutoServiceRegistrationTests.Config.class, properties = "management.port=0", webEnvironment = RANDOM_PORT) diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointNoRegistrationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointNoRegistrationTests.java index 11e889af..7e91a616 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointNoRegistrationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointNoRegistrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.client.serviceregistry.endpoint; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; @@ -31,7 +30,6 @@ import org.springframework.cloud.client.serviceregistry.endpoint.ServiceRegistry import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -41,7 +39,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. /** * @author Spencer Gibb */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = ServiceRegistryEndpointNoRegistrationTests.TestConfiguration.class) @AutoConfigureMockMvc public class ServiceRegistryEndpointNoRegistrationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointTests.java index f1cc7adb..8605f311 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/client/serviceregistry/endpoint/ServiceRegistryEndpointTests.java @@ -22,8 +22,7 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringBootConfiguration; @@ -35,7 +34,6 @@ import org.springframework.cloud.client.serviceregistry.Registration; import org.springframework.cloud.client.serviceregistry.ServiceRegistry; import org.springframework.context.annotation.Bean; import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import static org.assertj.core.api.BDDAssertions.then; @@ -49,7 +47,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * @author Spencer Gibb * @author Tim Ysewyn */ -@RunWith(SpringRunner.class) // @checkstyle:off @SpringBootTest(classes = ServiceRegistryEndpointTests.TestConfiguration.class, properties = "management.endpoints.web.exposure.include=*") diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientBuilderConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientBuilderConfigurationTests.java index b7aed99d..8373856d 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientBuilderConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientBuilderConfigurationTests.java @@ -17,8 +17,7 @@ package org.springframework.cloud.commons.httpclient; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; @@ -27,14 +26,12 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = CustomHttpClientBuilderApplication.class) public class CustomHttpClientBuilderConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientConfigurationTests.java index 693b9216..1a62d562 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomHttpClientConfigurationTests.java @@ -23,8 +23,7 @@ import okhttp3.OkHttpClient; import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; @@ -32,14 +31,12 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = CustomApplication.class, properties = { "spring.cloud.httpclient.ok.enabled: true" }) public class CustomHttpClientConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomOkHttpClientBuilderConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomOkHttpClientBuilderConfigurationTests.java index 2b0d2b1f..6bd2eeef 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomOkHttpClientBuilderConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/CustomOkHttpClientBuilderConfigurationTests.java @@ -20,8 +20,7 @@ import java.lang.reflect.Field; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; @@ -29,7 +28,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.BDDAssertions.then; @@ -37,7 +35,6 @@ import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = CustomOkHttpClientBuilderApplication.class) public class CustomOkHttpClientBuilderConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientFactoryTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientFactoryTests.java index 2c7a4907..2147ca0f 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientFactoryTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultApacheHttpClientFactoryTests.java @@ -25,7 +25,7 @@ import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.assertj.core.api.BDDAssertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ReflectionUtils; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultHttpClientConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultHttpClientConfigurationTests.java index c5517cb4..0327779f 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultHttpClientConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultHttpClientConfigurationTests.java @@ -16,22 +16,19 @@ package org.springframework.cloud.commons.httpclient; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Ryan Baxter */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = MyApplication.class, properties = { "spring.cloud.httpclient.ok.enabled: true" }) public class DefaultHttpClientConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientConnectionPoolFactoryTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientConnectionPoolFactoryTest.java index cbe75687..99f2e4f0 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientConnectionPoolFactoryTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientConnectionPoolFactoryTest.java @@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit; import okhttp3.ConnectionPool; import okhttp3.internal.connection.RealConnectionPool; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ReflectionUtils; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientFactoryTest.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientFactoryTest.java index 89111ce9..eb69a234 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientFactoryTest.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/httpclient/DefaultOkHttpClientFactoryTest.java @@ -23,7 +23,7 @@ import javax.net.ssl.HostnameVerifier; import okhttp3.ConnectionPool; import okhttp3.OkHttpClient; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ReflectionUtils; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/publisher/FluxFirstNonEmptyEmittingTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/publisher/FluxFirstNonEmptyEmittingTests.java index 13edac62..0d7ac759 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/publisher/FluxFirstNonEmptyEmittingTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/publisher/FluxFirstNonEmptyEmittingTests.java @@ -19,7 +19,7 @@ package org.springframework.cloud.commons.publisher; import java.time.Duration; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.CoreSubscriber; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/ResourceServerTokenRelayAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/ResourceServerTokenRelayAutoConfigurationTests.java index dfe1b5af..1d8c90b0 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/ResourceServerTokenRelayAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/ResourceServerTokenRelayAutoConfigurationTests.java @@ -16,8 +16,8 @@ package org.springframework.cloud.commons.security; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso; @@ -49,7 +49,7 @@ public class ResourceServerTokenRelayAutoConfigurationTests { private ConfigurableApplicationContext context; - @After + @AfterEach public void close() { if (this.context != null) { this.context.close(); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/tokenrelay/ResourceServerTokenRelayTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/tokenrelay/ResourceServerTokenRelayTests.java index 52913d86..f24bfc05 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/tokenrelay/ResourceServerTokenRelayTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/security/tokenrelay/ResourceServerTokenRelayTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.commons.security.tokenrelay; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -41,7 +40,6 @@ import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -56,7 +54,6 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat * @author Peter Szanto (spring@szantocsalad.hu) * */ -@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "security.oauth2.resource.jwt.keyValue=secret", "spring.cloud.mvc.token-relay.enabled=true", "spring.autoconfigure.exclude=" }) diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/IdUtilsTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/IdUtilsTests.java index c90022dd..29adf3f5 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/IdUtilsTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/IdUtilsTests.java @@ -16,9 +16,9 @@ package org.springframework.cloud.commons.util; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.env.MockEnvironment; @@ -33,12 +33,12 @@ public class IdUtilsTests { private MockEnvironment env; - @Before + @BeforeEach public void setup() { this.env = new MockEnvironment(); } - @After + @AfterEach public void destroy() { this.env = null; } diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/InetUtilsTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/InetUtilsTests.java index dbae581f..36eb3aee 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/InetUtilsTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/InetUtilsTests.java @@ -20,7 +20,7 @@ import java.net.InetAddress; import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cloud.commons.util.InetUtils.HostInfo; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/SpringFactoryImportSelectorTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/SpringFactoryImportSelectorTests.java index 185590e2..2f2a156e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/SpringFactoryImportSelectorTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/commons/util/SpringFactoryImportSelectorTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.commons.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.BDDAssertions.then; diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierAutoConfigurationTests.java index 19cfb13c..70350322 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierAutoConfigurationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.configuration; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringBootVersion; @@ -25,7 +24,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -35,7 +33,6 @@ import static org.springframework.cloud.configuration.SpringBootVersionVerifier. /** * @author Marcin Grzejszczak */ -@RunWith(SpringRunner.class) @SpringBootTest public class CompatibilityVerifierAutoConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierDisabledAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierDisabledAutoConfigurationTests.java index 37ac9592..4b8c346c 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierDisabledAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierDisabledAutoConfigurationTests.java @@ -16,21 +16,18 @@ package org.springframework.cloud.configuration; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; /** * @author Marcin Grzejszczak */ -@RunWith(SpringRunner.class) @SpringBootTest(properties = "spring.cloud.compatibility-verifier.enabled=false") public class CompatibilityVerifierDisabledAutoConfigurationTests { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierFailureAutoConfigurationTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierFailureAutoConfigurationTests.java index 8aa39a26..95c220c4 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierFailureAutoConfigurationTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierFailureAutoConfigurationTests.java @@ -17,13 +17,11 @@ package org.springframework.cloud.configuration; import org.assertj.core.api.BDDAssertions; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.system.OutputCaptureRule; import org.springframework.context.annotation.Configuration; import org.springframework.core.NestedExceptionUtils; @@ -34,9 +32,6 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class CompatibilityVerifierFailureAutoConfigurationTests { - @Rule - public OutputCaptureRule outputCapture = new OutputCaptureRule(); - @Test public void contextFailsToLoad() { try { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierTests.java index 4e13d987..52171cf4 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/CompatibilityVerifierTests.java @@ -20,29 +20,28 @@ import java.util.ArrayList; import java.util.List; import org.assertj.core.api.BDDAssertions; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; import static org.assertj.core.api.BDDAssertions.then; /** * @author Marcin Grzejszczak */ +@ExtendWith(OutputCaptureExtension.class) public class CompatibilityVerifierTests { - @Rule - public OutputCaptureRule outputCapture = new OutputCaptureRule(); - @Test - public void should_not_print_the_report_when_no_errors_were_found() { + public void should_not_print_the_report_when_no_errors_were_found(CapturedOutput output) { CompositeCompatibilityVerifier verifier = new CompositeCompatibilityVerifier( new ArrayList()); verifier.verifyDependencies(); - then(this.outputCapture.toString()).doesNotContain("SPRING CLOUD VERIFICATION FAILED"); + then(output).doesNotContain("SPRING CLOUD VERIFICATION FAILED"); } @Test diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SSHContextFactoryTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SSHContextFactoryTests.java index f831f168..12ef299d 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SSHContextFactoryTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SSHContextFactoryTests.java @@ -27,9 +27,9 @@ import java.security.cert.Certificate; import javax.net.ssl.SSLContext; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; @@ -52,7 +52,7 @@ public class SSHContextFactoryTests { private TlsProperties properties; - @BeforeClass + @BeforeAll public static void createKeyStoreAndTrustStore() throws Exception { KeyTool tool = new KeyTool(); @@ -82,7 +82,7 @@ public class SSHContextFactoryTests { return result; } - @Before + @BeforeEach public void createProperties() { properties = new TlsProperties(); diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java index d3161338..b6613aca 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.BDDAssertions.then; diff --git a/spring-cloud-context-webflux-integration-tests/pom.xml b/spring-cloud-context-webflux-integration-tests/pom.xml index 3e027490..54909e04 100644 --- a/spring-cloud-context-webflux-integration-tests/pom.xml +++ b/spring-cloud-context-webflux-integration-tests/pom.xml @@ -42,11 +42,6 @@ spring-boot-configuration-processor true - - org.junit.vintage - junit-vintage-engine - test - diff --git a/spring-cloud-context-webflux-integration-tests/src/test/java/org/springframework/cloud/context/integration/webflux/RefreshEndpointIntegrationTests.java b/spring-cloud-context-webflux-integration-tests/src/test/java/org/springframework/cloud/context/integration/webflux/RefreshEndpointIntegrationTests.java index d393f693..98301b62 100644 --- a/spring-cloud-context-webflux-integration-tests/src/test/java/org/springframework/cloud/context/integration/webflux/RefreshEndpointIntegrationTests.java +++ b/spring-cloud-context-webflux-integration-tests/src/test/java/org/springframework/cloud/context/integration/webflux/RefreshEndpointIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.integration.webflux; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -27,7 +26,6 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -36,7 +34,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Dave Syer * */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = RefreshEndpointIntegrationTests.ClientApp.class, properties = { "management.endpoints.web.exposure.include=*" }, webEnvironment = RANDOM_PORT) public class RefreshEndpointIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/LifecycleMvcAutoConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/LifecycleMvcAutoConfigurationTests.java index b995d724..cf3af23d 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/LifecycleMvcAutoConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/LifecycleMvcAutoConfigurationTests.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.function.Function; import org.assertj.core.util.Lists; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/RefreshAutoConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/RefreshAutoConfigurationTests.java index e7b4f30d..04bf003c 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/RefreshAutoConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/autoconfigure/RefreshAutoConfigurationTests.java @@ -18,8 +18,8 @@ package org.springframework.cloud.autoconfigure; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -27,7 +27,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.cloud.context.refresh.ContextRefresher; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Configuration; @@ -38,11 +39,9 @@ import static org.assertj.core.api.BDDAssertions.then; /** * @author Dave Syer */ +@ExtendWith(OutputCaptureExtension.class) public class RefreshAutoConfigurationTests { - @Rule - public OutputCaptureRule output = new OutputCaptureRule(); - private static ConfigurableApplicationContext getApplicationContext(WebApplicationType type, Class configuration, String... properties) { return new SpringApplicationBuilder(configuration).web(type).properties(properties).properties("server.port=0") @@ -50,10 +49,10 @@ public class RefreshAutoConfigurationTests { } @Test - public void noWarnings() { + public void noWarnings(CapturedOutput output) { try (ConfigurableApplicationContext context = getApplicationContext(WebApplicationType.NONE, Config.class)) { then(context.containsBean("refreshScope")).isTrue(); - then(this.output.toString()).doesNotContain("WARN"); + then(output.toString()).doesNotContain("WARN"); } } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapDisabledAutoConfigurationIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapDisabledAutoConfigurationIntegrationTests.java index e5afe584..a3ba747d 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapDisabledAutoConfigurationIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapDisabledAutoConfigurationIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.bootstrap; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -25,11 +24,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.bootstrap.BootstrapDisabledAutoConfigurationIntegrationTests.Application; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = "spring.cloud.bootstrap.enabled:false") public class BootstrapDisabledAutoConfigurationIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java index e594156e..cbedca47 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.bootstrap; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -26,11 +25,9 @@ import org.springframework.cloud.bootstrap.BootstrapOrderingAutoConfigurationInt import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = { "encrypt.key:deadbeef", "spring.config.use-legacy-processing=true" }) @ActiveProfiles("encrypt") diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java index fe9a5a4e..002af5ab 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java @@ -21,8 +21,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -35,12 +34,10 @@ import org.springframework.core.env.Environment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; -import org.springframework.test.context.junit4.SpringRunner; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = { "spring.config.use-legacy-processing=true", "spring.cloud.bootstrap.name:ordering" }) public class BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java index c29b7296..ad236854 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java @@ -20,8 +20,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -34,11 +33,9 @@ import org.springframework.core.env.Environment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.PropertySource; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = { "encrypt.key:deadbeef", "spring.cloud.bootstrap.name:custom", "spring.config.use-legacy-processing=true" }) @ActiveProfiles("encrypt") diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingSpringApplicationJsonIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingSpringApplicationJsonIntegrationTests.java index 1cdd4ac7..a7a142c8 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingSpringApplicationJsonIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingSpringApplicationJsonIntegrationTests.java @@ -16,10 +16,9 @@ package org.springframework.cloud.bootstrap; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -27,23 +26,21 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.bootstrap.BootstrapOrderingSpringApplicationJsonIntegrationTests.Application; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = "spring.cloud.bootstrap.name:json") public class BootstrapOrderingSpringApplicationJsonIntegrationTests { @Autowired private ConfigurableEnvironment environment; - @BeforeClass + @BeforeAll public static void spikeJson() { System.setProperty("SPRING_APPLICATION_JSON", "{\"message\":\"From JSON\"}"); } - @AfterClass + @AfterAll public static void unspikeJson() { System.clearProperty("SPRING_APPLICATION_JSON"); } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java index 6ff2f885..11b9d6cd 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java @@ -16,19 +16,16 @@ package org.springframework.cloud.bootstrap; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.bootstrap.BootstrapOrderingSpringApplicationJsonIntegrationTests.Application; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; import static org.springframework.cloud.bootstrap.TestHigherPriorityBootstrapConfiguration.firstToBeCreated; -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, properties = "spring.config.use-legacy-processing=true") public class BootstrapSourcesOrderingTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/MessageSourceConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/MessageSourceConfigurationTests.java index 168f3b01..faaf810a 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/MessageSourceConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/MessageSourceConfigurationTests.java @@ -23,8 +23,7 @@ package org.springframework.cloud.bootstrap; import java.util.Locale; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -32,11 +31,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.bootstrap.MessageSourceConfigurationTests.TestApplication; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestApplication.class, properties = "debug=true") public class MessageSourceConfigurationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java index 1194f78c..c709d5dd 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java @@ -21,11 +21,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -53,14 +52,11 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class BootstrapConfigurationTests { - @Rule - public ExpectedException expected = ExpectedException.none(); - private ConfigurableApplicationContext context; private ConfigurableApplicationContext sibling; - @After + @AfterEach public void close() { // Expected.* is bound to the PropertySourceConfiguration below System.clearProperty("expected.name"); @@ -148,9 +144,11 @@ public class BootstrapConfigurationTests { @Test public void failsOnPropertySource() { System.setProperty("expected.fail", "true"); - this.expected.expectMessage("Planned"); - this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE) - .properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run(); + Throwable throwable = Assertions.assertThrows(RuntimeException.class, () -> { + this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE) + .properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run(); + }); + then(throwable.getMessage().equals("Planned")); } @Test @@ -336,7 +334,7 @@ public class BootstrapConfigurationTests { } @Test - @Ignore // FIXME: legacy + @Disabled // FIXME: legacy public void differentProfileInChild() { PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar"); // Profiles are always merged with the child diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java index 4f117164..9c2b0b0c 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.bootstrap.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java index a9d7b71b..c078fdd0 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.bootstrap.encrypt; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java index 08ba3ae0..926f44ab 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.bootstrap.encrypt; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptorFactoryTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptorFactoryTests.java index af42c2af..faa7c940 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptorFactoryTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptorFactoryTests.java @@ -18,7 +18,8 @@ package org.springframework.cloud.bootstrap.encrypt; import java.nio.charset.Charset; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.cloud.context.encrypt.EncryptorFactory; import org.springframework.core.io.ClassPathResource; @@ -44,11 +45,13 @@ public class EncryptorFactoryTests { then(encryptor.decrypt(encrypted)).isEqualTo(toEncrypt); } - @Test(expected = RuntimeException.class) + @Test public void testWithInvalidRsaPrivateKey() { String key = "-----BEGIN RSA PRIVATE KEY-----\n" + "MIIEowIBAAKCAQEAwClFgrRa/PUHPIJr9gvIPL6g6Rjp/TVZmVNOf2fL96DYbkj5\n"; - new EncryptorFactory().create(key); + Assertions.assertThrows(RuntimeException.class, () -> { + new EncryptorFactory().create(key); + }); } } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java index 2fb1bdac..b8a8f670 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EnvironmentDecryptApplicationInitializerTests.java @@ -21,10 +21,11 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.boot.test.system.OutputCaptureRule; +import org.springframework.boot.test.system.CapturedOutput; +import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.test.util.TestPropertyValues.Type; import org.springframework.context.ApplicationContext; @@ -53,14 +54,12 @@ import static org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptAppl * @author Biju Kunjummen * @author Tim Ysewyn */ +@ExtendWith(OutputCaptureExtension.class) public class EnvironmentDecryptApplicationInitializerTests { private EnvironmentDecryptApplicationInitializer listener = new EnvironmentDecryptApplicationInitializer( Encryptors.noOpText()); - @Rule - public OutputCaptureRule outputCapture = new OutputCaptureRule(); - @Test public void decryptCipherKey() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(); @@ -89,7 +88,7 @@ public class EnvironmentDecryptApplicationInitializerTests { } @Test - public void errorOnDecrypt() { + public void errorOnDecrypt(CapturedOutput output) { this.listener = new EnvironmentDecryptApplicationInitializer(Encryptors.text("deadbeef", "AFFE37")); ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(); TestPropertyValues.of("spring.cloud.bootstrap.enabled=true", "foo: {cipher}bar").applyTo(context); @@ -101,19 +100,19 @@ public class EnvironmentDecryptApplicationInitializerTests { then(e).isInstanceOf(IllegalStateException.class); } // Assert logs contain warning even when exception thrown - String sysOutput = this.outputCapture.toString(); + String sysOutput = output.toString(); then(sysOutput).contains("Cannot decrypt: key=foo"); } @Test - public void errorOnDecryptWithEmpty() { + public void errorOnDecryptWithEmpty(CapturedOutput output) { this.listener = new EnvironmentDecryptApplicationInitializer(Encryptors.text("deadbeef", "AFFE37")); this.listener.setFailOnError(false); ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(); TestPropertyValues.of("spring.cloud.bootstrap.enabled=true", "foo: {cipher}bar").applyTo(context); this.listener.initialize(context); // Assert logs contain warning - String sysOutput = this.outputCapture.toString(); + String sysOutput = output.toString(); then(sysOutput).contains("Cannot decrypt: key=foo"); // Empty is safest fallback for undecryptable cipher then(context.getEnvironment().getProperty("foo")).isEqualTo(""); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerIntegrationTests.java index d27eab76..87c970ca 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerIntegrationTests.java @@ -24,8 +24,7 @@ import javax.servlet.ServletException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; @@ -40,7 +39,6 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import static org.assertj.core.api.Assertions.fail; @@ -50,7 +48,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "management.endpoints.web.exposure.include=*", "management.endpoint.env.post.enabled=true" }) @AutoConfigureMockMvc diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerTest.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerTest.java index d9b5d882..f826e9c6 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerTest.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/environment/EnvironmentManagerTest.java @@ -16,7 +16,7 @@ package org.springframework.cloud.context.environment; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.springframework.context.ApplicationEvent; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/named/NamedContextFactoryTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/named/NamedContextFactoryTests.java index 1e7ddc5d..4ae630ac 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/named/NamedContextFactoryTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/named/NamedContextFactoryTests.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.Map; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java index b0a7ffa2..eea089a3 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java @@ -19,8 +19,7 @@ package org.springframework.cloud.context.properties; import javax.annotation.PostConstruct; import org.aopalliance.intercept.MethodInterceptor; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -39,11 +38,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = "spring.config.use-legacy-processing=true") @ActiveProfiles("config") public class ConfigurationPropertiesRebinderIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderLifecycleIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderLifecycleIntegrationTests.java index 9fa505d9..1a898eba 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderLifecycleIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderLifecycleIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.properties; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -35,11 +34,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class ConfigurationPropertiesRebinderLifecycleIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderListIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderListIntegrationTests.java index 58434f77..b786728a 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderListIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderListIntegrationTests.java @@ -21,9 +21,8 @@ import java.util.Map; import javax.annotation.PostConstruct; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; @@ -40,11 +39,9 @@ import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.PropertySource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = "messages=one,two") public class ConfigurationPropertiesRebinderListIntegrationTests { @@ -68,7 +65,7 @@ public class ConfigurationPropertiesRebinderListIntegrationTests { @Test @DirtiesContext - @Ignore("Can't rebind to list and re-initialize it (need refresh scope for this to work)") + @Disabled("Can't rebind to list and re-initialize it (need refresh scope for this to work)") public void testReplaceProperties() throws Exception { then("[one, two]").isEqualTo(this.properties.getMessages().toString()); Map map = findTestProperties(); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderProxyIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderProxyIntegrationTests.java index d25cfe76..b4322033 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderProxyIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderProxyIntegrationTests.java @@ -21,8 +21,7 @@ import java.util.Map; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration; @@ -39,11 +38,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "messages.expiry.one=168", "messages.expiry.two=76" }) public class ConfigurationPropertiesRebinderProxyIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java index ed5e8ea2..4bf42ee0 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java @@ -18,8 +18,7 @@ package org.springframework.cloud.context.properties; import javax.annotation.PostConstruct; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; @@ -36,11 +35,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = "spring.config.use-legacy-processing=true") public class ConfigurationPropertiesRebinderRefreshScopeIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java index 1a8e1a24..0c00c3a4 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.refresh; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -31,11 +30,9 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "spring.datasource.hikari.read-only=false", "spring.config.use-legacy-processing=true" }) public class ContextRefresherIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java index 11407e37..7fde8ea8 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java @@ -21,10 +21,9 @@ import java.util.Collection; import java.util.Collections; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringBootConfiguration; @@ -38,12 +37,10 @@ import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) @SpringBootTest(properties = "spring.config.use-legacy-processing=true") @DirtiesContext public class ContextRefresherOrderingIntegrationTests { @@ -56,14 +53,14 @@ public class ContextRefresherOrderingIntegrationTests { private static String original; - @BeforeClass + @BeforeAll public static void beforeClass() { original = System.getProperty("spring.cloud.bootstrap.sources"); System.setProperty("spring.cloud.bootstrap.sources", "org.springframework.cloud.context.refresh.ContextRefresherOrderingIntegrationTests.PropertySourceConfiguration"); } - @AfterClass + @AfterAll public static void afterClass() { if (original != null) { System.setProperty("spring.cloud.bootstrap.sources", original); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java index 76619d7b..da69559b 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java @@ -22,9 +22,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.boot.SpringApplication; @@ -52,14 +52,14 @@ public class ContextRefresherTests { private RefreshScope scope = Mockito.mock(RefreshScope.class); - @After + @AfterEach public void close() { System.clearProperty(LoggingSystem.SYSTEM_PROPERTY); TestLoggingSystem.count = 0; } @Test - @Ignore // FIXME: legacy config + @Disabled // FIXME: legacy config public void orderNewPropertiesConsistentWithNewContext() { try (ConfigurableApplicationContext context = SpringApplication.run(Empty.class, "--spring.config.use-legacy-processing=true", "--spring.main.web-application-type=none", diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java index 33605c08..c53702c8 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java @@ -16,8 +16,8 @@ package org.springframework.cloud.context.restart; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -35,7 +35,7 @@ public class RestartIntegrationTests { SpringApplication.run(TestConfiguration.class, args); } - @After + @AfterEach public void close() { if (this.context != null) { this.context.close(); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java index 18b75bfa..2eee178f 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.aop.scope.ScopedProxyUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -28,11 +27,9 @@ import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.context.scope.refresh.ImportRefreshScopeIntegrationTests.TestConfiguration; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class ImportRefreshScopeIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/MoreRefreshScopeIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/MoreRefreshScopeIntegrationTests.java index dd6cd2b5..2513cea5 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/MoreRefreshScopeIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/MoreRefreshScopeIntegrationTests.java @@ -18,10 +18,9 @@ package org.springframework.cloud.context.scope.refresh; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.BeanCreationException; @@ -40,12 +39,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.fail; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class MoreRefreshScopeIntegrationTests { @@ -58,13 +55,13 @@ public class MoreRefreshScopeIntegrationTests { @Autowired private ConfigurableEnvironment environment; - @Before + @BeforeEach public void init() { then(TestService.getInitCount()).isEqualTo(1); TestService.reset(); } - @After + @AfterEach public void close() { TestService.reset(); } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java index 1da44138..20b8e9f7 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java @@ -21,8 +21,7 @@ import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; @@ -39,7 +38,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.RequestEntity; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -50,7 +48,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen * @author Dave Syer * */ -@RunWith(SpringRunner.class) + @SpringBootTest(classes = ClientApp.class, properties = { "management.endpoints.web.exposure.include=*", "management.endpoint.env.post.enabled=true" }, webEnvironment = RANDOM_PORT) diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConcurrencyTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConcurrencyTests.java index e380bfd1..06a96cc9 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConcurrencyTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConcurrencyTests.java @@ -25,8 +25,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -45,11 +44,9 @@ import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Repeat; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class RefreshScopeConcurrencyTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationScaleTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationScaleTests.java index 78d96d23..60eb2b20 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationScaleTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationScaleTests.java @@ -27,8 +27,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -47,12 +46,10 @@ import org.springframework.context.annotation.Import; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Repeat; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.ObjectUtils; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "logging.level.org.springframework.cloud.context.scope.refresh.RefreshScopeConfigurationScaleTests=DEBUG" }) public class RefreshScopeConfigurationScaleTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java index ddba0f64..e2c8a868 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java @@ -16,10 +16,8 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.scope.ScopedProxyUtils; import org.springframework.beans.factory.annotation.Value; @@ -44,12 +42,9 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class RefreshScopeConfigurationTests { - @Rule - public ExpectedException expected = ExpectedException.none(); - private AnnotationConfigApplicationContext context; - @After + @AfterEach public void init() { if (this.context != null) { this.context.close(); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeIntegrationTests.java index 46209dbc..aecd8518 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeIntegrationTests.java @@ -18,10 +18,10 @@ package org.springframework.cloud.context.scope.refresh; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.scope.ScopedProxyUtils; @@ -40,11 +40,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class RefreshScopeIntegrationTests { @@ -57,13 +55,13 @@ public class RefreshScopeIntegrationTests { @Autowired private org.springframework.cloud.context.scope.refresh.RefreshScope scope; - @Before + @BeforeEach public void init() { then(ExampleService.getInitCount()).isEqualTo(1); ExampleService.reset(); } - @After + @AfterEach public void close() { ExampleService.reset(); } @@ -119,10 +117,12 @@ public class RefreshScopeIntegrationTests { } // see gh-349 - @Test(expected = ServiceException.class) + @Test @DirtiesContext - public void testCheckedException() throws Exception { - this.service.throwsException(); + public void testCheckedException() { + Assertions.assertThrows(ServiceException.class, () -> { + this.service.throwsException(); + }); } public interface Service { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeLazyIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeLazyIntegrationTests.java index c1186183..c0aee999 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeLazyIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeLazyIntegrationTests.java @@ -18,10 +18,9 @@ package org.springframework.cloud.context.scope.refresh; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.scope.ScopedProxyUtils; @@ -42,11 +41,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class RefreshScopeLazyIntegrationTests { @@ -59,14 +56,14 @@ public class RefreshScopeLazyIntegrationTests { @Autowired private org.springframework.cloud.context.scope.refresh.RefreshScope scope; - @Before + @BeforeEach public void init() { // The RefreshScope is lazy (eager=false) so it won't have been instantiated yet then(ExampleService.getInitCount()).isEqualTo(0); ExampleService.reset(); } - @After + @AfterEach public void close() { ExampleService.reset(); } diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeListBindingIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeListBindingIntegrationTests.java index dd880ac1..2831adac 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeListBindingIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeListBindingIntegrationTests.java @@ -20,8 +20,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.annotation.Autowired; @@ -40,11 +39,9 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.PropertySource; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class, properties = { "test.messages[0]=one", "test.messages[1]=two" }) public class RefreshScopeListBindingIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeNullBeanIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeNullBeanIntegrationTests.java index 9e578bdc..8f7afa91 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeNullBeanIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeNullBeanIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; @@ -28,11 +27,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = { RefreshScopeNullBeanIntegrationTests.TestConfiguration.class }) public class RefreshScopeNullBeanIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopePureScaleTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopePureScaleTests.java index 6af6e026..61cc3da7 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopePureScaleTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopePureScaleTests.java @@ -27,8 +27,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -43,12 +42,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Repeat; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.ObjectUtils; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) // , // properties="logging.level.org.springframework.cloud.context.scope.refresh.RefreshScopePureScaleTests=DEBUG") diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeScaleTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeScaleTests.java index 39ce6ed8..056c9065 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeScaleTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeScaleTests.java @@ -25,8 +25,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -45,11 +44,9 @@ import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Repeat; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.BDDAssertions.then; -@RunWith(SpringRunner.class) @SpringBootTest(classes = TestConfiguration.class) public class RefreshScopeScaleTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java index 3cc2ef0a..df903e29 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.WebApplicationType; diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeWebIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeWebIntegrationTests.java index 8503f4cd..748e936a 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeWebIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeWebIntegrationTests.java @@ -16,8 +16,7 @@ package org.springframework.cloud.context.scope.refresh; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.aop.scope.ScopedProxyUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -31,7 +30,6 @@ import org.springframework.cloud.context.environment.EnvironmentManager; import org.springframework.cloud.context.scope.refresh.RefreshScopeWebIntegrationTests.Application; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -41,7 +39,6 @@ import static org.assertj.core.api.BDDAssertions.then; * @author Dave Syer * */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class RefreshScopeWebIntegrationTests { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/health/RefreshScopeHealthIndicatorTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/health/RefreshScopeHealthIndicatorTests.java index c9046519..ea549487 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/health/RefreshScopeHealthIndicatorTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/health/RefreshScopeHealthIndicatorTests.java @@ -18,8 +18,8 @@ package org.springframework.cloud.health; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.BDDMockito; import org.springframework.beans.factory.ObjectProvider; @@ -45,7 +45,7 @@ public class RefreshScopeHealthIndicatorTests { private RefreshScopeHealthIndicator indicator = new RefreshScopeHealthIndicator(this.scopeProvider, this.rebinder); - @Before + @BeforeEach public void init() { BDDMockito.willReturn(this.scope).given(this.scopeProvider).getIfAvailable(); when(this.rebinder.getErrors()).thenReturn(Collections.emptyMap()); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/logging/LoggingRebinderTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/logging/LoggingRebinderTests.java index ff1aaff7..e04401cd 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/logging/LoggingRebinderTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/logging/LoggingRebinderTests.java @@ -19,8 +19,8 @@ package org.springframework.cloud.logging; import java.util.Collections; import ch.qos.logback.classic.Level; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +43,7 @@ public class LoggingRebinderTests { private Logger logger = LoggerFactory.getLogger("org.springframework.web"); - @After + @AfterEach public void reset() { LoggingSystem.get(getClass().getClassLoader()).setLogLevel("org.springframework.web", LogLevel.INFO); }