@Test
public void testNullFromGetTransaction() {

  // channel which returns null from getTransaction()
  Channel ch = mock(Channel.class);
  when(ch.getTransaction()).thenReturn(null);
  ChannelSelector sel = new ReplicatingChannelSelector();
  sel.setChannels(Lists.newArrayList(ch));
  ChannelProcessor proc = new ChannelProcessor(sel);
  List<Event> events = Lists.newArrayList();
  events.add(EventBuilder.withBody("event 1", Charsets.UTF_8));
  boolean threw = false;
  try {
    proc.processEventBatch(events);
  } catch (NullPointerException ex) {
    threw = true;
    Assert.assertNotNull("NPE must be manually thrown", ex.getMessage());
  }
  Assert.assertTrue("Must throw NPE", threw);
}