AvroEventConvertUtil { public static Event toFlumeEvent(AvroFlumeEvent evt) { return toFlumeEvent(evt, false); } private  AvroEventConvertUtil(); static Event toFlumeEvent(AvroFlumeEvent evt); static Event toFlumeEvent(AvroFlumeEvent evt, boolean truncates); static AvroFlumeEvent toAvroEvent(Event e); static final Logger LOG; }
@Test public void testNullBody() { AvroFlumeEvent tEvt = new AvroFlumeEvent(); Assert.assertEquals(null, tEvt.body); Assert .assertEquals(0, AvroEventConvertUtil.toFlumeEvent(tEvt).getBody().length); }
@Test(expected = RuntimeException.class) public void testEvilEvent() { long maxSize = FlumeConfiguration.get().getEventMaxSizeBytes(); ByteBuffer toobig = ByteBuffer.allocate((int) (maxSize * 2)); AvroFlumeEvent tevt = new AvroFlumeEvent(); tevt.timestamp = 0L; tevt.priority = Priority.INFO; tevt.body = toobig; tevt.nanos = 0L; tevt.host = "localhost"; tevt.fields = new HashMap<CharSequence, ByteBuffer>(); Event e = AvroEventConvertUtil.toFlumeEvent(tevt); EventImpl.select(e); }
@Test public void testTruncEvilEvent() { long maxSize = FlumeConfiguration.get().getEventMaxSizeBytes(); ByteBuffer toobig = ByteBuffer.allocate((int) (maxSize * 2)); AvroFlumeEvent tevt = new AvroFlumeEvent(); tevt.timestamp = 0L; tevt.priority = Priority.INFO; tevt.body = toobig; tevt.nanos = 0L; tevt.host = "localhost"; tevt.fields = new HashMap<CharSequence, ByteBuffer>(); Event e = AvroEventConvertUtil.toFlumeEvent(tevt, true); EventImpl.select(e); }