dan-s1 commented on code in PR #8529:
URL: https://github.com/apache/nifi/pull/8529#discussion_r1544643677


##########
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:
   @sujkm Is it possible to have a test in TestPutSNS to test the endpoint 
override?



-- 
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]

Reply via email to