MessageSender { public void init() { mainLoopExecutor.scheduleWithFixedDelay( new Runnable() { @Override public void run() { try { deliverMessages(); purgeExpiredMessages(); } catch ( Exception e ) { LOG.error( "Error in MessageSender", e ); } } }, 0, SLEEP_BETWEEN_ITERATIONS_SEC, TimeUnit.SECONDS ); } MessageSender( final MessengerDataService messengerDataService, final MessengerImpl messenger ); void init(); void dispose(); static final int SLEEP_BETWEEN_ITERATIONS_SEC; }
@Test public void testInit() throws Exception { messageSender.init(); verify( mainLoopExecutor ).scheduleWithFixedDelay( isA( Runnable.class ), eq( 0L ), eq( ( long ) MessageSender.SLEEP_BETWEEN_ITERATIONS_SEC ), eq( TimeUnit.SECONDS ) ); }