Skip to content

Upgrade surefire-junit47 to surefire-junit-platform and partially revert "Migrate most tests to JUnit 5 (#2931)" #2970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 14, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


import java.io.File;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import software.amazon.awssdk.codegen.C2jModels;
import software.amazon.awssdk.codegen.IntermediateModelBuilder;
Expand All @@ -42,7 +42,7 @@ public class UseLegacyEventGenerationSchemeProcessorTest {
private static ServiceModel serviceModel;


@BeforeAll
@BeforeClass
public static void setup() {
String c2jFilePath = UseLegacyEventGenerationSchemeProcessorTest.class.getResource(RESOURCE_ROOT + "/service-2.json").getFile();
File c2jFile = new File(c2jFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

package software.amazon.awssdk.auth.credentials;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertEquals;

import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.profiles.ProfileFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.util.SdkUserAgent;
import software.amazon.awssdk.regions.util.ResourcesEndpointProvider;
Expand All @@ -51,7 +51,7 @@ public class HttpCredentialsProviderTest {

private static String successResponseWithInvalidBody;

@BeforeAll
@BeforeClass
public static void setup() throws IOException {
try (InputStream successInputStream = HttpCredentialsProviderTest.class.getResourceAsStream
("/resources/wiremock/successResponse.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder;
import java.time.Duration;
import java.time.Instant;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import software.amazon.awssdk.core.SdkSystemSetting;
import software.amazon.awssdk.core.exception.SdkClientException;
Expand All @@ -57,12 +57,12 @@ public class InstanceProfileCredentialsProviderTest {
@Rule
public WireMockRule mockMetadataEndpoint = new WireMockRule();

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

@AfterAll
@AfterClass
public static void teardown() {
System.clearProperty(SdkSystemSetting.AWS_EC2_METADATA_SERVICE_ENDPOINT.property());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import static org.assertj.core.api.Assertions.assertThat;

import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.Rule;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import software.amazon.awssdk.metrics.MetricCategory;
import software.amazon.awssdk.metrics.MetricCollection;
Expand All @@ -34,7 +34,7 @@ public class DefaultMetricCollectorTest {
@Rule
public ExpectedException thrown = ExpectedException.none();

@AfterAll
@AfterClass
public static void teardown() {
DefaultSdkMetric.clearDeclaredMetrics();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import software.amazon.awssdk.metrics.MetricCategory;
import software.amazon.awssdk.metrics.MetricLevel;
Expand All @@ -32,7 +32,7 @@ public class DefaultSdkMetricTest {
@Rule
public ExpectedException thrown = ExpectedException.none();

@BeforeEach
@Before
public void methodSetup() {
DefaultSdkMetric.clearDeclaredMetrics();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static java.util.Collections.emptyMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;

import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
Expand All @@ -26,11 +27,10 @@
import java.net.Inet4Address;
import java.net.URI;
import java.util.Collections;
import org.junit.After;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.Test;

public class ConnectionUtilsComponentTest {

Expand All @@ -42,15 +42,15 @@ public class ConnectionUtilsComponentTest {

private final ConnectionUtils sut = ConnectionUtils.create();

@AfterEach
@After
public void cleanup() {
System.getProperties().remove("http.proxyHost");
System.getProperties().remove("http.proxyPort");
}

@Test
public void proxiesAreNotUsedEvenIfPropertyIsSet() throws IOException {
Assumptions.assumeTrue(Inet4Address.getLocalHost().isReachable(100));
assumeTrue(Inet4Address.getLocalHost().isReachable(100));
System.getProperties().put("http.proxyHost", "localhost");
System.getProperties().put("http.proxyPort", String.valueOf(mockProxyServer.port()));
HttpURLConnection connection = sut.connectToEndpoint(URI.create("http://" + Inet4Address.getLocalHost().getHostAddress() + ":" + mockServer.port()), emptyMap());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.http.Fault;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import software.amazon.awssdk.core.SdkSystemSetting;
import software.amazon.awssdk.core.exception.SdkClientException;
Expand All @@ -51,7 +51,7 @@ public class EC2MetadataUtilsTest {
@Rule
public WireMockRule mockMetadataEndpoint = new WireMockRule();

@BeforeEach
@Before
public void methodSetup() {
System.setProperty(SdkSystemSetting.AWS_EC2_METADATA_SERVICE_ENDPOINT.property(), "http://localhost:" + mockMetadataEndpoint.port());
EC2MetadataUtils.clearCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.net.URISyntaxException;
import java.nio.file.Paths;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.profiles.ProfileFileSystemSetting;
import software.amazon.awssdk.regions.Region;
Expand Down
4 changes: 2 additions & 2 deletions core/sdk-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<artifactId>surefire-junit-platform</artifactId>
<version>${maven.surefire.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -259,7 +259,7 @@
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<artifactId>surefire-junit-platform</artifactId>
<version>${maven.surefire.version}</version>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import static software.amazon.awssdk.core.internal.http.timers.ClientExecutionAndRequestTimerTestUtils.executionContext;
import static software.amazon.awssdk.core.internal.util.ResponseHandlerTestUtils.combinedSyncResponseHandler;

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

@BeforeEach
@Before
public void setUp() {
stubFor(any(urlPathEqualTo(OPERATION)).willReturn(aResponse()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.Assert.fail;
import static software.amazon.awssdk.core.internal.http.timers.ClientExecutionAndRequestTimerTestUtils.executionContext;
import static software.amazon.awssdk.core.internal.util.ResponseHandlerTestUtils.combinedSyncResponseHandler;
import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely;
Expand All @@ -31,7 +31,7 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import software.amazon.awssdk.core.exception.SdkServiceException;
import software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient;
import software.amazon.awssdk.core.internal.http.response.NullErrorResponseHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static software.amazon.awssdk.core.internal.util.ResponseHandlerTestUtils.combinedSyncResponseHandler;

import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import software.amazon.awssdk.core.exception.SdkServiceException;
import software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient;
import software.amazon.awssdk.core.internal.http.pipeline.stages.ApplyTransactionIdStage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import software.amazon.awssdk.core.exception.ApiCallAttemptTimeoutException;
import software.amazon.awssdk.core.exception.ApiCallTimeoutException;
import software.amazon.awssdk.core.exception.SdkServiceException;
Expand All @@ -60,7 +60,7 @@ public class AsyncHttpClientApiCallTimeoutTests {

private AmazonAsyncHttpClient httpClient;

@BeforeEach
@Before
public void setup() {
httpClient = testAsyncClientBuilder()
.retryPolicy(RetryPolicy.none())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import software.amazon.awssdk.core.exception.ApiCallAttemptTimeoutException;
import software.amazon.awssdk.core.http.ExecutionContext;
import software.amazon.awssdk.core.http.NoopTestRequest;
Expand All @@ -56,7 +56,7 @@ public class HttpClientApiCallAttemptTimeoutTest {

private AmazonSyncHttpClient httpClient;

@BeforeEach
@Before
public void setup() {
httpClient = testClientBuilder()
.retryPolicy(RetryPolicy.none())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import software.amazon.awssdk.core.exception.ApiCallTimeoutException;
import software.amazon.awssdk.core.http.ExecutionContext;
import software.amazon.awssdk.core.http.NoopTestRequest;
Expand All @@ -56,7 +56,7 @@ public class HttpClientApiCallTimeoutTest {

private AmazonSyncHttpClient httpClient;

@BeforeEach
@Before
public void setup() {
httpClient = testClientBuilder()
.retryPolicy(RetryPolicy.none())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.io.IOException;
import java.time.Duration;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import software.amazon.awssdk.core.internal.util.Mimetype;
import software.amazon.awssdk.utils.IoUtils;
Expand Down
Loading