SyslogUDPSource extends AbstractSource implements EventDrivenSource, Configurable { @VisibleForTesting SourceCounter getSourceCounter() { return sourceCounter; }  @Override void start(); @Override void stop(); @Override void configure(Context context); static final int DEFAULT_MIN_SIZE; static final int DEFAULT_INITIAL_SIZE; }
@Test public void testSourceCounter() throws Exception { init("true"); doCounterCommon(); for (int i = 0; i < 10 && source.getSourceCounter().getEventAcceptedCount() == 0; i++) { Thread.sleep(100); } Assert.assertEquals(1, source.getSourceCounter().getEventAcceptedCount()); Assert.assertEquals(1, source.getSourceCounter().getEventReceivedCount()); }
@Test public void testSourceCounterChannelFail() throws Exception { init("true"); ChannelProcessor cp = Mockito.mock(ChannelProcessor.class); doThrow(new ChannelException("dummy")).when(cp).processEvent(any(Event.class)); source.setChannelProcessor(cp); doCounterCommon(); for (int i = 0; i < 10 && source.getSourceCounter().getChannelWriteFail() == 0; i++) { Thread.sleep(100); } Assert.assertEquals(1, source.getSourceCounter().getChannelWriteFail()); }
@Test public void testSourceCounterReadFail() throws Exception { init("true"); ChannelProcessor cp = Mockito.mock(ChannelProcessor.class); doThrow(new RuntimeException("dummy")).when(cp).processEvent(any(Event.class)); source.setChannelProcessor(cp); doCounterCommon(); for (int i = 0; i < 10 && source.getSourceCounter().getEventReadFail() == 0; i++) { Thread.sleep(100); } Assert.assertEquals(1, source.getSourceCounter().getEventReadFail()); }