Skip to content
Permalink
Browse files
[FLINK-27561][aws][tests] Migrate connector-aws-base to JUnit5
  • Loading branch information
snuyanzin committed May 18, 2022
1 parent 1c252ad commit dbfb2ac7302152dac237282ee656d010c76e46c8
Showing 6 changed files with 203 additions and 195 deletions.
@@ -104,6 +104,12 @@ under the License.
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<excludes>
<!-- test-jar is still used by JUnit4 modules -->
<exclude>META-INF/services/org.junit.jupiter.api.extension.Extension</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
@@ -21,17 +21,17 @@
import org.apache.flink.connector.aws.config.AWSConfigConstants;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/** Unit tests for {@link AWSOptionUtils}. */
public class AWSOptionsUtilTest {
class AWSOptionsUtilTest {

@Test
public void testAWSKeyMapper() {
void testAWSKeyMapper() {
AWSOptionUtils awsOptionUtils = new AWSOptionUtils(getDefaultAWSConfigurations());
Map<String, String> expectedProperties = getDefaultExpectedAWSConfigurations();

@@ -42,7 +42,7 @@ public void testAWSKeyMapper() {
}

@Test
public void testAWSKeySelectionAndMapping() {
void testAWSKeySelectionAndMapping() {
Map<String, String> resolvedTableOptions = getDefaultAWSConfigurations();
Map<String, String> expectedProperties = getDefaultExpectedAWSConfigurations();
// adding irrelevant configurations
@@ -58,7 +58,7 @@ public void testAWSKeySelectionAndMapping() {
}

@Test
public void testGoodAWSProperties() {
void testGoodAWSProperties() {
AWSOptionUtils awsOptionUtils = new AWSOptionUtils(getDefaultAWSConfigurations());
Properties expectedProperties = new Properties();
expectedProperties.putAll(getDefaultExpectedAWSConfigurations());
@@ -69,7 +69,7 @@ public void testGoodAWSProperties() {
}

@Test
public void testBadAWSRegion() {
void testBadAWSRegion() {
Map<String, String> defaultProperties = getDefaultAWSConfigurations();
defaultProperties.put("aws.region", "invalid-aws-region");

@@ -81,7 +81,7 @@ public void testBadAWSRegion() {
}

@Test
public void testMissingAWSCredentials() {
void testMissingAWSCredentials() {
Map<String, String> defaultProperties = getDefaultAWSConfigurations();
defaultProperties.remove("aws.credentials.basic.accesskeyid");

@@ -98,7 +98,7 @@ public void testMissingAWSCredentials() {
}

@Test
public void testInvalidTrustAllCertificatesOption() {
void testInvalidTrustAllCertificatesOption() {
Map<String, String> defaultProperties = getDefaultAWSConfigurations();
defaultProperties.put("aws.trust.all.certificates", "invalid-boolean");

@@ -19,17 +19,16 @@
package org.apache.flink.connector.aws.table.util;

import org.apache.flink.connector.aws.config.AWSConfigConstants;
import org.apache.flink.util.TestLogger;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/** Unit tests for {@link AsyncClientOptionsUtils}. */
public class AsyncClientOptionsUtilsTest extends TestLogger {
class AsyncClientOptionsUtilsTest {

@Test
public void testGoodAsyncClientOptionsMapping() {
@@ -44,7 +43,7 @@ public void testGoodAsyncClientOptionsMapping() {
}

@Test
public void testAsyncClientOptionsUtilsFilteringNonPrefixedOptions() {
void testAsyncClientOptionsUtilsFilteringNonPrefixedOptions() {
Map<String, String> defaultClientOptions = getDefaultClientOptions();
defaultClientOptions.put("sink.not.http-client.some.option", "someValue");

@@ -59,7 +58,7 @@ public void testAsyncClientOptionsUtilsFilteringNonPrefixedOptions() {
}

@Test
public void testAsyncClientOptionsUtilsExtractingCorrectConfiguration() {
void testAsyncClientOptionsUtilsExtractingCorrectConfiguration() {
AsyncClientOptionsUtils asyncClientOptionsUtils =
new AsyncClientOptionsUtils(getDefaultClientOptions());

@@ -70,7 +69,7 @@ public void testAsyncClientOptionsUtilsExtractingCorrectConfiguration() {
}

@Test
public void testAsyncClientOptionsUtilsFailOnInvalidMaxConcurrency() {
void testAsyncClientOptionsUtilsFailOnInvalidMaxConcurrency() {
Map<String, String> defaultClientOptions = getDefaultClientOptions();
defaultClientOptions.put("sink.http-client.max-concurrency", "invalid-integer");

@@ -84,7 +83,7 @@ public void testAsyncClientOptionsUtilsFailOnInvalidMaxConcurrency() {
}

@Test
public void testAsyncClientOptionsUtilsFailOnInvalidReadTimeout() {
void testAsyncClientOptionsUtilsFailOnInvalidReadTimeout() {
Map<String, String> defaultClientOptions = getDefaultClientOptions();
defaultClientOptions.put("sink.http-client.read-timeout", "invalid-integer");

@@ -98,7 +97,7 @@ public void testAsyncClientOptionsUtilsFailOnInvalidReadTimeout() {
}

@Test
public void testAsyncClientOptionsUtilsFailOnInvalidHttpProtocol() {
void testAsyncClientOptionsUtilsFailOnInvalidHttpProtocol() {
Map<String, String> defaultProperties = getDefaultClientOptions();
defaultProperties.put("sink.http-client.protocol.version", "invalid-http-protocol");

@@ -17,7 +17,7 @@

package org.apache.flink.connector.aws.util;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder;
@@ -47,15 +47,15 @@
import static org.mockito.Mockito.when;

/** Tests for {@link AWSAsyncSinkUtil}. */
public class AWSAsyncSinkUtilTest {
class AWSAsyncSinkUtilTest {

private static final String DEFAULT_USER_AGENT_PREFIX_FORMAT =
"Apache Flink %s (%s) *Destination* Connector";
private static final String DEFAULT_USER_AGENT_PREFIX_FORMAT_V2 =
"Apache Flink %s (%s) *Destination* Connector V2";

@Test
public void testCreateKinesisAsyncClient() {
void testCreateKinesisAsyncClient() {
Properties properties = TestUtil.properties(AWS_REGION, "eu-west-2");
MockAsyncClientBuilder builder = mockKinesisAsyncClientBuilder();
ClientOverrideConfiguration clientOverrideConfiguration =
@@ -74,7 +74,7 @@ public void testCreateKinesisAsyncClient() {
}

@Test
public void testCreateKinesisAsyncClientWithEndpointOverride() {
void testCreateKinesisAsyncClientWithEndpointOverride() {
Properties properties = TestUtil.properties(AWS_REGION, "eu-west-2");
properties.setProperty(AWS_ENDPOINT, "https://localhost");

@@ -90,7 +90,7 @@ public void testCreateKinesisAsyncClientWithEndpointOverride() {
}

@Test
public void testClientOverrideConfigurationWithDefaults() {
void testClientOverrideConfigurationWithDefaults() {
SdkClientConfiguration clientConfiguration = SdkClientConfiguration.builder().build();

ClientOverrideConfiguration.Builder builder = mockClientOverrideConfigurationBuilder();
@@ -112,7 +112,7 @@ public void testClientOverrideConfigurationWithDefaults() {
}

@Test
public void testClientOverrideConfigurationUserAgentSuffix() {
void testClientOverrideConfigurationUserAgentSuffix() {
SdkClientConfiguration clientConfiguration =
SdkClientConfiguration.builder()
.option(SdkAdvancedClientOption.USER_AGENT_SUFFIX, "suffix")
@@ -130,7 +130,7 @@ public void testClientOverrideConfigurationUserAgentSuffix() {
}

@Test
public void testClientOverrideConfigurationApiCallAttemptTimeout() {
void testClientOverrideConfigurationApiCallAttemptTimeout() {
SdkClientConfiguration clientConfiguration =
SdkClientConfiguration.builder()
.option(SdkClientOption.API_CALL_ATTEMPT_TIMEOUT, Duration.ofMillis(500))
@@ -149,7 +149,7 @@ public void testClientOverrideConfigurationApiCallAttemptTimeout() {
}

@Test
public void testClientOverrideConfigurationApiCallTimeout() {
void testClientOverrideConfigurationApiCallTimeout() {
SdkClientConfiguration clientConfiguration =
SdkClientConfiguration.builder()
.option(SdkClientOption.API_CALL_TIMEOUT, Duration.ofMillis(600))

0 comments on commit dbfb2ac

Please sign in to comment.