diff --git a/spring-cloud-config-client-tls-tests/pom.xml b/spring-cloud-config-client-tls-tests/pom.xml
index ff057a05..b7382269 100644
--- a/spring-cloud-config-client-tls-tests/pom.xml
+++ b/spring-cloud-config-client-tls-tests/pom.xml
@@ -92,8 +92,8 @@
test
- org.junit.vintage
- junit-vintage-engine
+ org.junit.platform
+ junit-platform-launcher
test
diff --git a/spring-cloud-config-client-tls-tests/src/test/java/org/springframework/cloud/config/client/tls/AbstractTlsSetup.java b/spring-cloud-config-client-tls-tests/src/test/java/org/springframework/cloud/config/client/tls/AbstractTlsSetup.java
index e09ea4a7..e116ca7f 100644
--- a/spring-cloud-config-client-tls-tests/src/test/java/org/springframework/cloud/config/client/tls/AbstractTlsSetup.java
+++ b/spring-cloud-config-client-tls-tests/src/test/java/org/springframework/cloud/config/client/tls/AbstractTlsSetup.java
@@ -21,7 +21,7 @@ import java.io.FileOutputStream;
import java.io.OutputStream;
import java.security.KeyStore;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.BeforeAll;
public abstract class AbstractTlsSetup {
@@ -41,7 +41,7 @@ public abstract class AbstractTlsSetup {
protected static File wrongClientCert;
- @BeforeClass
+ @BeforeAll
public static void createCertificates() throws Exception {
KeyTool tool = new KeyTool();
diff --git a/spring-cloud-config-client-tls-tests/src/test/java/org/springframework/cloud/config/client/tls/ConfigClientTlsTests.java b/spring-cloud-config-client-tls-tests/src/test/java/org/springframework/cloud/config/client/tls/ConfigClientTlsTests.java
index dbeb5fd8..c9213c6f 100644
--- a/spring-cloud-config-client-tls-tests/src/test/java/org/springframework/cloud/config/client/tls/ConfigClientTlsTests.java
+++ b/spring-cloud-config-client-tls-tests/src/test/java/org/springframework/cloud/config/client/tls/ConfigClientTlsTests.java
@@ -18,9 +18,10 @@ package org.springframework.cloud.config.client.tls;
import java.io.File;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -32,12 +33,12 @@ public class ConfigClientTlsTests extends AbstractTlsSetup {
protected static TlsConfigServerRunner server;
- @BeforeClass
+ @BeforeAll
public static void setupAll() throws Exception {
startConfigServer();
}
- @AfterClass
+ @AfterAll
public static void tearDownAll() {
stopConfigServer();
}
@@ -96,20 +97,24 @@ public class ConfigClientTlsTests extends AbstractTlsSetup {
}
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void wrongPasswordCauseFailure() {
- TlsConfigClientRunner client = createConfigClient(false);
- enableTlsClient(client);
- client.setKeyStore(clientCert, WRONG_PASSWORD, WRONG_PASSWORD);
- client.start();
+ Assertions.assertThrows(IllegalStateException.class, () -> {
+ TlsConfigClientRunner client = createConfigClient(false);
+ enableTlsClient(client);
+ client.setKeyStore(clientCert, WRONG_PASSWORD, WRONG_PASSWORD);
+ client.start();
+ });
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void nonExistKeyStoreCauseFailure() {
- TlsConfigClientRunner client = createConfigClient(false);
- enableTlsClient(client);
- client.setKeyStore(new File("nonExistFile"));
- client.start();
+ Assertions.assertThrows(IllegalStateException.class, () -> {
+ TlsConfigClientRunner client = createConfigClient(false);
+ enableTlsClient(client);
+ client.setKeyStore(new File("nonExistFile"));
+ client.start();
+ });
}
@Test
diff --git a/spring-cloud-config-client/pom.xml b/spring-cloud-config-client/pom.xml
index 11398624..0ac027a2 100644
--- a/spring-cloud-config-client/pom.xml
+++ b/spring-cloud-config-client/pom.xml
@@ -86,8 +86,8 @@
test
- org.junit.vintage
- junit-vintage-engine
+ org.junit.platform
+ junit-platform-launcher
test
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/BaseDiscoveryClientConfigServiceBootstrapConfigurationTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/BaseDiscoveryClientConfigServiceBootstrapConfigurationTests.java
index d6ffdddd..df1fd00e 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/BaseDiscoveryClientConfigServiceBootstrapConfigurationTests.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/BaseDiscoveryClientConfigServiceBootstrapConfigurationTests.java
@@ -19,9 +19,7 @@ package org.springframework.cloud.config.client;
import java.util.Arrays;
import java.util.Collections;
-import org.junit.After;
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.AfterEach;
import org.mockito.Mockito;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
@@ -41,16 +39,13 @@ import static org.springframework.cloud.config.client.ConfigClientProperties.Dis
public abstract class BaseDiscoveryClientConfigServiceBootstrapConfigurationTests {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
protected AnnotationConfigApplicationContext context;
protected DiscoveryClient client = Mockito.mock(DiscoveryClient.class);
protected ServiceInstance info = new DefaultServiceInstance("app:8877", "app", "foo", 8877, false);
- @After
+ @AfterEach
public void close() {
if (this.context != null) {
this.context.close();
@@ -74,11 +69,6 @@ public abstract class BaseDiscoveryClientConfigServiceBootstrapConfigurationTest
.willReturn(Collections.emptyList()).willReturn(Collections.singletonList(this.info));
}
- void expectNoInstancesOfConfigServerException() {
- this.expectedException.expect(IllegalStateException.class);
- this.expectedException.expectMessage("No instances found of configserver (" + DEFAULT_CONFIG_SERVER + ")");
- }
-
void expectDiscoveryClientConfigServiceBootstrapConfigurationIsSetup() {
assertThat(this.context.getBeanNamesForType(DiscoveryClientConfigServiceBootstrapConfiguration.class).length)
.isEqualTo(1);
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigClientPropertiesTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigClientPropertiesTests.java
index 86fcfe9d..83d0dd98 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigClientPropertiesTests.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigClientPropertiesTests.java
@@ -16,9 +16,8 @@
package org.springframework.cloud.config.client;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.cloud.config.client.ConfigClientProperties.Credentials;
@@ -35,9 +34,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class ConfigClientPropertiesTests {
- @Rule
- public ExpectedException expected = ExpectedException.none();
-
private ConfigClientProperties locator = new ConfigClientProperties(new StandardEnvironment());
@Test
@@ -149,26 +145,26 @@ public class ConfigClientPropertiesTests {
@Test
public void checkIfExceptionThrownForNegativeIndex() {
- this.locator.setUri(new String[] { "http://localhost:8888", "http://localhost:8889" });
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage("Trying to access an invalid array index");
- Credentials credentials = this.locator.getCredentials(-1);
+ Assertions.assertThatThrownBy(() -> {
+ this.locator.setUri(new String[] { "http://localhost:8888", "http://localhost:8889" });
+ Credentials credentials = this.locator.getCredentials(-1);
+ }).isInstanceOf(IllegalStateException.class).hasMessageContaining("Trying to access an invalid array index");
}
@Test
public void checkIfExceptionThrownForPositiveInvalidIndex() {
- this.locator.setUri(new String[] { "http://localhost:8888", "http://localhost:8889" });
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage("Trying to access an invalid array index");
- Credentials credentials = this.locator.getCredentials(3);
+ Assertions.assertThatThrownBy(() -> {
+ this.locator.setUri(new String[] { "http://localhost:8888", "http://localhost:8889" });
+ Credentials credentials = this.locator.getCredentials(3);
+ }).isInstanceOf(IllegalStateException.class).hasMessageContaining("Trying to access an invalid array index");
}
@Test
public void checkIfExceptionThrownForIndexEqualToLength() {
- this.locator.setUri(new String[] { "http://localhost:8888", "http://localhost:8889" });
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage("Trying to access an invalid array index");
- Credentials credentials = this.locator.getCredentials(2);
+ Assertions.assertThatThrownBy(() -> {
+ this.locator.setUri(new String[] { "http://localhost:8888", "http://localhost:8889" });
+ Credentials credentials = this.locator.getCredentials(2);
+ }).isInstanceOf(IllegalStateException.class).hasMessageContaining("Trying to access an invalid array index");
}
@Test
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigClientWatchTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigClientWatchTests.java
index 8773cf89..28c7082c 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigClientWatchTests.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigClientWatchTests.java
@@ -16,7 +16,7 @@
package org.springframework.cloud.config.client;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServerBootstrapConfigurationTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServerBootstrapConfigurationTests.java
index 2fb8263c..3bc06345 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServerBootstrapConfigurationTests.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServerBootstrapConfigurationTests.java
@@ -16,7 +16,7 @@
package org.springframework.cloud.config.client;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.boot.WebApplicationType;
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServiceBootstrapConfigurationTest.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServiceBootstrapConfigurationTest.java
index be7d3fc0..cf68b4b2 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServiceBootstrapConfigurationTest.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServiceBootstrapConfigurationTest.java
@@ -18,9 +18,9 @@ package org.springframework.cloud.config.client;
import java.lang.reflect.Field;
-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.test.util.TestPropertyValues;
@@ -41,12 +41,12 @@ public class ConfigServiceBootstrapConfigurationTest {
private AnnotationConfigApplicationContext context;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
this.context = new AnnotationConfigApplicationContext();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
if (this.context != null) {
this.context.close();
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocatorTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocatorTests.java
index 2423baa7..aff87d90 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocatorTests.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocatorTests.java
@@ -27,10 +27,9 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.logging.LogFactory;
-import org.hamcrest.core.IsInstanceOf;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.assertj.core.api.AbstractThrowableAssert;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
@@ -66,9 +65,6 @@ import static org.springframework.cloud.config.environment.EnvironmentMediaType.
public class ConfigServicePropertySourceLocatorTests {
- @Rule
- public ExpectedException expected = ExpectedException.none();
-
private ConfigurableEnvironment environment = new StandardEnvironment();
private ConfigServicePropertySourceLocator locator = new ConfigServicePropertySourceLocator(
@@ -140,16 +136,16 @@ public class ConfigServicePropertySourceLocatorTests {
@Test
public void sunnyDayWithNoSuchLabelAndFailFast() {
- ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
- defaults.setFailFast(true);
- this.locator = new ConfigServicePropertySourceLocator(defaults);
- mockRequestResponseWithLabel(new ResponseEntity<>((Void) null, HttpStatus.NOT_FOUND), "release(_)v1.0.0");
- this.locator.setRestTemplate(this.restTemplate);
- TestPropertyValues.of("spring.cloud.config.label:release/v1.0.1").applyTo(this.environment);
- this.expected.expect(IsInstanceOf.instanceOf(IllegalStateException.class));
- this.expected.expectMessage(
+ Assertions.assertThatThrownBy(() -> {
+ ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
+ defaults.setFailFast(true);
+ this.locator = new ConfigServicePropertySourceLocator(defaults);
+ mockRequestResponseWithLabel(new ResponseEntity<>((Void) null, HttpStatus.NOT_FOUND), "release(_)v1.0.0");
+ this.locator.setRestTemplate(this.restTemplate);
+ TestPropertyValues.of("spring.cloud.config.label:release/v1.0.1").applyTo(this.environment);
+ this.locator.locateCollection(this.environment);
+ }).isInstanceOf(IllegalStateException.class).hasMessageContaining(
"Could not locate PropertySource and the fail fast property is set, failing: None of labels [release/v1.0.1] found");
- this.locator.locateCollection(this.environment);
}
@Test
@@ -161,61 +157,62 @@ public class ConfigServicePropertySourceLocatorTests {
@Test
public void failFast() throws Exception {
- ClientHttpRequestFactory requestFactory = Mockito.mock(ClientHttpRequestFactory.class);
- mockRequestResponse(requestFactory, null, HttpStatus.INTERNAL_SERVER_ERROR);
- RestTemplate restTemplate = new RestTemplate(requestFactory);
- ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
- defaults.setFailFast(true);
- this.locator = new ConfigServicePropertySourceLocator(defaults);
- this.locator.setRestTemplate(restTemplate);
- this.expected.expect(IsInstanceOf.instanceOf(IllegalStateException.class));
- this.expected.expectCause(IsInstanceOf.instanceOf(HttpServerErrorException.class));
- this.expected.expectMessage("fail fast property is set");
- this.locator.locateCollection(this.environment);
+ Assertions.assertThatThrownBy(() -> {
+ ClientHttpRequestFactory requestFactory = Mockito.mock(ClientHttpRequestFactory.class);
+ mockRequestResponse(requestFactory, null, HttpStatus.INTERNAL_SERVER_ERROR);
+ RestTemplate restTemplate = new RestTemplate(requestFactory);
+ ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
+ defaults.setFailFast(true);
+ this.locator = new ConfigServicePropertySourceLocator(defaults);
+ this.locator.setRestTemplate(restTemplate);
+ this.locator.locateCollection(this.environment);
+ }).isInstanceOf(IllegalStateException.class).hasCauseInstanceOf(HttpServerErrorException.class)
+ .hasMessageContaining("fail fast property is set");
}
@Test
public void failFastWhenNotFound() throws Exception {
- ClientHttpRequestFactory requestFactory = Mockito.mock(ClientHttpRequestFactory.class);
- mockRequestResponse(requestFactory, null, HttpStatus.NOT_FOUND);
- RestTemplate restTemplate = new RestTemplate(requestFactory);
- ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
- defaults.setFailFast(true);
- this.locator = new ConfigServicePropertySourceLocator(defaults);
- this.locator.setRestTemplate(restTemplate);
- this.expected.expect(IsInstanceOf.instanceOf(IllegalStateException.class));
- this.expected.expectMessage("fail fast property is set, failing: None of labels [] found");
- this.locator.locateCollection(this.environment);
+ Assertions.assertThatThrownBy(() -> {
+ ClientHttpRequestFactory requestFactory = Mockito.mock(ClientHttpRequestFactory.class);
+ mockRequestResponse(requestFactory, null, HttpStatus.NOT_FOUND);
+ RestTemplate restTemplate = new RestTemplate(requestFactory);
+ ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
+ defaults.setFailFast(true);
+ this.locator = new ConfigServicePropertySourceLocator(defaults);
+ this.locator.setRestTemplate(restTemplate);
+ this.locator.locateCollection(this.environment);
+ }).isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining("fail fast property is set, failing: None of labels [] found");
}
@Test
public void failFastWhenRequestTimesOut() {
- mockRequestTimedOut();
- ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
- defaults.setFailFast(true);
- this.locator = new ConfigServicePropertySourceLocator(defaults);
- this.locator.setRestTemplate(this.restTemplate);
- this.expected.expect(IsInstanceOf.instanceOf(IllegalStateException.class));
- this.expected.expectCause(IsInstanceOf.instanceOf(ResourceAccessException.class));
- this.expected.expectMessage("fail fast property is set");
- this.locator.locateCollection(this.environment);
+ Assertions.assertThatThrownBy(() -> {
+ mockRequestTimedOut();
+ ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
+ defaults.setFailFast(true);
+ this.locator = new ConfigServicePropertySourceLocator(defaults);
+ this.locator.setRestTemplate(this.restTemplate);
+ this.locator.locateCollection(this.environment);
+ }).isInstanceOf(IllegalStateException.class).hasMessageContaining("fail fast property is set");
}
@Test
public void failFastWhenBothPasswordAndAuthorizationPropertiesSet() throws Exception {
- ClientHttpRequestFactory requestFactory = Mockito.mock(ClientHttpRequestFactory.class);
- ClientHttpRequest request = Mockito.mock(ClientHttpRequest.class);
- Mockito.when(requestFactory.createRequest(Mockito.any(URI.class), Mockito.any(HttpMethod.class)))
- .thenReturn(request);
- ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
- defaults.setFailFast(true);
- defaults.setUsername("username");
- defaults.setPassword("password");
- defaults.getHeaders().put(AUTHORIZATION, "Basic dXNlcm5hbWU6cGFzc3dvcmQNCg==");
- this.locator = new ConfigServicePropertySourceLocator(defaults);
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage("Could not locate PropertySource and the fail fast property is set, failing");
- this.locator.locateCollection(this.environment);
+ Assertions.assertThatThrownBy(() -> {
+ ClientHttpRequestFactory requestFactory = Mockito.mock(ClientHttpRequestFactory.class);
+ ClientHttpRequest request = Mockito.mock(ClientHttpRequest.class);
+ Mockito.when(requestFactory.createRequest(Mockito.any(URI.class), Mockito.any(HttpMethod.class)))
+ .thenReturn(request);
+ ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
+ defaults.setFailFast(true);
+ defaults.setUsername("username");
+ defaults.setPassword("password");
+ defaults.getHeaders().put(AUTHORIZATION, "Basic dXNlcm5hbWU6cGFzc3dvcmQNCg==");
+ this.locator = new ConfigServicePropertySourceLocator(defaults);
+ this.locator.locateCollection(this.environment);
+ }).isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining("Could not locate PropertySource and the fail fast property is set, failing");
}
@Test
@@ -253,32 +250,33 @@ public class ConfigServicePropertySourceLocatorTests {
@Test
public void shouldThrowExceptionWhenPasswordAndAuthorizationBothSet() {
- HttpHeaders headers = new HttpHeaders();
- ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
- defaults.getHeaders().put(AUTHORIZATION, "Basic dXNlcm5hbWU6cGFzc3dvcmQNCg==");
- String username = "user";
- String password = "pass";
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage("You must set either 'password' or 'authorization'");
- factory(defaults).addAuthorizationToken(headers, username, password);
+ Assertions.assertThatThrownBy(() -> {
+ HttpHeaders headers = new HttpHeaders();
+ ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
+ defaults.getHeaders().put(AUTHORIZATION, "Basic dXNlcm5hbWU6cGFzc3dvcmQNCg==");
+ String username = "user";
+ String password = "pass";
+ factory(defaults).addAuthorizationToken(headers, username, password);
+ }).isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining("You must set either 'password' or 'authorization'");
}
@Test
public void shouldThrowExceptionWhenNegativeReadTimeoutSet() {
- ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
- defaults.setRequestReadTimeout(-1);
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage("Invalid Value for Read Timeout set.");
- factory(defaults).create();
+ Assertions.assertThatThrownBy(() -> {
+ ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
+ defaults.setRequestReadTimeout(-1);
+ factory(defaults).create();
+ }).isInstanceOf(IllegalStateException.class).hasMessageContaining("Invalid Value for Read Timeout set.");
}
@Test
public void shouldThrowExceptionWhenNegativeConnectTimeoutSet() {
- ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
- defaults.setRequestConnectTimeout(-1);
- this.expected.expect(IllegalStateException.class);
- this.expected.expectMessage("Invalid Value for Connect Timeout set.");
- factory(defaults).create();
+ Assertions.assertThatThrownBy(() -> {
+ ConfigClientProperties defaults = new ConfigClientProperties(this.environment);
+ defaults.setRequestConnectTimeout(-1);
+ factory(defaults).create();
+ }).isInstanceOf(IllegalStateException.class).hasMessageContaining("Invalid Value for Connect Timeout set.");
}
@Test
@@ -440,29 +438,32 @@ public class ConfigServicePropertySourceLocatorTests {
}
private void assertNextUriIsNotTried(ConfigClientProperties.MultipleUriStrategy multipleUriStrategy,
- HttpStatus firstUriResponse, Class extends Exception> expectedCause) throws Exception {
- // Set up with two URIs.
- ConfigClientProperties clientProperties = new ConfigClientProperties(this.environment);
- String badURI = "http://baduri";
- String goodURI = "http://localhost:8888";
- String[] uris = new String[] { badURI, goodURI };
- clientProperties.setUri(uris);
- clientProperties.setFailFast(true);
- // Strategy is CONNECTION_TIMEOUT_ONLY, so it should not try the next URI for
- // INTERNAL_SERVER_ERROR
- clientProperties.setMultipleUriStrategy(multipleUriStrategy);
- this.locator = new ConfigServicePropertySourceLocator(clientProperties);
- ClientHttpRequestFactory requestFactory = Mockito.mock(ClientHttpRequestFactory.class);
- RestTemplate restTemplate = new RestTemplate(requestFactory);
- mockRequestResponse(requestFactory, badURI, firstUriResponse);
- mockRequestResponse(requestFactory, goodURI, HttpStatus.OK);
- this.locator.setRestTemplate(restTemplate);
- this.expected.expect(IsInstanceOf.instanceOf(IllegalStateException.class));
- if (expectedCause != null) {
- this.expected.expectCause(IsInstanceOf.instanceOf(expectedCause));
+ HttpStatus firstUriResponse, Class extends Exception> expectedCause) {
+ AbstractThrowableAssert throwableAssert = Assertions.assertThatThrownBy(() -> {
+ // Set up with two URIs.
+ ConfigClientProperties clientProperties = new ConfigClientProperties(this.environment);
+ String badURI = "http://baduri";
+ String goodURI = "http://localhost:8888";
+ String[] uris = new String[] { badURI, goodURI };
+ clientProperties.setUri(uris);
+ clientProperties.setFailFast(true);
+ // Strategy is CONNECTION_TIMEOUT_ONLY, so it should not try the next URI for
+ // INTERNAL_SERVER_ERROR
+ clientProperties.setMultipleUriStrategy(multipleUriStrategy);
+ this.locator = new ConfigServicePropertySourceLocator(clientProperties);
+ ClientHttpRequestFactory requestFactory = Mockito.mock(ClientHttpRequestFactory.class);
+ RestTemplate restTemplate = new RestTemplate(requestFactory);
+ mockRequestResponse(requestFactory, badURI, firstUriResponse);
+ mockRequestResponse(requestFactory, goodURI, HttpStatus.OK);
+ this.locator.setRestTemplate(restTemplate);
+ this.locator.locateCollection(this.environment);
+ });
+ if (expectedCause == null) {
+ throwableAssert.hasNoCause().hasMessageContaining("fail fast property is set");
+ }
+ else {
+ throwableAssert.hasCauseInstanceOf(expectedCause).hasMessageContaining("fail fast property is set");
}
- this.expected.expectMessage("fail fast property is set");
- this.locator.locateCollection(this.environment);
}
@SuppressWarnings("SameParameterValue")
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigDataConfigurationNoRetryTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigDataConfigurationNoRetryTests.java
index bbb35bf5..1bf01f9f 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigDataConfigurationNoRetryTests.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigDataConfigurationNoRetryTests.java
@@ -21,9 +21,8 @@ import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.boot.BootstrapRegistry;
@@ -36,7 +35,6 @@ import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.config.client.ConfigClientProperties.Credentials;
import org.springframework.cloud.test.ClassPathExclusions;
-import org.springframework.cloud.test.ModifiedClassPathRunner;
import org.springframework.context.ConfigurableApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,7 +46,6 @@ import static org.springframework.cloud.config.client.ConfigClientProperties.Dis
/**
* @author Dave Syer
*/
-@RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions({ "spring-retry-*.jar", "spring-boot-starter-aop-*.jar" })
public class DiscoveryClientConfigDataConfigurationNoRetryTests {
@@ -58,7 +55,7 @@ public class DiscoveryClientConfigDataConfigurationNoRetryTests {
protected ServiceInstance info = new DefaultServiceInstance("app:8877", "app", "foo", 8877, false);
- @After
+ @AfterEach
public void close() {
if (this.context != null) {
this.context.close();
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfigurationNoSpringRetryTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfigurationNoSpringRetryTests.java
index af83aee6..c62447d4 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfigurationNoSpringRetryTests.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfigurationNoSpringRetryTests.java
@@ -16,24 +16,23 @@
package org.springframework.cloud.config.client;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.cloud.test.ClassPathExclusions;
-import org.springframework.cloud.test.ModifiedClassPathRunner;
-@RunWith(ModifiedClassPathRunner.class)
+import static org.springframework.cloud.config.client.ConfigClientProperties.Discovery.DEFAULT_CONFIG_SERVER;
+
@ClassPathExclusions({ "spring-retry-*.jar", "spring-boot-starter-aop-*.jar" })
public class DiscoveryClientConfigServiceBootstrapConfigurationNoSpringRetryTests
extends BaseDiscoveryClientConfigServiceBootstrapConfigurationTests {
@Test
public void shouldFailWithExceptionGetConfigServerInstanceFromDiscoveryClient() throws Exception {
- givenDiscoveryClientReturnsNoInfo();
-
- expectNoInstancesOfConfigServerException();
-
- setup("spring.cloud.config.discovery.enabled=true", "spring.cloud.config.fail-fast=true");
+ org.assertj.core.api.Assertions.assertThatThrownBy(() -> {
+ givenDiscoveryClientReturnsNoInfo();
+ setup("spring.cloud.config.discovery.enabled=true", "spring.cloud.config.fail-fast=true");
+ }).isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining("No instances found of configserver (" + DEFAULT_CONFIG_SERVER + ")");
}
@Test
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfigurationTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfigurationTests.java
index 0b46b3e7..fd7eb797 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfigurationTests.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfigurationTests.java
@@ -18,7 +18,7 @@ package org.springframework.cloud.config.client;
import java.util.Collections;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
@@ -178,13 +178,12 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests
}
@Test
- public void shouldRetryAndFailWithExceptionGetConfigServerInstanceFromDiscoveryClient() throws Exception {
- givenDiscoveryClientReturnsNoInfo();
-
- expectNoInstancesOfConfigServerException();
-
- setup("spring.cloud.config.discovery.enabled=true", "spring.cloud.config.retry.maxAttempts=3",
- "spring.cloud.config.retry.initialInterval=10", "spring.cloud.config.fail-fast=true");
+ public void shouldRetryAndFailWithExceptionGetConfigServerInstanceFromDiscoveryClient() {
+ org.assertj.core.api.Assertions.assertThatThrownBy(() -> {
+ givenDiscoveryClientReturnsNoInfo();
+ setup("spring.cloud.config.discovery.enabled=true", "spring.cloud.config.retry.maxAttempts=3",
+ "spring.cloud.config.retry.initialInterval=10", "spring.cloud.config.fail-fast=true");
+ }).isInstanceOf(IllegalStateException.class);
}
@Test
diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/environment/EnvironmentTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/environment/EnvironmentTests.java
index e72b7453..dcf85566 100644
--- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/environment/EnvironmentTests.java
+++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/config/environment/EnvironmentTests.java
@@ -16,7 +16,7 @@
package org.springframework.cloud.config.environment;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/spring-cloud-config-monitor/pom.xml b/spring-cloud-config-monitor/pom.xml
index 3315c44a..7f3fa558 100644
--- a/spring-cloud-config-monitor/pom.xml
+++ b/spring-cloud-config-monitor/pom.xml
@@ -47,8 +47,8 @@
test
- org.junit.vintage
- junit-vintage-engine
+ org.junit.platform
+ junit-platform-launcher
test
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/BitbucketPropertyPathNotificationExtractorTests.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/BitbucketPropertyPathNotificationExtractorTests.java
index 48e1193c..ae6ea92d 100644
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/BitbucketPropertyPathNotificationExtractorTests.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/BitbucketPropertyPathNotificationExtractorTests.java
@@ -21,8 +21,8 @@ import java.util.UUID;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
@@ -41,7 +41,7 @@ public class BitbucketPropertyPathNotificationExtractorTests {
private HttpHeaders headers;
- @Before
+ @BeforeEach
public void setup() {
this.headers = new HttpHeaders();
}
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/CompositePropertyPathNotificationExtractorTests.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/CompositePropertyPathNotificationExtractorTests.java
index c889d616..6fae4cd8 100644
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/CompositePropertyPathNotificationExtractorTests.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/CompositePropertyPathNotificationExtractorTests.java
@@ -22,7 +22,7 @@ import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/EnvironmentMonitorAutoConfigurationTests.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/EnvironmentMonitorAutoConfigurationTests.java
index 6fefe54b..a83905a7 100644
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/EnvironmentMonitorAutoConfigurationTests.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/EnvironmentMonitorAutoConfigurationTests.java
@@ -18,7 +18,7 @@ package org.springframework.cloud.config.monitor;
import java.util.Collection;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerProperties;
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/FileMonitorConfigurationTest.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/FileMonitorConfigurationTest.java
index 162cfafa..bf7b9ce3 100644
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/FileMonitorConfigurationTest.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/FileMonitorConfigurationTest.java
@@ -23,9 +23,9 @@ import java.util.List;
import java.util.Set;
import io.micrometer.observation.ObservationRegistry;
-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.cloud.config.server.environment.AbstractScmEnvironmentRepository;
import org.springframework.cloud.config.server.environment.JGitEnvironmentProperties;
@@ -54,12 +54,12 @@ public class FileMonitorConfigurationTest {
private List repositories = new ArrayList<>();
- @Before
+ @BeforeEach
public void setup() {
fileMonitorConfiguration.setResourceLoader(new FileSystemResourceLoader());
}
- @After
+ @AfterEach
public void tearDown() {
fileMonitorConfiguration.stop();
}
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GiteaPropertyPathNotificationExtractorTests.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GiteaPropertyPathNotificationExtractorTests.java
index 1b9b7287..9024ab84 100755
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GiteaPropertyPathNotificationExtractorTests.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GiteaPropertyPathNotificationExtractorTests.java
@@ -20,7 +20,7 @@ import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GiteePropertyPathNotificationExtractorTests.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GiteePropertyPathNotificationExtractorTests.java
index 9b5352e8..38979cc6 100644
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GiteePropertyPathNotificationExtractorTests.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GiteePropertyPathNotificationExtractorTests.java
@@ -20,7 +20,7 @@ import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GithubPropertyPathNotificationExtractorTests.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GithubPropertyPathNotificationExtractorTests.java
index cd02eacb..c8bcfc63 100644
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GithubPropertyPathNotificationExtractorTests.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GithubPropertyPathNotificationExtractorTests.java
@@ -20,7 +20,7 @@ import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GitlabPropertyPathNotificationExtractorTests.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GitlabPropertyPathNotificationExtractorTests.java
index bfdb74f8..7f082f33 100644
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GitlabPropertyPathNotificationExtractorTests.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GitlabPropertyPathNotificationExtractorTests.java
@@ -20,7 +20,7 @@ import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GogsPropertyPathNotificationExtractorTests.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GogsPropertyPathNotificationExtractorTests.java
index 5a6c04b9..06e2f6a5 100755
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GogsPropertyPathNotificationExtractorTests.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/GogsPropertyPathNotificationExtractorTests.java
@@ -20,7 +20,7 @@ import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
diff --git a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/PropertyPathEndpointTests.java b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/PropertyPathEndpointTests.java
index d1bccab5..9350d0b0 100644
--- a/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/PropertyPathEndpointTests.java
+++ b/spring-cloud-config-monitor/src/test/java/org/springframework/cloud/config/monitor/PropertyPathEndpointTests.java
@@ -20,8 +20,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.http.HttpHeaders;
@@ -37,7 +37,7 @@ public class PropertyPathEndpointTests {
private PropertyPathEndpoint endpoint = new PropertyPathEndpoint(
new CompositePropertyPathNotificationExtractor(Collections.emptyList()), "abc1");
- @Before
+ @BeforeEach
public void init() {
StaticApplicationContext publisher = new StaticApplicationContext();
this.endpoint.setApplicationEventPublisher(publisher);
diff --git a/spring-cloud-config-sample/pom.xml b/spring-cloud-config-sample/pom.xml
index 6ba34e93..9b8c5016 100644
--- a/spring-cloud-config-sample/pom.xml
+++ b/spring-cloud-config-sample/pom.xml
@@ -53,8 +53,8 @@
test
- org.junit.vintage
- junit-vintage-engine
+ org.junit.platform
+ junit-platform-launcher
test
diff --git a/spring-cloud-config-sample/src/test/java/sample/ApplicationBootstrapTests.java b/spring-cloud-config-sample/src/test/java/sample/ApplicationBootstrapTests.java
index fe249f01..daa50455 100644
--- a/spring-cloud-config-sample/src/test/java/sample/ApplicationBootstrapTests.java
+++ b/spring-cloud-config-sample/src/test/java/sample/ApplicationBootstrapTests.java
@@ -19,10 +19,9 @@ package sample;
import java.io.IOException;
import java.util.Map;
-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.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
@@ -32,7 +31,6 @@ import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentProperties;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.TestSocketUtils;
import static org.assertj.core.api.Assertions.assertThat;
@@ -47,7 +45,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
*
* @author Spencer Gibb
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,
// Normally spring.cloud.config.enabled:true is the default but since we have the
// config
@@ -67,7 +64,7 @@ public class ApplicationBootstrapTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void startConfigServer() throws IOException {
System.setProperty("spring.cloud.bootstrap.name", "bootstrapservercomposite");
String baseDir = ConfigServerTestUtils.getBaseDirectory("spring-cloud-config-sample");
@@ -80,7 +77,7 @@ public class ApplicationBootstrapTests {
System.setProperty("config.port", "" + configPort);
}
- @AfterClass
+ @AfterAll
public static void close() {
System.clearProperty("config.port");
System.clearProperty("spring.cloud.bootstrap.name");
diff --git a/spring-cloud-config-sample/src/test/java/sample/ApplicationTests.java b/spring-cloud-config-sample/src/test/java/sample/ApplicationTests.java
index bd94f2f8..45d85c1a 100644
--- a/spring-cloud-config-sample/src/test/java/sample/ApplicationTests.java
+++ b/spring-cloud-config-sample/src/test/java/sample/ApplicationTests.java
@@ -19,10 +19,9 @@ package sample;
import java.io.IOException;
import java.util.Map;
-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.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
@@ -31,13 +30,11 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.TestSocketUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,
// Normally spring.cloud.config.enabled:true is the default but since we have the
// config server on the classpath we need to set it explicitly
@@ -57,7 +54,7 @@ public class ApplicationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void startConfigServer() throws IOException {
String baseDir = ConfigServerTestUtils.getBaseDirectory("spring-cloud-config-sample");
String repo = ConfigServerTestUtils.prepareLocalRepo(baseDir, "target/repos", "config-repo", "target/config");
@@ -71,7 +68,7 @@ public class ApplicationTests {
System.setProperty("config.port", "" + configPort);
}
- @AfterClass
+ @AfterAll
public static void close() {
System.clearProperty("config.port");
if (server != null) {
diff --git a/spring-cloud-config-sample/src/test/java/sample/ConfigDataCustomMediaTypeIntegrationTests.java b/spring-cloud-config-sample/src/test/java/sample/ConfigDataCustomMediaTypeIntegrationTests.java
index 82fa0627..b401e31a 100644
--- a/spring-cloud-config-sample/src/test/java/sample/ConfigDataCustomMediaTypeIntegrationTests.java
+++ b/spring-cloud-config-sample/src/test/java/sample/ConfigDataCustomMediaTypeIntegrationTests.java
@@ -18,10 +18,9 @@ package sample;
import java.io.IOException;
-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.SpringApplication;
@@ -34,13 +33,11 @@ import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MutablePropertySources;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.TestSocketUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,
// Normally spring.cloud.config.enabled:true is the default but since we have the
// config server on the classpath we need to set it explicitly
@@ -62,7 +59,7 @@ public class ConfigDataCustomMediaTypeIntegrationTests {
@Autowired
ConfigurableEnvironment env;
- @BeforeClass
+ @BeforeAll
public static void startConfigServer() throws IOException {
String baseDir = ConfigServerTestUtils.getBaseDirectory("spring-cloud-config-sample");
String repo = ConfigServerTestUtils.prepareLocalRepo(baseDir, "target/repos", "config-repo", "target/config");
@@ -73,7 +70,7 @@ public class ConfigDataCustomMediaTypeIntegrationTests {
System.setProperty("spring.cloud.config.uri", "http://localhost:" + configPort);
}
- @AfterClass
+ @AfterAll
public static void close() {
System.clearProperty("spring.cloud.config.uri");
if (server != null) {
diff --git a/spring-cloud-config-sample/src/test/java/sample/ConfigDataIntegrationTests.java b/spring-cloud-config-sample/src/test/java/sample/ConfigDataIntegrationTests.java
index ffd7e0e4..1f001431 100644
--- a/spring-cloud-config-sample/src/test/java/sample/ConfigDataIntegrationTests.java
+++ b/spring-cloud-config-sample/src/test/java/sample/ConfigDataIntegrationTests.java
@@ -19,10 +19,9 @@ package sample;
import java.io.IOException;
import java.util.Map;
-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.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
@@ -31,13 +30,11 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.TestSocketUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,
// Normally spring.cloud.config.enabled:true is the default but since we have the
// config server on the classpath we need to set it explicitly
@@ -56,7 +53,7 @@ public class ConfigDataIntegrationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void startConfigServer() throws IOException {
String baseDir = ConfigServerTestUtils.getBaseDirectory("spring-cloud-config-sample");
String repo = ConfigServerTestUtils.prepareLocalRepo(baseDir, "target/repos", "config-repo", "target/config");
@@ -67,7 +64,7 @@ public class ConfigDataIntegrationTests {
System.setProperty("spring.cloud.config.uri", "http://localhost:" + configPort);
}
- @AfterClass
+ @AfterAll
public static void close() {
System.clearProperty("spring.cloud.config.uri");
if (server != null) {
diff --git a/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingIntegrationTests.java b/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingIntegrationTests.java
index fb466012..0f973c8d 100644
--- a/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingIntegrationTests.java
+++ b/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingIntegrationTests.java
@@ -18,10 +18,9 @@ package sample;
import java.util.Map;
-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.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
@@ -31,13 +30,11 @@ import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.TestSocketUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,
// Normally spring.cloud.config.enabled:true is the default but since we have the
// config server on the classpath we need to set it explicitly
@@ -58,7 +55,7 @@ public class ConfigDataOrderingIntegrationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void startConfigServer() {
server = SpringApplication.run(org.springframework.cloud.config.server.test.TestConfigServerApplication.class,
"--spring.profiles.active=native", "--server.port=" + configPort, "--spring.config.name=server");
@@ -66,7 +63,7 @@ public class ConfigDataOrderingIntegrationTests {
System.setProperty("spring.cloud.config.uri", "http://localhost:" + configPort);
}
- @AfterClass
+ @AfterAll
public static void close() {
System.clearProperty("spring.cloud.config.uri");
if (server != null) {
diff --git a/spring-cloud-config-sample/src/test/java/sample/ConfigDataRetryIntegrationTests.java b/spring-cloud-config-sample/src/test/java/sample/ConfigDataRetryIntegrationTests.java
index 5685251d..a34706c0 100644
--- a/spring-cloud-config-sample/src/test/java/sample/ConfigDataRetryIntegrationTests.java
+++ b/spring-cloud-config-sample/src/test/java/sample/ConfigDataRetryIntegrationTests.java
@@ -22,10 +22,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
-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.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
@@ -37,7 +36,6 @@ import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.TestSocketUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
@@ -46,7 +44,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,
// Normally spring.cloud.config.enabled:true is the default but since we have the
// config server on the classpath we need to set it explicitly
@@ -66,7 +63,7 @@ public class ConfigDataRetryIntegrationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void startConfigServer() throws IOException {
String baseDir = ConfigServerTestUtils.getBaseDirectory("spring-cloud-config-sample");
String repo = ConfigServerTestUtils.prepareLocalRepo(baseDir, "target/repos", "config-repo", "target/config");
@@ -76,7 +73,7 @@ public class ConfigDataRetryIntegrationTests {
System.setProperty("spring.cloud.config.uri", "http://localhost:" + configPort);
}
- @AfterClass
+ @AfterAll
public static void close() {
System.clearProperty("spring.cloud.config.uri");
if (server != null) {
diff --git a/spring-cloud-config-sample/src/test/java/sample/ServerNativeApplicationTests.java b/spring-cloud-config-sample/src/test/java/sample/ServerNativeApplicationTests.java
index daab047a..27520398 100644
--- a/spring-cloud-config-sample/src/test/java/sample/ServerNativeApplicationTests.java
+++ b/spring-cloud-config-sample/src/test/java/sample/ServerNativeApplicationTests.java
@@ -18,10 +18,9 @@ package sample;
import java.io.IOException;
-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.SpringApplication;
@@ -30,12 +29,10 @@ import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.config.server.test.ConfigServerTestUtils;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
-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;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, properties = "spring.application.name:bad", webEnvironment = RANDOM_PORT)
public class ServerNativeApplicationTests {
@@ -49,7 +46,7 @@ public class ServerNativeApplicationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void startConfigServer() throws IOException {
String repo = ConfigServerTestUtils.prepareLocalRepo();
server = SpringApplication.run(org.springframework.cloud.config.server.test.TestConfigServerApplication.class,
@@ -62,7 +59,7 @@ public class ServerNativeApplicationTests {
System.setProperty("config.port", "" + configPort);
}
- @AfterClass
+ @AfterAll
public static void close() {
System.clearProperty("config.port");
if (server != null) {
diff --git a/spring-cloud-config-server/pom.xml b/spring-cloud-config-server/pom.xml
index ceb1dd62..2d650ff9 100644
--- a/spring-cloud-config-server/pom.xml
+++ b/spring-cloud-config-server/pom.xml
@@ -162,8 +162,8 @@
test
- org.junit.vintage
- junit-vintage-engine
+ org.junit.platform
+ junit-platform-launcher
test
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/AdhocTestSuite.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/AdhocTestSuite.java
index 1de908f7..146b0394 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/AdhocTestSuite.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/AdhocTestSuite.java
@@ -16,7 +16,7 @@
package org.springframework.cloud.config.server;
-import org.junit.Ignore;
+import org.junit.jupiter.api.Disabled;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@@ -85,7 +85,7 @@ import org.springframework.cloud.config.server.ssh.SshUriPropertyProcessorTest;
ConfigServerHealthIndicatorTests.class, CustomCompositeEnvironmentRepositoryTests.class,
CustomEnvironmentRepositoryTests.class, BootstrapConfigServerIntegrationTests.class,
AwsS3EnvironmentRepositoryTests.class, AwsParameterStoreEnvironmentRepositoryTests.class })
-@Ignore
+@Disabled
public class AdhocTestSuite {
}
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/BootstrapConfigServerIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/BootstrapConfigServerIntegrationTests.java
index be2fba0a..4a2d90cd 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/BootstrapConfigServerIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/BootstrapConfigServerIntegrationTests.java
@@ -20,10 +20,9 @@ import java.io.IOException;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.SystemReader;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -36,13 +35,11 @@ import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.assertOriginTrackedValue;
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.getV2AcceptEntity;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfigServerApplication.class, properties = { "spring.cloud.bootstrap.enabled=true",
"logging.level.org.springframework.boot.context.config=TRACE", "spring.cloud.bootstrap.name:enable-bootstrap",
"encrypt.rsa.algorithm=DEFAULT", "encrypt.rsa.strong=false" },
@@ -56,7 +53,7 @@ public class BootstrapConfigServerIntegrationTests {
@Autowired
ConfigurableEnvironment env;
- @BeforeClass
+ @BeforeAll
public static void init() throws IOException {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
@@ -76,7 +73,7 @@ public class BootstrapConfigServerIntegrationTests {
}
@Test
- @Ignore // FIXME: configdata
+ @Disabled // FIXME: configdata
public void environmentBootstraps() {
assertThat(this.env.getProperty("info.foo", "")).isEqualTo("bar");
assertThat(this.env.getProperty("config.foo", "")).isEqualTo("foo");
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CompositeClasspathTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CompositeClasspathTests.java
index b30b7ba0..fc248f34 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CompositeClasspathTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CompositeClasspathTests.java
@@ -16,20 +16,17 @@
package org.springframework.cloud.config.server;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.cloud.config.server.composite.CompositeUtils;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.cloud.test.ClassPathExclusions;
-import org.springframework.cloud.test.ModifiedClassPathRunner;
import static org.assertj.core.api.Assertions.assertThat;
public class CompositeClasspathTests {
- @RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions({ "spring-jdbc-*.jar", "spring-data-redis-*.jar" })
public static class JdbcTests {
@@ -49,7 +46,6 @@ public class CompositeClasspathTests {
}
- @RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions({ "spring-jdbc-*.jar", "spring-data-redis-*.jar", "spring-boot-actuator-*.jar" })
public static class NoActuatorTests {
@@ -68,7 +64,6 @@ public class CompositeClasspathTests {
}
- @RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions("httpclient-*.jar")
public static class HttpClientTests {
@@ -88,7 +83,6 @@ public class CompositeClasspathTests {
}
- @RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions("svnkit-*.jar")
public static class SvnTests {
@@ -108,7 +102,6 @@ public class CompositeClasspathTests {
}
- @RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions("org.eclipse.jgit-*.jar")
public static class JGitTests {
@@ -128,7 +121,6 @@ public class CompositeClasspathTests {
}
- @RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions("google-auth-library-oauth2-http-*.jar")
public static class GoogleAuthTests {
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CompositeIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CompositeIntegrationTests.java
index 04d09cb2..d544454f 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CompositeIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CompositeIntegrationTests.java
@@ -18,9 +18,8 @@ package org.springframework.cloud.config.server;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.SystemReader;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -31,7 +30,6 @@ import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
-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;
@@ -43,7 +41,6 @@ import static org.springframework.cloud.config.server.test.ConfigServerTestUtils
*/
public class CompositeIntegrationTests {
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfigServerApplication.class,
properties = { "spring.config.name:compositeconfigserver",
"spring.cloud.config.server.svn.uri:file:///./target/repos/svn-config-repo",
@@ -57,7 +54,7 @@ public class CompositeIntegrationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
@@ -94,7 +91,6 @@ public class CompositeIntegrationTests {
}
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfigServerApplication.class,
properties = { "spring.config.name:compositeconfigserver",
"spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",
@@ -108,7 +104,7 @@ public class CompositeIntegrationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientBackwardsCompatibilityIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientBackwardsCompatibilityIntegrationTests.java
index 3b1a19a8..5fc6efcf 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientBackwardsCompatibilityIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientBackwardsCompatibilityIntegrationTests.java
@@ -22,9 +22,8 @@ import java.util.Map;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.SystemReader;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -36,13 +35,11 @@ import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
-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;
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.getV2AcceptEntity;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfigServerApplication.class, properties = { "spring.config.name:configserver" },
webEnvironment = RANDOM_PORT)
@ActiveProfiles({ "test", "native" })
@@ -54,7 +51,7 @@ public class ConfigClientBackwardsCompatibilityIntegrationTests {
@Autowired
private ApplicationContext context;
- @BeforeClass
+ @BeforeAll
public static void init() throws IOException {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientOffIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientOffIntegrationTests.java
index c520cf51..d70d1312 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientOffIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientOffIntegrationTests.java
@@ -20,9 +20,8 @@ import java.io.IOException;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.SystemReader;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.BeanFactoryUtils;
@@ -43,7 +42,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -51,7 +49,6 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfiguration.class, webEnvironment = RANDOM_PORT)
@ActiveProfiles("test")
public class ConfigClientOffIntegrationTests {
@@ -62,7 +59,7 @@ public class ConfigClientOffIntegrationTests {
@Autowired
private ApplicationContext context;
- @BeforeClass
+ @BeforeAll
public static void init() throws IOException {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientOnIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientOnIntegrationTests.java
index 0f614f67..f62b6e8a 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientOnIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigClientOnIntegrationTests.java
@@ -20,10 +20,9 @@ import java.io.IOException;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.SystemReader;
-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.mockito.Mockito;
import org.springframework.beans.factory.BeanFactoryUtils;
@@ -45,14 +44,12 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ByteArrayResource;
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.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfiguration.class,
properties = { "spring.config.use-legacy-processing=true", "spring.cloud.config.enabled:true" },
webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -68,7 +65,7 @@ public class ConfigClientOnIntegrationTests {
@Autowired
private ApplicationContext context;
- @BeforeClass
+ @BeforeAll
public static void init() throws IOException {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
@@ -76,7 +73,7 @@ public class ConfigClientOnIntegrationTests {
localRepo = ConfigServerTestUtils.prepareLocalRepo();
}
- @AfterClass
+ @AfterAll
public static void after() throws IOException {
ConfigServerTestUtils.deleteLocalRepo(localRepo);
}
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigServerApplicationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigServerApplicationTests.java
index 4e0374a1..f9e01cb6 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigServerApplicationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ConfigServerApplicationTests.java
@@ -17,15 +17,12 @@
package org.springframework.cloud.config.server;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.test.ClassPathExclusions;
-import org.springframework.cloud.test.ModifiedClassPathRunner;
import org.springframework.context.ConfigurableApplicationContext;
-@RunWith(ModifiedClassPathRunner.class)
@ClassPathExclusions("h2-*.jar")
public class ConfigServerApplicationTests {
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubCompositeConfigServerIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubCompositeConfigServerIntegrationTests.java
index 18b8e7e1..e2a9f1c7 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubCompositeConfigServerIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubCompositeConfigServerIntegrationTests.java
@@ -16,15 +16,13 @@
package org.springframework.cloud.config.server;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
-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;
@@ -32,7 +30,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
/**
* @author Alberto C. RÃos
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfigServerApplication.class,
properties = { "spring.profiles.active:composite", "spring.cloud.config.server.composite[0].type:credhub",
"spring.cloud.config.server.composite[0].url:https://credhub:8844" },
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubConfigServerIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubConfigServerIntegrationTests.java
index 392b62c3..bc1ae1f0 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubConfigServerIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubConfigServerIntegrationTests.java
@@ -16,15 +16,13 @@
package org.springframework.cloud.config.server;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
-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;
@@ -32,7 +30,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
/**
* @author Alberto C. RÃos
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfigServerApplication.class, properties = { "spring.profiles.active:credhub",
"spring.cloud.config.server.credhub.url:https://credhub:8844" }, webEnvironment = RANDOM_PORT)
public class CredhubConfigServerIntegrationTests extends CredhubIntegrationTest {
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubIntegrationTest.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubIntegrationTest.java
index 3829cfb4..895bd526 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubIntegrationTest.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/CredhubIntegrationTest.java
@@ -16,7 +16,7 @@
package org.springframework.cloud.config.server;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mockito;
import org.springframework.boot.test.mock.mockito.MockBean;
@@ -39,7 +39,7 @@ public class CredhubIntegrationTest {
@MockBean
private CredHubOperations credHubOperations;
- @Before
+ @BeforeEach
public void setUp() {
CredHubCredentialOperations credhubCredentialOperations = Mockito.mock(CredHubCredentialOperations.class);
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/NativeConfigServerIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/NativeConfigServerIntegrationTests.java
index 5c45cb7f..a58b4250 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/NativeConfigServerIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/NativeConfigServerIntegrationTests.java
@@ -20,9 +20,8 @@ import java.io.IOException;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.SystemReader;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -34,14 +33,12 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
-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;
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.getV2AcceptEntity;
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.prepareLocalRepo;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfigServerApplication.class, properties = { "spring.config.name:configserver" },
webEnvironment = RANDOM_PORT)
@ActiveProfiles({ "test", "native" })
@@ -50,7 +47,7 @@ public class NativeConfigServerIntegrationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void init() throws IOException {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/RefreshableConfigServerIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/RefreshableConfigServerIntegrationTests.java
index 7b1f8586..b5ca28ba 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/RefreshableConfigServerIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/RefreshableConfigServerIntegrationTests.java
@@ -20,10 +20,9 @@ import java.io.IOException;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.SystemReader;
-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.mockito.Mockito;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -46,7 +45,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
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.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.isA;
@@ -55,7 +53,6 @@ import static org.mockito.BDDMockito.given;
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.assertOriginTrackedValue;
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.getV2AcceptEntity;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfiguration.class,
properties = { "spring.cloud.config.enabled=true", "spring.cloud.bootstrap.enabled=true",
"management.endpoint.env.post.enabled=true", "management.endpoints.web.exposure.include=env, refresh" },
@@ -69,7 +66,7 @@ public class RefreshableConfigServerIntegrationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void init() throws IOException {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
@@ -77,7 +74,7 @@ public class RefreshableConfigServerIntegrationTests {
localRepo = ConfigServerTestUtils.prepareLocalRepo();
}
- @AfterClass
+ @AfterAll
public static void after() throws IOException {
ConfigServerTestUtils.deleteLocalRepo(localRepo);
}
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/SubversionConfigServerIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/SubversionConfigServerIntegrationTests.java
index b07b29f0..be51290c 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/SubversionConfigServerIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/SubversionConfigServerIntegrationTests.java
@@ -19,9 +19,8 @@ package org.springframework.cloud.config.server;
import java.io.File;
import java.io.IOException;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -35,7 +34,6 @@ import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
-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;
@@ -47,7 +45,6 @@ import static org.springframework.cloud.config.server.test.ConfigServerTestUtils
* @author Dave Syer
* @author Roy Clarkson
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfigServerApplication.class,
properties = { "spring.config.name:configserver",
"spring.cloud.config.server.svn.uri:file:///./target/repos/svn-config-repo",
@@ -62,7 +59,7 @@ public class SubversionConfigServerIntegrationTests {
@Autowired
private ApplicationContext context;
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
ConfigServerTestUtils.prepareLocalSvnRepo("src/test/resources/svn-config-repo", "target/repos/svn-config-repo");
}
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/TransportConfigurationIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/TransportConfigurationIntegrationTests.java
index 40fcf444..d7666876 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/TransportConfigurationIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/TransportConfigurationIntegrationTests.java
@@ -27,8 +27,7 @@ import org.eclipse.jgit.transport.SshConfigStore;
import org.eclipse.jgit.transport.SshTransport;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.sshd.SshdSessionFactory;
-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;
@@ -41,7 +40,6 @@ import org.springframework.cloud.config.server.ssh.PropertyBasedSshSessionFactor
import org.springframework.cloud.config.server.ssh.SshPropertyValidator;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -54,7 +52,6 @@ public class TransportConfigurationIntegrationTests {
public static class PropertyBasedCallbackTest {
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
@@ -84,7 +81,6 @@ public class TransportConfigurationIntegrationTests {
}
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
@@ -118,7 +114,6 @@ public class TransportConfigurationIntegrationTests {
public static class PrivateKeyPropertyWithLineBreaks {
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
@@ -141,7 +136,6 @@ public class TransportConfigurationIntegrationTests {
}
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
@@ -168,7 +162,6 @@ public class TransportConfigurationIntegrationTests {
public static class SshPropertiesWithinNestedRepo {
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
@@ -196,7 +189,6 @@ public class TransportConfigurationIntegrationTests {
}
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.config.additional-location=optional:file:/ssh/,optional:classpath:/ssh/",
@@ -228,7 +220,6 @@ public class TransportConfigurationIntegrationTests {
public static class FileBasedCallbackTest {
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.cloud.config.server.git.uri=git@gitserver.com:team/repo.git",
@@ -282,7 +273,6 @@ public class TransportConfigurationIntegrationTests {
}
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = { TestConfigServerApplication.class, SshPropertyValidator.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = { "spring.cloud.config.server.composite[0].type=git",
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/VanillaConfigServerIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/VanillaConfigServerIntegrationTests.java
index e0614b54..f5d98ec0 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/VanillaConfigServerIntegrationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/VanillaConfigServerIntegrationTests.java
@@ -21,9 +21,8 @@ import java.util.Arrays;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.SystemReader;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -37,13 +36,11 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
-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;
import static org.springframework.cloud.config.server.test.ConfigServerTestUtils.getV2AcceptEntity;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfigServerApplication.class,
properties = { "spring.config.name:configserver",
"spring.cloud.config.server.git.uri:file:./target/repos/config-repo" },
@@ -54,7 +51,7 @@ public class VanillaConfigServerIntegrationTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void init() throws IOException {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/composite/CompositUtilsTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/composite/CompositUtilsTests.java
index 3228239d..ad56246b 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/composite/CompositUtilsTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/composite/CompositUtilsTests.java
@@ -18,20 +18,19 @@ package org.springframework.cloud.config.server.composite;
import java.util.List;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
+import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
import static org.assertj.core.api.Assertions.assertThat;
+@ExtendWith(OutputCaptureExtension.class)
public class CompositUtilsTests {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void getCompositeTypeListWorks() {
new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
@@ -49,18 +48,18 @@ public class CompositUtilsTests {
@Test
public void getCompositeTypeListFails() {
- this.thrown.expect(IllegalStateException.class);
-
- new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
- .withPropertyValues("spring.profiles.active:test,composite", "spring.config.name:compositeconfigserver",
- "spring.jmx.enabled=false",
- "spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",
- "spring.cloud.config.server.composite[0].type:git",
- "spring.cloud.config.server.composite[2].uri:file:///./target/repos/svn-config-repo",
- "spring.cloud.config.server.composite[2].type:svn")
- .run(context -> {
- CompositeUtils.getCompositeTypeList(context.getEnvironment());
- });
+ Assertions.assertThatThrownBy(() -> {
+ new WebApplicationContextRunner().withUserConfiguration(TestConfigServerApplication.class)
+ .withPropertyValues("spring.profiles.active:test,composite",
+ "spring.config.name:compositeconfigserver", "spring.jmx.enabled=false",
+ "spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo",
+ "spring.cloud.config.server.composite[0].type:git",
+ "spring.cloud.config.server.composite[2].uri:file:///./target/repos/svn-config-repo",
+ "spring.cloud.config.server.composite[2].type:svn")
+ .run(context -> {
+ CompositeUtils.getCompositeTypeList(context.getEnvironment());
+ });
+ }).isInstanceOf(IllegalStateException.class);
}
}
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/ConfigServerHealthIndicatorTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/ConfigServerHealthIndicatorTests.java
index 58367441..43ec7114 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/ConfigServerHealthIndicatorTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/ConfigServerHealthIndicatorTests.java
@@ -18,8 +18,8 @@ package org.springframework.cloud.config.server.config;
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.Answers;
import org.mockito.Mock;
import org.mockito.Mockito;
@@ -49,7 +49,7 @@ public class ConfigServerHealthIndicatorTests {
private ConfigServerHealthIndicator indicator;
- @Before
+ @BeforeEach
public void init() {
initMocks(this);
this.indicator = new ConfigServerHealthIndicator(this.repository);
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/CustomCompositeEnvironmentRepositoryTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/CustomCompositeEnvironmentRepositoryTests.java
index 47f8a2fc..55403653 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/CustomCompositeEnvironmentRepositoryTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/CustomCompositeEnvironmentRepositoryTests.java
@@ -21,9 +21,8 @@ import java.util.List;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.SystemReader;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -43,7 +42,6 @@ import org.springframework.core.Ordered;
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.Assertions.assertThat;
@@ -52,7 +50,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class CustomCompositeEnvironmentRepositoryTests {
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = CustomCompositeEnvironmentRepositoryTests.StaticTests.Config.class,
properties = { "spring.config.name:compositeconfigserver",
"spring.cloud.config.server.git.uri:file:./target/repos/config-repo",
@@ -65,7 +62,7 @@ public class CustomCompositeEnvironmentRepositoryTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
@@ -102,7 +99,6 @@ public class CustomCompositeEnvironmentRepositoryTests {
}
- @RunWith(SpringRunner.class)
@SpringBootTest(classes = CustomCompositeEnvironmentRepositoryTests.ListTests.Config.class,
properties = { "spring.config.name:compositeconfigserver",
"spring.cloud.config.server.composite[0].type:git",
@@ -117,7 +113,7 @@ public class CustomCompositeEnvironmentRepositoryTests {
@LocalServerPort
private int port;
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
// mock Git configuration to make tests independent of local Git configuration
SystemReader.setInstance(new MockSystemReader());
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/CustomEnvironmentRepositoryTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/CustomEnvironmentRepositoryTests.java
index a61956e6..15c57a04 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/CustomEnvironmentRepositoryTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/CustomEnvironmentRepositoryTests.java
@@ -16,8 +16,7 @@
package org.springframework.cloud.config.server.config;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -33,7 +32,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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.Assertions.assertThat;
@@ -41,7 +39,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
*
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestApplication.class, properties = { "spring.config.name:configserver" },
webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfigurationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfigurationTests.java
index d5ec6763..7d451d95 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfigurationTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfigurationTests.java
@@ -16,7 +16,7 @@
package org.springframework.cloud.config.server.config;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/HttpClientVaultRestTemplateFactoryTest.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/HttpClientVaultRestTemplateFactoryTest.java
index fd2308a2..21fb3990 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/HttpClientVaultRestTemplateFactoryTest.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/HttpClientVaultRestTemplateFactoryTest.java
@@ -20,21 +20,15 @@ import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.cloud.config.server.environment.HttpClientVaultRestTemplateFactory;
import org.springframework.cloud.config.server.environment.VaultEnvironmentProperties;
import org.springframework.cloud.config.server.proxy.ProxyHostProperties;
import org.springframework.web.client.RestTemplate;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.instanceOf;
-
/**
* @author Dylan Roberts
*/
@@ -72,74 +66,65 @@ public class HttpClientVaultRestTemplateFactoryTest {
HTTPS_PROXY.setPort(8081);
}
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
private HttpClientVaultRestTemplateFactory factory;
- @Before
+ @BeforeEach
public void setUp() {
this.factory = new HttpClientVaultRestTemplateFactory();
}
@Test
public void authenticatedHttpsProxy() throws Exception {
- VaultEnvironmentProperties properties = getVaultEnvironmentProperties(null, AUTHENTICATED_HTTPS_PROXY);
- RestTemplate restTemplate = this.factory.build(properties);
- this.expectedException.expectCause(allOf(instanceOf(UnknownHostException.class),
- hasProperty("message", containsString(AUTHENTICATED_HTTPS_PROXY.getHost()))));
-
- restTemplate.getForObject("https://somehost", String.class);
+ Assertions.assertThatThrownBy(() -> {
+ VaultEnvironmentProperties properties = getVaultEnvironmentProperties(null, AUTHENTICATED_HTTPS_PROXY);
+ RestTemplate restTemplate = this.factory.build(properties);
+ restTemplate.getForObject("https://somehost", String.class);
+ }).hasCauseInstanceOf(UnknownHostException.class).hasMessageContaining(AUTHENTICATED_HTTPS_PROXY.getHost());
}
@Test
public void httpsProxy() throws Exception {
- VaultEnvironmentProperties properties = getVaultEnvironmentProperties(null, HTTPS_PROXY);
- RestTemplate restTemplate = this.factory.build(properties);
- this.expectedException.expectCause(allOf(instanceOf(UnknownHostException.class),
- hasProperty("message", containsString(HTTPS_PROXY.getHost()))));
-
- restTemplate.getForObject("https://somehost", String.class);
+ Assertions.assertThatThrownBy(() -> {
+ VaultEnvironmentProperties properties = getVaultEnvironmentProperties(null, HTTPS_PROXY);
+ RestTemplate restTemplate = this.factory.build(properties);
+ restTemplate.getForObject("https://somehost", String.class);
+ }).hasCauseInstanceOf(UnknownHostException.class).hasMessageContaining(HTTPS_PROXY.getHost());
}
@Test
public void httpsProxy_called_for_http_request_when_no_httpProxy_specified() throws Exception {
- VaultEnvironmentProperties properties = getVaultEnvironmentProperties(null, HTTPS_PROXY);
- RestTemplate restTemplate = this.factory.build(properties);
- this.expectedException.expectCause(allOf(instanceOf(UnknownHostException.class),
- hasProperty("message", containsString(HTTPS_PROXY.getHost()))));
-
- restTemplate.getForObject("http://somehost", String.class);
+ Assertions.assertThatThrownBy(() -> {
+ VaultEnvironmentProperties properties = getVaultEnvironmentProperties(null, HTTPS_PROXY);
+ RestTemplate restTemplate = this.factory.build(properties);
+ restTemplate.getForObject("http://somehost", String.class);
+ }).hasCauseInstanceOf(UnknownHostException.class).hasMessageContaining(HTTPS_PROXY.getHost());
}
@Test
public void authenticatedHttpProxy() throws Exception {
- VaultEnvironmentProperties properties = getVaultEnvironmentProperties(AUTHENTICATED_HTTP_PROXY, null);
- RestTemplate restTemplate = this.factory.build(properties);
- this.expectedException.expectCause(allOf(instanceOf(UnknownHostException.class),
- hasProperty("message", containsString(AUTHENTICATED_HTTP_PROXY.getHost()))));
-
- restTemplate.getForObject("http://somehost", String.class);
+ Assertions.assertThatThrownBy(() -> {
+ VaultEnvironmentProperties properties = getVaultEnvironmentProperties(AUTHENTICATED_HTTP_PROXY, null);
+ RestTemplate restTemplate = this.factory.build(properties);
+ restTemplate.getForObject("http://somehost", String.class);
+ }).hasCauseInstanceOf(UnknownHostException.class).hasMessageContaining(AUTHENTICATED_HTTP_PROXY.getHost());
}
@Test
public void httpProxy() throws Exception {
- VaultEnvironmentProperties properties = getVaultEnvironmentProperties(HTTP_PROXY, null);
- RestTemplate restTemplate = this.factory.build(properties);
- this.expectedException.expectCause(allOf(instanceOf(UnknownHostException.class),
- hasProperty("message", containsString(HTTP_PROXY.getHost()))));
-
- restTemplate.getForObject("http://somehost", String.class);
+ Assertions.assertThatThrownBy(() -> {
+ VaultEnvironmentProperties properties = getVaultEnvironmentProperties(HTTP_PROXY, null);
+ RestTemplate restTemplate = this.factory.build(properties);
+ restTemplate.getForObject("http://somehost", String.class);
+ }).hasCauseInstanceOf(UnknownHostException.class).hasMessageContaining(HTTP_PROXY.getHost());
}
@Test
public void httpProxy_called_for_https_request_when_no_httpsProxy_specified() throws Exception {
- VaultEnvironmentProperties properties = getVaultEnvironmentProperties(HTTP_PROXY, null);
- RestTemplate restTemplate = this.factory.build(properties);
- this.expectedException.expectCause(allOf(instanceOf(UnknownHostException.class),
- hasProperty("message", containsString(HTTP_PROXY.getHost()))));
-
- restTemplate.getForObject("https://somehost", String.class);
+ Assertions.assertThatThrownBy(() -> {
+ VaultEnvironmentProperties properties = getVaultEnvironmentProperties(HTTP_PROXY, null);
+ RestTemplate restTemplate = this.factory.build(properties);
+ restTemplate.getForObject("https://somehost", String.class);
+ }).hasCauseInstanceOf(UnknownHostException.class).hasMessageContaining(HTTP_PROXY.getHost());
}
private VaultEnvironmentProperties getVaultEnvironmentProperties(ProxyHostProperties httpProxy,
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/credentials/AwsCodeCommitCredentialsProviderTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/credentials/AwsCodeCommitCredentialsProviderTests.java
index 3839f1c7..c6f90d9b 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/credentials/AwsCodeCommitCredentialsProviderTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/credentials/AwsCodeCommitCredentialsProviderTests.java
@@ -21,8 +21,8 @@ import java.net.URISyntaxException;
import org.eclipse.jgit.errors.UnsupportedCredentialItem;
import org.eclipse.jgit.transport.CredentialItem;
import org.eclipse.jgit.transport.URIish;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import org.springframework.cloud.config.server.support.AwsCodeCommitCredentialProvider;
@@ -53,7 +53,7 @@ public class AwsCodeCommitCredentialsProviderTests {
private AwsCodeCommitCredentialProvider provider;
- @Before
+ @BeforeEach
public void init() {
GitCredentialsProviderFactory factory = new GitCredentialsProviderFactory();
this.provider = (AwsCodeCommitCredentialProvider) factory.createFor(AWS_REPO, USER, PASSWORD, null, false);
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/credentials/GitCredentialsProviderFactoryTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/credentials/GitCredentialsProviderFactoryTests.java
index ac33d576..a7a72e5d 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/credentials/GitCredentialsProviderFactoryTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/credentials/GitCredentialsProviderFactoryTests.java
@@ -18,8 +18,8 @@ package org.springframework.cloud.config.server.credentials;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.cloud.config.server.support.AwsCodeCommitCredentialProvider;
import org.springframework.cloud.config.server.support.GitCredentialsProviderFactory;
@@ -48,7 +48,7 @@ public class GitCredentialsProviderFactoryTests {
private GitCredentialsProviderFactory factory;
- @Before
+ @BeforeEach
public void init() {
this.factory = new GitCredentialsProviderFactory();
}
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/encryption/CipherEnvironmentEncryptorTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/encryption/CipherEnvironmentEncryptorTests.java
index ee5c6338..67886ad7 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/encryption/CipherEnvironmentEncryptorTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/encryption/CipherEnvironmentEncryptorTests.java
@@ -20,9 +20,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runners.Parameterized.Parameters;
import org.springframework.cloud.config.environment.Environment;
@@ -34,18 +33,13 @@ import org.springframework.security.crypto.encrypt.TextEncryptor;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(Parameterized.class)
+/**
+ * Converted all the tests to parameterized tests.
+ *
+ * @author Siva Krishna Battu
+ */
public class CipherEnvironmentEncryptorTests {
- TextEncryptor textEncryptor = new EncryptorFactory().create("foo");
-
- EnvironmentEncryptor encryptor;
-
- public CipherEnvironmentEncryptorTests(String salt, String key) {
- this.textEncryptor = new EncryptorFactory(salt).create(key);
- this.encryptor = new CipherEnvironmentEncryptor(keys -> CipherEnvironmentEncryptorTests.this.textEncryptor);
- }
-
@Parameters
public static List