@Test
public void testErrorCounterChannelWriteFail() throws Exception {

  MultiportSyslogTCPSource source = new MultiportSyslogTCPSource();
  Channel channel = new MemoryChannel();
  List<Event> channelEvents = new ArrayList<>();
  ChannelProcessor cp = Mockito.mock(ChannelProcessor.class);
  doThrow(new ChannelException("dummy")).doNothing().when(cp)
      .processEventBatch(anyListOf(Event.class));
  try {
    testNPorts(source, channel, channelEvents, 1, cp,
        getSimpleEventSender(), new Context());
  } catch (Exception e) {
    //
  }
  SourceCounter sc = (SourceCounter) Whitebox.getInternalState(source, "sourceCounter");
  Assert.assertEquals(1, sc.getChannelWriteFail());
  source.stop();
}