shawnweeks commented on a change in pull request #3974: Add onUnscheduled 
support for ExecuteGroovyScript Processor
URL: https://github.com/apache/nifi/pull/3974#discussion_r364909027
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/test/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScriptTest.java
 ##########
 @@ -427,6 +427,29 @@ public void test_withWriter() throws Exception {
         
flowFile.assertContentEquals("5678".getBytes(StandardCharsets.UTF_16LE));
     }
 
+    @Test
+    public void test_onStart_onStop() throws Exception {
+        runner.setProperty(ExecuteGroovyScript.SCRIPT_FILE, 
TEST_RESOURCE_LOCATION + "test_onStart_onStop.groovy");
+        runner.assertValid();
+        runner.enqueue("");
+        runner.run();
+
+        
runner.assertAllFlowFilesTransferred(ExecuteGroovyScript.REL_SUCCESS.getName(), 
1);
+        final List<MockFlowFile> result = 
runner.getFlowFilesForRelationship(ExecuteGroovyScript.REL_SUCCESS.getName());
+        MockFlowFile resultFile = result.get(0);
+        resultFile.assertAttributeExists("a");
+        resultFile.assertAttributeEquals("a", "A");
+        // Inspect the output visually for onStop, no way to pass back values
+    }
+
+    @Test
 
 Review comment:
   If you'd like to actually check the out here you can do something like this.
   ```
   @Test
   public void test_onUnscheduled() throws Exception {
       runner.setProperty(ExecuteGroovyScript.SCRIPT_FILE, 
TEST_RESOURCE_LOCATION + "test_onUnscheduled.groovy");
       runner.assertValid();
       final PrintStream originalOut = System.out;
       final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
       System.setOut(new PrintStream(outContent));
       runner.run();
       System.setOut(originalOut);
       assertEquals("onUnscheduled invoked successfully - Inspect this 
visually\n", outContent.toString());
       // Inspect the output visually
   }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to