Add unInit, to fix leaked state between tests.

This commit is contained in:
2024-03-12 14:05:03 -05:00
parent 2c4fc6a0d4
commit d09b12ca5b
2 changed files with 15 additions and 1 deletions

View File

@ -299,4 +299,16 @@ public class QScheduleManager
return (scheduler); return (scheduler);
} }
/*******************************************************************************
** reset the singleton instance (to null); clear the map of schedulers.
** Not clear it's ever useful to call in main-code - but can be used for tests.
*******************************************************************************/
public void unInit()
{
qScheduleManager = null;
schedulers.clear();
}
} }

View File

@ -80,7 +80,8 @@ class SimpleSchedulerTest extends BaseTest
assertThat(simpleScheduler.getExecutors()).isNotEmpty(); assertThat(simpleScheduler.getExecutors()).isNotEmpty();
simpleScheduler.stopAsync(); qScheduleManager.stop();
qScheduleManager.unInit();
} }
@ -119,6 +120,7 @@ class SimpleSchedulerTest extends BaseTest
////////////////////////////////////////////////// //////////////////////////////////////////////////
SleepUtils.sleep(50, TimeUnit.MILLISECONDS); SleepUtils.sleep(50, TimeUnit.MILLISECONDS);
qScheduleManager.stopAsync(); qScheduleManager.stopAsync();
qScheduleManager.unInit();
System.out.println("Ran: " + BasicStep.counter + " times"); System.out.println("Ran: " + BasicStep.counter + " times");
assertTrue(BasicStep.counter > 1, "Scheduled process should have ran at least twice (but only ran [" + BasicStep.counter + "] time(s)."); assertTrue(BasicStep.counter > 1, "Scheduled process should have ran at least twice (but only ran [" + BasicStep.counter + "] time(s).");