Skip to content

Commit 45bcb33

Browse files
Upgrade surefire-junit47 to surefire-junit-platform and partially revert "Migrate most tests to JUnit 5 (#2931)" (#2970)
Upgrade surefire-junit47 to surefire-junit-platform and partially revert "Migrate most tests to JUnit 5 (#2931)" This partially reverts commit abe96fd (#2931). Only tests that use org.junit.Rule are reverted as they are not compatible with JUnit 5. This also upgrades surefire-junit47 to surefire-junit-platform to be compatible with the junit-jupiter test platform.
1 parent 6282ed7 commit 45bcb33

File tree

140 files changed

+445
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+445
-443
lines changed

codegen/src/test/java/software/amazon/awssdk/codegen/customization/processors/UseLegacyEventGenerationSchemeProcessorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818

1919
import java.io.File;
20+
import org.junit.BeforeClass;
2021
import org.junit.Rule;
21-
import org.junit.jupiter.api.BeforeAll;
22-
import org.junit.jupiter.api.Test;
22+
import org.junit.Test;
2323
import org.junit.rules.ExpectedException;
2424
import software.amazon.awssdk.codegen.C2jModels;
2525
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
@@ -42,7 +42,7 @@ public class UseLegacyEventGenerationSchemeProcessorTest {
4242
private static ServiceModel serviceModel;
4343

4444

45-
@BeforeAll
45+
@BeforeClass
4646
public static void setup() {
4747
String c2jFilePath = UseLegacyEventGenerationSchemeProcessorTest.class.getResource(RESOURCE_ROOT + "/service-2.json").getFile();
4848
File c2jFile = new File(c2jFilePath);

core/auth/src/test/java/software/amazon/awssdk/auth/credentials/AwsCredentialsProviderChainTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
package software.amazon.awssdk.auth.credentials;
1717

18-
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.Assert.assertEquals;
1919

2020
import org.junit.Rule;
21-
import org.junit.jupiter.api.Test;
21+
import org.junit.Test;
2222
import org.junit.rules.ExpectedException;
2323
import software.amazon.awssdk.core.exception.SdkClientException;
2424
import software.amazon.awssdk.profiles.ProfileFile;

core/auth/src/test/java/software/amazon/awssdk/auth/credentials/HttpCredentialsProviderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
import java.time.Duration;
3232
import java.time.Instant;
3333
import java.util.Date;
34+
import org.junit.BeforeClass;
3435
import org.junit.ClassRule;
35-
import org.junit.jupiter.api.BeforeAll;
36-
import org.junit.jupiter.api.Test;
36+
import org.junit.Test;
3737
import software.amazon.awssdk.core.exception.SdkClientException;
3838
import software.amazon.awssdk.core.util.SdkUserAgent;
3939
import software.amazon.awssdk.regions.util.ResourcesEndpointProvider;
@@ -51,7 +51,7 @@ public class HttpCredentialsProviderTest {
5151

5252
private static String successResponseWithInvalidBody;
5353

54-
@BeforeAll
54+
@BeforeClass
5555
public static void setup() throws IOException {
5656
try (InputStream successInputStream = HttpCredentialsProviderTest.class.getResourceAsStream
5757
("/resources/wiremock/successResponse.json");

core/auth/src/test/java/software/amazon/awssdk/auth/credentials/InstanceProfileCredentialsProviderTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder;
3232
import java.time.Duration;
3333
import java.time.Instant;
34+
import org.junit.AfterClass;
35+
import org.junit.Before;
3436
import org.junit.Rule;
35-
import org.junit.jupiter.api.AfterAll;
36-
import org.junit.jupiter.api.BeforeEach;
37-
import org.junit.jupiter.api.Test;
37+
import org.junit.Test;
3838
import org.junit.rules.ExpectedException;
3939
import software.amazon.awssdk.core.SdkSystemSetting;
4040
import software.amazon.awssdk.core.exception.SdkClientException;
@@ -57,12 +57,12 @@ public class InstanceProfileCredentialsProviderTest {
5757
@Rule
5858
public WireMockRule mockMetadataEndpoint = new WireMockRule();
5959

60-
@BeforeEach
60+
@Before
6161
public void methodSetup() {
6262
System.setProperty(SdkSystemSetting.AWS_EC2_METADATA_SERVICE_ENDPOINT.property(), "http://localhost:" + mockMetadataEndpoint.port());
6363
}
6464

65-
@AfterAll
65+
@AfterClass
6666
public static void teardown() {
6767
System.clearProperty(SdkSystemSetting.AWS_EC2_METADATA_SERVICE_ENDPOINT.property());
6868
}

core/metrics-spi/src/test/java/software/amazon/awssdk/metrics/internal/DefaultMetricCollectorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
import static org.assertj.core.api.Assertions.assertThat;
1919

2020
import java.util.stream.Stream;
21+
import org.junit.AfterClass;
2122
import org.junit.Rule;
22-
import org.junit.jupiter.api.AfterAll;
23-
import org.junit.jupiter.api.Test;
23+
import org.junit.Test;
2424
import org.junit.rules.ExpectedException;
2525
import software.amazon.awssdk.metrics.MetricCategory;
2626
import software.amazon.awssdk.metrics.MetricCollection;
@@ -34,7 +34,7 @@ public class DefaultMetricCollectorTest {
3434
@Rule
3535
public ExpectedException thrown = ExpectedException.none();
3636

37-
@AfterAll
37+
@AfterClass
3838
public static void teardown() {
3939
DefaultSdkMetric.clearDeclaredMetrics();
4040
}

core/metrics-spi/src/test/java/software/amazon/awssdk/metrics/internal/DefaultSdkMetricTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import java.util.Set;
2121
import java.util.stream.Collectors;
2222
import java.util.stream.Stream;
23+
import org.junit.Before;
2324
import org.junit.Rule;
24-
import org.junit.jupiter.api.BeforeEach;
25-
import org.junit.jupiter.api.Test;
25+
import org.junit.Test;
2626
import org.junit.rules.ExpectedException;
2727
import software.amazon.awssdk.metrics.MetricCategory;
2828
import software.amazon.awssdk.metrics.MetricLevel;
@@ -32,7 +32,7 @@ public class DefaultSdkMetricTest {
3232
@Rule
3333
public ExpectedException thrown = ExpectedException.none();
3434

35-
@BeforeEach
35+
@Before
3636
public void methodSetup() {
3737
DefaultSdkMetric.clearDeclaredMetrics();
3838
}

core/regions/src/test/java/software/amazon/awssdk/regions/internal/util/ConnectionUtilsComponentTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import static java.util.Collections.emptyMap;
1919
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.junit.Assume.assumeTrue;
2021

2122
import com.github.tomakehurst.wiremock.client.WireMock;
2223
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
@@ -26,11 +27,10 @@
2627
import java.net.Inet4Address;
2728
import java.net.URI;
2829
import java.util.Collections;
30+
import org.junit.After;
2931
import org.junit.ClassRule;
3032
import org.junit.Rule;
31-
import org.junit.jupiter.api.AfterEach;
32-
import org.junit.jupiter.api.Assumptions;
33-
import org.junit.jupiter.api.Test;
33+
import org.junit.Test;
3434

3535
public class ConnectionUtilsComponentTest {
3636

@@ -42,15 +42,15 @@ public class ConnectionUtilsComponentTest {
4242

4343
private final ConnectionUtils sut = ConnectionUtils.create();
4444

45-
@AfterEach
45+
@After
4646
public void cleanup() {
4747
System.getProperties().remove("http.proxyHost");
4848
System.getProperties().remove("http.proxyPort");
4949
}
5050

5151
@Test
5252
public void proxiesAreNotUsedEvenIfPropertyIsSet() throws IOException {
53-
Assumptions.assumeTrue(Inet4Address.getLocalHost().isReachable(100));
53+
assumeTrue(Inet4Address.getLocalHost().isReachable(100));
5454
System.getProperties().put("http.proxyHost", "localhost");
5555
System.getProperties().put("http.proxyPort", String.valueOf(mockProxyServer.port()));
5656
HttpURLConnection connection = sut.connectToEndpoint(URI.create("http://" + Inet4Address.getLocalHost().getHostAddress() + ":" + mockServer.port()), emptyMap());

core/regions/src/test/java/software/amazon/awssdk/regions/internal/util/EC2MetadataUtilsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import com.github.tomakehurst.wiremock.client.WireMock;
2929
import com.github.tomakehurst.wiremock.http.Fault;
3030
import com.github.tomakehurst.wiremock.junit.WireMockRule;
31+
import org.junit.Before;
3132
import org.junit.Rule;
32-
import org.junit.jupiter.api.BeforeEach;
33-
import org.junit.jupiter.api.Test;
33+
import org.junit.Test;
3434
import org.junit.rules.ExpectedException;
3535
import software.amazon.awssdk.core.SdkSystemSetting;
3636
import software.amazon.awssdk.core.exception.SdkClientException;
@@ -51,7 +51,7 @@ public class EC2MetadataUtilsTest {
5151
@Rule
5252
public WireMockRule mockMetadataEndpoint = new WireMockRule();
5353

54-
@BeforeEach
54+
@Before
5555
public void methodSetup() {
5656
System.setProperty(SdkSystemSetting.AWS_EC2_METADATA_SERVICE_ENDPOINT.property(), "http://localhost:" + mockMetadataEndpoint.port());
5757
EC2MetadataUtils.clearCache();

core/regions/src/test/java/software/amazon/awssdk/regions/providers/AwsProfileRegionProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.net.URISyntaxException;
2222
import java.nio.file.Paths;
2323
import org.junit.Rule;
24-
import org.junit.jupiter.api.Test;
24+
import org.junit.Test;
2525
import software.amazon.awssdk.core.exception.SdkClientException;
2626
import software.amazon.awssdk.profiles.ProfileFileSystemSetting;
2727
import software.amazon.awssdk.regions.Region;

core/sdk-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
<dependencies>
204204
<dependency>
205205
<groupId>org.apache.maven.surefire</groupId>
206-
<artifactId>surefire-junit47</artifactId>
206+
<artifactId>surefire-junit-platform</artifactId>
207207
<version>${maven.surefire.version}</version>
208208
</dependency>
209209
<dependency>
@@ -259,7 +259,7 @@
259259
<dependencies>
260260
<dependency>
261261
<groupId>org.apache.maven.surefire</groupId>
262-
<artifactId>surefire-junit47</artifactId>
262+
<artifactId>surefire-junit-platform</artifactId>
263263
<version>${maven.surefire.version}</version>
264264
</dependency>
265265
</dependencies>

core/sdk-core/src/test/java/software/amazon/awssdk/core/http/AmazonHttpClientWireMockTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import static software.amazon.awssdk.core.internal.http.timers.ClientExecutionAndRequestTimerTestUtils.executionContext;
2727
import static software.amazon.awssdk.core.internal.util.ResponseHandlerTestUtils.combinedSyncResponseHandler;
2828

29-
import org.junit.jupiter.api.BeforeEach;
30-
import org.junit.jupiter.api.Test;
29+
import org.junit.Before;
30+
import org.junit.Test;
3131
import software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient;
3232
import software.amazon.awssdk.core.internal.http.response.NullErrorResponseHandler;
3333
import software.amazon.awssdk.http.SdkHttpFullRequest;
@@ -41,7 +41,7 @@ public class AmazonHttpClientWireMockTest extends WireMockTestBase {
4141
private static final String CONFIG_HEADER_VALUE = "client config header value";
4242
private static final String REQUEST_HEADER_VALUE = "request header value";
4343

44-
@BeforeEach
44+
@Before
4545
public void setUp() {
4646
stubFor(any(urlPathEqualTo(OPERATION)).willReturn(aResponse()));
4747
}

core/sdk-core/src/test/java/software/amazon/awssdk/core/http/ContentStreamProviderWireMockTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
2121
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
2222
import static org.assertj.core.api.Assertions.assertThat;
23-
import static org.junit.jupiter.api.Assertions.fail;
23+
import static org.junit.Assert.fail;
2424
import static software.amazon.awssdk.core.internal.http.timers.ClientExecutionAndRequestTimerTestUtils.executionContext;
2525
import static software.amazon.awssdk.core.internal.util.ResponseHandlerTestUtils.combinedSyncResponseHandler;
2626
import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely;
@@ -31,7 +31,7 @@
3131
import java.nio.charset.StandardCharsets;
3232
import java.util.ArrayList;
3333
import java.util.List;
34-
import org.junit.jupiter.api.Test;
34+
import org.junit.Test;
3535
import software.amazon.awssdk.core.exception.SdkServiceException;
3636
import software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient;
3737
import software.amazon.awssdk.core.internal.http.response.NullErrorResponseHandler;

core/sdk-core/src/test/java/software/amazon/awssdk/core/http/SdkTransactionIdInHeaderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
2222
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
2323
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
24-
import static org.junit.jupiter.api.Assertions.assertEquals;
25-
import static org.junit.jupiter.api.Assertions.assertNotNull;
26-
import static org.junit.jupiter.api.Assertions.fail;
24+
import static org.junit.Assert.assertEquals;
25+
import static org.junit.Assert.assertNotNull;
26+
import static org.junit.Assert.fail;
2727
import static software.amazon.awssdk.core.internal.util.ResponseHandlerTestUtils.combinedSyncResponseHandler;
2828

2929
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
30-
import org.junit.jupiter.api.Test;
30+
import org.junit.Test;
3131
import software.amazon.awssdk.core.exception.SdkServiceException;
3232
import software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient;
3333
import software.amazon.awssdk.core.internal.http.pipeline.stages.ApplyTransactionIdStage;

core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/http/timers/AsyncHttpClientApiCallTimeoutTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
import java.util.Arrays;
3434
import java.util.Collections;
3535
import java.util.concurrent.CompletableFuture;
36+
import org.junit.Before;
3637
import org.junit.Rule;
37-
import org.junit.jupiter.api.BeforeEach;
38-
import org.junit.jupiter.api.Test;
38+
import org.junit.Test;
3939
import software.amazon.awssdk.core.exception.ApiCallAttemptTimeoutException;
4040
import software.amazon.awssdk.core.exception.ApiCallTimeoutException;
4141
import software.amazon.awssdk.core.exception.SdkServiceException;
@@ -60,7 +60,7 @@ public class AsyncHttpClientApiCallTimeoutTests {
6060

6161
private AmazonAsyncHttpClient httpClient;
6262

63-
@BeforeEach
63+
@Before
6464
public void setup() {
6565
httpClient = testAsyncClientBuilder()
6666
.retryPolicy(RetryPolicy.none())

core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/http/timers/HttpClientApiCallAttemptTimeoutTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import com.github.tomakehurst.wiremock.junit.WireMockRule;
3131
import java.io.ByteArrayInputStream;
3232
import java.util.Arrays;
33+
import org.junit.Before;
3334
import org.junit.Rule;
34-
import org.junit.jupiter.api.BeforeEach;
35-
import org.junit.jupiter.api.Test;
35+
import org.junit.Test;
3636
import software.amazon.awssdk.core.exception.ApiCallAttemptTimeoutException;
3737
import software.amazon.awssdk.core.http.ExecutionContext;
3838
import software.amazon.awssdk.core.http.NoopTestRequest;
@@ -56,7 +56,7 @@ public class HttpClientApiCallAttemptTimeoutTest {
5656

5757
private AmazonSyncHttpClient httpClient;
5858

59-
@BeforeEach
59+
@Before
6060
public void setup() {
6161
httpClient = testClientBuilder()
6262
.retryPolicy(RetryPolicy.none())

core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/http/timers/HttpClientApiCallTimeoutTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import com.github.tomakehurst.wiremock.junit.WireMockRule;
3131
import java.io.ByteArrayInputStream;
3232
import java.util.Arrays;
33+
import org.junit.Before;
3334
import org.junit.Rule;
34-
import org.junit.jupiter.api.BeforeEach;
35-
import org.junit.jupiter.api.Test;
35+
import org.junit.Test;
3636
import software.amazon.awssdk.core.exception.ApiCallTimeoutException;
3737
import software.amazon.awssdk.core.http.ExecutionContext;
3838
import software.amazon.awssdk.core.http.NoopTestRequest;
@@ -56,7 +56,7 @@ public class HttpClientApiCallTimeoutTest {
5656

5757
private AmazonSyncHttpClient httpClient;
5858

59-
@BeforeEach
59+
@Before
6060
public void setup() {
6161
httpClient = testClientBuilder()
6262
.retryPolicy(RetryPolicy.none())

core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/util/MetricUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.io.IOException;
2323
import java.time.Duration;
2424
import org.junit.Rule;
25-
import org.junit.jupiter.api.Test;
25+
import org.junit.Test;
2626
import org.junit.rules.ExpectedException;
2727
import software.amazon.awssdk.core.http.HttpResponseHandler;
2828
import software.amazon.awssdk.core.metrics.CoreMetric;

core/sdk-core/src/test/java/software/amazon/awssdk/core/sync/RequestBodyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import java.nio.file.Files;
3131
import java.nio.file.Path;
3232
import org.junit.Rule;
33-
import org.junit.jupiter.api.Test;
33+
import org.junit.Test;
3434
import org.junit.rules.TemporaryFolder;
3535
import software.amazon.awssdk.core.internal.util.Mimetype;
3636
import software.amazon.awssdk.utils.IoUtils;

0 commit comments

Comments
 (0)