sujkm commented on code in PR #8529:
URL: https://github.com/apache/nifi/pull/8529#discussion_r1546337329
##########
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/sns/ITPutSNS.java:
##########
@@ -36,43 +45,75 @@
*/
public class ITPutSNS {
- private static final String CREDENTIALS_FILE =
System.getProperty("user.home") + "/aws-credentials.properties";
- private final String TOPIC_ARN = "Add SNS ARN here";
+ private static final DockerImageName localstackImage =
DockerImageName.parse("localstack/localstack:latest");
+
+ private static final LocalStackContainer localstack = new
LocalStackContainer(localstackImage)
+ .withServices(LocalStackContainer.Service.SNS);
+
+ private static final String CREDENTIALS_FILE =
"src/test/resources/mock-aws-credentials.properties";
+ private static String topicARN;
+ private static SnsClient client;
@BeforeAll
- public static void assumeCredentialsFileExists() {
- Assumptions.assumeTrue(new File(CREDENTIALS_FILE).exists());
+ public static void setup() throws InterruptedException {
+ System.setProperty("software.amazon.awssdk.http.service.impl",
"software.amazon.awssdk.http.urlconnection.UrlConnectionSdkHttpService");
+ localstack.start();
+
+ client = SnsClient.builder()
+ .endpointOverride(localstack.getEndpoint())
+ .credentialsProvider(
+ StaticCredentialsProvider.create(
+
AwsBasicCredentials.create(localstack.getAccessKey(), localstack.getSecretKey())
+ )
+ )
+ .region(Region.of(localstack.getRegion()))
+ .build();
+
+ final CreateTopicResponse response =
client.createTopic(CreateTopicRequest.builder()
+ .name("SnsSystemTest")
+ .build());
+ assertTrue(response.sdkHttpResponse().isSuccessful());
+ topicARN = response.topicArn();
+ }
+
+ @AfterAll
+ public static void shutdown() {
+ client.close();
+ localstack.stop();
}
@Test
public void testPublish() throws IOException {
- final TestRunner runner = TestRunners.newTestRunner(new PutSNS());
- AuthUtils.enableCredentialsFile(runner, CREDENTIALS_FILE);
- runner.setProperty(PutSNS.ARN, TOPIC_ARN);
+ final TestRunner runner = initRunner(PutSNS.class);
+ AuthUtils.enableAccessKey(runner, localstack.getAccessKey(),
localstack.getSecretKey());
Review Comment:
I'm not sure how to test this since all the current examples of testing
endpoint override are done in the integration tests. Should I leave the
integration test as it was?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]