@Test(timeout = 5000)
public void testRunBeforeCtxClosedEvent() throws Exception {

    ContextRefreshedEvent refreshEvent = mock(ContextRefreshedEvent.class);
    inBuffer.onApplicationEvent(refreshEvent);
    ContextClosedEvent event = mock(ContextClosedEvent.class);
    when(workerManager.isUp()).thenReturn(true);
    doReturn(true).when(workerStateUpdateService).isWorkerEnabled();
    Thread thread = new Thread(inBuffer);
    thread.start();
    verify(workerManager, timeout(1000).atLeastOnce()).getInBufferSize();
    inBuffer.onApplicationEvent(event);
    while (thread.isAlive()) {
        Thread.sleep(100L);
    }
}