@Test public void testPeriodCheck() throws Exception { InOrder inOrder = inOrder(testHandler); lcsAppender.setFlushIntervalMillis(10000000); lcsAppender.setPeriodCheckIntervalMillis(200); doNothing().when(testHandler).doStart(); lcsAppender.start(); inOrder.verify(testHandler, times(1)).doStart(); doNothing().when(testHandler).doPeriodCheck(); Thread.sleep(200 + 50); inOrder.verify(testHandler).doPeriodCheck(); doNothing().when(testHandler).doClose(); lcsAppender.close(); inOrder.verify(testHandler, times(1)).doClose(); inOrder.verifyNoMoreInteractions(); }
private void periodCheck() { if (System.currentTimeMillis() - lastPeriodCheckTimestamp > periodCheckIntervalMillis) { lastPeriodCheckTimestamp = System.currentTimeMillis(); doPeriodCheck(); } }
LCSAppender { private void periodCheck() { if (System.currentTimeMillis() - lastPeriodCheckTimestamp > periodCheckIntervalMillis) { lastPeriodCheckTimestamp = System.currentTimeMillis(); doPeriodCheck(); } } }
LCSAppender { private void periodCheck() { if (System.currentTimeMillis() - lastPeriodCheckTimestamp > periodCheckIntervalMillis) { lastPeriodCheckTimestamp = System.currentTimeMillis(); doPeriodCheck(); } } LCSAppender(ILogger logger); }
LCSAppender { private void periodCheck() { if (System.currentTimeMillis() - lastPeriodCheckTimestamp > periodCheckIntervalMillis) { lastPeriodCheckTimestamp = System.currentTimeMillis(); doPeriodCheck(); } } LCSAppender(ILogger logger); String getTopicName(); void setTopicName(String topicName); long getMaxBufferMessageBytes(); void setMaxBufferMessageBytes(long maxBufferMessageBytes); boolean isBlockWhenBufferFull(); void setBlockWhenBufferFull(boolean blockWhenBufferFull); long getMaxBufferMessageNumber(); void setMaxBufferMessageNumber(long maxBufferMessageNumber); long getFlushMessageBytes(); void setFlushMessageBytes(long flushMessageBytes); long getFlushMessageNumber(); void setFlushMessageNumber(long flushMessageNumber); long getFlushIntervalMillis(); void setFlushIntervalMillis(long flushIntervalMillis); long getPeriodCheckIntervalMillis(); void setPeriodCheckIntervalMillis(long periodCheckIntervalMillis); void start(); void close(); void addMessage(Message message); }
LCSAppender { private void periodCheck() { if (System.currentTimeMillis() - lastPeriodCheckTimestamp > periodCheckIntervalMillis) { lastPeriodCheckTimestamp = System.currentTimeMillis(); doPeriodCheck(); } } LCSAppender(ILogger logger); String getTopicName(); void setTopicName(String topicName); long getMaxBufferMessageBytes(); void setMaxBufferMessageBytes(long maxBufferMessageBytes); boolean isBlockWhenBufferFull(); void setBlockWhenBufferFull(boolean blockWhenBufferFull); long getMaxBufferMessageNumber(); void setMaxBufferMessageNumber(long maxBufferMessageNumber); long getFlushMessageBytes(); void setFlushMessageBytes(long flushMessageBytes); long getFlushMessageNumber(); void setFlushMessageNumber(long flushMessageNumber); long getFlushIntervalMillis(); void setFlushIntervalMillis(long flushIntervalMillis); long getPeriodCheckIntervalMillis(); void setPeriodCheckIntervalMillis(long periodCheckIntervalMillis); void start(); void close(); void addMessage(Message message);  }