Skip to content

Commit 8052cbb

Browse files
author
Bennett Lynch
committed
Upgrade surefire-junit47 to surefire-junit-platform and partially revert "Migrate most tests to JUnit 5 (aws#2931)"
This partially reverts commit abe96fd (aws#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 8052cbb

File tree

103 files changed

+323
-312
lines changed

Some content is hidden

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

103 files changed

+323
-312
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/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/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;

http-clients/apache-client/src/test/java/software/amazon/awssdk/http/apache/ApacheClientTlsAuthTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
import java.net.URI;
3333
import javax.net.ssl.SSLException;
3434
import org.apache.http.NoHttpResponseException;
35+
import org.junit.After;
36+
import org.junit.AfterClass;
37+
import org.junit.Before;
38+
import org.junit.BeforeClass;
3539
import org.junit.Rule;
36-
import org.junit.jupiter.api.AfterAll;
37-
import org.junit.jupiter.api.AfterEach;
38-
import org.junit.jupiter.api.BeforeAll;
39-
import org.junit.jupiter.api.BeforeEach;
40-
import org.junit.jupiter.api.Test;
40+
import org.junit.Test;
4141
import org.junit.rules.ExpectedException;
4242
import software.amazon.awssdk.http.FileStoreTlsKeyManagersProvider;
4343
import software.amazon.awssdk.http.HttpExecuteRequest;
@@ -61,7 +61,7 @@ public class ApacheClientTlsAuthTest extends ClientTlsAuthTestBase {
6161
@Rule
6262
public ExpectedException thrown = ExpectedException.none();
6363

64-
@BeforeAll
64+
@BeforeClass
6565
public static void setUp() throws IOException {
6666
ClientTlsAuthTestBase.setUp();
6767

@@ -83,12 +83,12 @@ public static void setUp() throws IOException {
8383
keyManagersProvider = FileStoreTlsKeyManagersProvider.create(clientKeyStore, CLIENT_STORE_TYPE, STORE_PASSWORD);
8484
}
8585

86-
@BeforeEach
86+
@Before
8787
public void methodSetup() {
8888
wireMockServer.stubFor(any(urlMatching(".*")).willReturn(aResponse().withStatus(200).withBody("{}")));
8989
}
9090

91-
@AfterAll
91+
@AfterClass
9292
public static void teardown() throws IOException {
9393
wireMockServer.stop();
9494
System.clearProperty("javax.net.ssl.trustStore");
@@ -97,7 +97,7 @@ public static void teardown() throws IOException {
9797
ClientTlsAuthTestBase.teardown();
9898
}
9999

100-
@AfterEach
100+
@After
101101
public void methodTeardown() {
102102
if (client != null) {
103103
client.close();

http-clients/apache-client/src/test/java/software/amazon/awssdk/http/apache/ApacheMetricsTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
import com.github.tomakehurst.wiremock.WireMockServer;
2525
import java.io.IOException;
26+
import org.junit.After;
27+
import org.junit.AfterClass;
28+
import org.junit.Before;
29+
import org.junit.BeforeClass;
2630
import org.junit.Rule;
27-
import org.junit.jupiter.api.AfterAll;
28-
import org.junit.jupiter.api.AfterEach;
29-
import org.junit.jupiter.api.BeforeAll;
30-
import org.junit.jupiter.api.BeforeEach;
31-
import org.junit.jupiter.api.Test;
31+
import org.junit.Test;
3232
import org.junit.rules.ExpectedException;
3333
import software.amazon.awssdk.http.HttpExecuteRequest;
3434
import software.amazon.awssdk.http.HttpExecuteResponse;
@@ -47,23 +47,23 @@ public class ApacheMetricsTest {
4747
@Rule
4848
public ExpectedException thrown = ExpectedException.none();
4949

50-
@BeforeAll
50+
@BeforeClass
5151
public static void setUp() throws IOException {
5252
wireMockServer = new WireMockServer();
5353
wireMockServer.start();
5454
}
5555

56-
@BeforeEach
56+
@Before
5757
public void methodSetup() {
5858
wireMockServer.stubFor(any(urlMatching(".*")).willReturn(aResponse().withStatus(200).withBody("{}")));
5959
}
6060

61-
@AfterAll
61+
@AfterClass
6262
public static void teardown() throws IOException {
6363
wireMockServer.stop();
6464
}
6565

66-
@AfterEach
66+
@After
6767
public void methodTeardown() {
6868
if (client != null) {
6969
client.close();

http-clients/aws-crt-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
<dependencies>
193193
<dependency>
194194
<groupId>org.apache.maven.surefire</groupId>
195-
<artifactId>surefire-junit47</artifactId>
195+
<artifactId>surefire-junit-platform</artifactId>
196196
<version>${maven.surefire.version}</version>
197197
</dependency>
198198
<dependency>

0 commit comments

Comments
 (0)