diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/HttpClientSupportTest.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/HttpClientSupportTest.java index 138508e0..b22fff21 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/HttpClientSupportTest.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/HttpClientSupportTest.java @@ -27,10 +27,10 @@ import com.github.tomakehurst.wiremock.client.WireMock; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnJre; +import org.junit.jupiter.api.condition.JRE; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -38,7 +38,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.cloud.config.server.environment.JGitEnvironmentProperties; import org.springframework.cloud.config.server.proxy.ProxyHostProperties; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.config.annotation.EnableWebMvc; @@ -50,18 +49,11 @@ import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import static org.hamcrest.Matchers.anyOf; -import static org.hamcrest.Matchers.isA; -import static org.junit.internal.matchers.ThrowableCauseMatcher.hasCause; -@RunWith(SpringRunner.class) @SpringBootTest(classes = HttpClientSupportTest.TestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class HttpClientSupportTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @LocalServerPort private String localServerPort; @@ -71,13 +63,13 @@ public class HttpClientSupportTest { properties.setTimeout(1); CloseableHttpClient httpClient = HttpClientSupport.builder(properties).build(); - this.expectedException - .expect(anyOf(isA(SocketTimeoutException.class), hasCause(isA(SocketTimeoutException.class)))); - - httpClient.execute(new HttpGet(String.format("http://127.0.0.1:%s/test/endpoint", this.localServerPort))); + Assertions.assertThatThrownBy(() -> { + httpClient.execute(new HttpGet(String.format("http://127.0.0.1:%s/test/endpoint", this.localServerPort))); + }).isInstanceOf(SocketTimeoutException.class); } @Test + @EnabledOnJre(JRE.JAVA_8) public void httpsProxy() throws GeneralSecurityException, IOException { WireMockServer wireMockProxyServer = new WireMockServer( options().httpDisabled(true).dynamicHttpsPort().enableBrowserProxying(true).trustAllProxyTargets(true));