exceptionfactory commented on a change in pull request #5041:
URL: https://github.com/apache/nifi/pull/5041#discussion_r622581289



##########
File path: 
minifi/minifi-bootstrap/src/test/java/org/apache/nifi/minifi/bootstrap/status/reporters/StatusLoggerTest.java
##########
@@ -194,16 +209,81 @@ public void TestErrorException() throws IOException {
         
Mockito.when(queryableStatusAggregator.statusReport(MOCK_QUERY)).thenThrow(ioException);
 
         statusLogger.initialize(getProperties(LogLevel.ERROR), 
queryableStatusAggregator);
+        statusLogger.setScheduledExecutorService(new 
RunOnceScheduledExecutorService());
         statusLogger.start();
 
         verify(logger, 
Mockito.timeout(300).atLeastOnce()).error(ENCOUNTERED_IO_EXCEPTION, 
ioException);
     }
 
-    private static Properties getProperties(LogLevel logLevel){
+    private static Properties getProperties(LogLevel logLevel) {
         Properties properties = new Properties();
-        properties.setProperty(REPORT_PERIOD_KEY, "100");
+        properties.setProperty(REPORT_PERIOD_KEY, "1");
         properties.setProperty(LOGGING_LEVEL_KEY, logLevel.name());
         properties.setProperty(QUERY_KEY, MOCK_QUERY);
         return properties;
     }
+
+    private static class RunOnceScheduledExecutorService extends 
AbstractExecutorService implements ScheduledExecutorService {

Review comment:
       Instead of implementing the interface, what about using 
`Executors.newSingleThreadScheduledExecutor(ThreadFactory)` with a custom 
`ThreadFactory` that uses `Thread.currentThread()`?  That would simplify the 
implementation.

##########
File path: 
minifi/minifi-bootstrap/src/test/java/org/apache/nifi/minifi/bootstrap/status/reporters/StatusLoggerTest.java
##########
@@ -101,14 +107,16 @@ public void testFailedInitDueToNoQuery(){
     @Test
     public void TestTrace() {
         statusLogger.initialize(getProperties(LogLevel.TRACE), 
queryableStatusAggregator);
+        statusLogger.setScheduledExecutorService(new 
RunOnceScheduledExecutorService());
         statusLogger.start();
 
-        verify(logger, Mockito.timeout(300).atLeastOnce()).info(MOCK_STATUS, 
(Throwable) null);
+        verify(logger, Mockito.timeout(300).atLeastOnce()).trace(MOCK_STATUS, 
(Throwable) null);

Review comment:
       With the change to ensure that the task is always run, can 
Mockito.timeout() be removed from all test methods?




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


Reply via email to