This is an automated email from the ASF dual-hosted git repository.

joewitt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new c6999ba9d8 NIFI-10278 - This closes #6247. repeat onTrigger of 
ConsumeTwitter until a FlowFile is received or timeout after 60 seconds
c6999ba9d8 is described below

commit c6999ba9d80b792cbeea889fc76462568cc22bc8
Author: emiliosetiadarma <[email protected]>
AuthorDate: Mon Jul 25 13:26:36 2022 -0700

    NIFI-10278 - This closes #6247. repeat onTrigger of ConsumeTwitter until a 
FlowFile is received or timeout after 60 seconds
    
    Signed-off-by: Joe Witt <[email protected]>
---
 .../apache/nifi/processors/twitter/TestConsumeTwitter.java | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-social-media-bundle/nifi-twitter-processors/src/test/java/org/apache/nifi/processors/twitter/TestConsumeTwitter.java
 
b/nifi-nar-bundles/nifi-social-media-bundle/nifi-twitter-processors/src/test/java/org/apache/nifi/processors/twitter/TestConsumeTwitter.java
index 56d2a2c14a..decd3093f9 100644
--- 
a/nifi-nar-bundles/nifi-social-media-bundle/nifi-twitter-processors/src/test/java/org/apache/nifi/processors/twitter/TestConsumeTwitter.java
+++ 
b/nifi-nar-bundles/nifi-social-media-bundle/nifi-twitter-processors/src/test/java/org/apache/nifi/processors/twitter/TestConsumeTwitter.java
@@ -25,6 +25,7 @@ import org.apache.nifi.util.TestRunners;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 import java.io.IOException;
 
@@ -53,6 +54,7 @@ public class TestConsumeTwitter {
     }
 
     @Test
+    @Timeout(60)
     public void testReceiveSingleTweetInStream() throws InterruptedException {
         MockResponse response = new MockResponse()
                 .setResponseCode(200)
@@ -68,11 +70,13 @@ public class TestConsumeTwitter {
 
         runner.assertValid();
 
-        // the TwitterStreamAPI class spins up another thread and might not be 
done queueing tweets in one run of the processor
-        final int maxTries = 3;
-        final long runSchedule = 250;
-        runner.setRunSchedule(runSchedule);
-        runner.run(maxTries, false, true);
+        // The TwitterStreamAPI class spins up another thread and might not be 
done queueing tweets in one run of the
+        // processor, so the test will timeout after 60 seconds.
+        runner.run(1, false, true);
+
+        while 
(runner.getFlowFilesForRelationship(ConsumeTwitter.REL_SUCCESS).size() == 0) {
+            runner.run(1, false, false);
+        }
         runner.stop();
 
         // there should only be a single FlowFile containing a tweet

Reply via email to