@Test
  public void testAvroNativeJson() throws IOException {
    AvroNativeFileOutputFormat format = new AvroNativeFileOutputFormat();
    ByteArrayOutputStream sos = new ByteArrayOutputStream();
    format.format(sos, e);
    format.close();
    byte[] bytes = sos.toByteArray();

    ReflectData reflectData = ReflectData.get();
    Schema schema = reflectData.getSchema(EventImpl.class);
    ReflectDatumReader<EventImpl> dr = new ReflectDatumReader<EventImpl>(schema);
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    DataFileStream<EventImpl> dec = new DataFileStream<EventImpl>(bais, dr);

    Event er = dec.next();
    assertEquals(e.getHost(), er.getHost());
    assertEquals(e.getNanos(), er.getNanos());
    assertEquals(e.getPriority(), er.getPriority());
    assertTrue(Arrays.equals(e.getBody(), er.getBody()));
  }
 private String format(Event e) {
   Date d = new Date(e.getTimestamp());
   String data =
       String.format(
           "%s %s %s: %s\n",
           DateUtils.asISO8601(d),
           e.getPriority(),
           "log4j",
           StringEscapeUtils.escapeJava(new String(e.getBody())));
   return data;
 }
  @Override
  public void append(Event e) throws IOException, InterruptedException {
    String helloWorldBody = "Hello World! -- " + new String(e.getBody());

    // make a copy of the event, but with the new body string.
    EventImpl e2 =
        new EventImpl(
            helloWorldBody.getBytes(),
            e.getTimestamp(),
            e.getPriority(),
            e.getNanos(),
            e.getHost(),
            e.getAttrs());

    super.append(e2);
  }
  private void assertCorrectResponse(int count, Event event, SearchResponse response) {
    SearchHits hits = response.getHits();

    assertEquals(count, hits.getTotalHits());

    SearchHit hit = hits.getAt(0);

    Map<String, Object> source = hit.getSource();

    assertEquals(event.getHost(), source.get("host"));
    assertEquals("1970-01-01T00:00:00.000Z", source.get("timestamp"));
    assertEquals(event.getPriority().name(), source.get("priority"));

    @SuppressWarnings("unchecked")
    Map<String, Object> message = (Map<String, Object>) source.get("message");
    assertEquals(new String(event.getBody()), message.get("text"));

    @SuppressWarnings("unchecked")
    Map<String, Object> fields = (Map<String, Object>) source.get("fields");

    assertEquals(new String(event.getAttrs().get("attr1")), fields.get("attr1"));
    assertEquals(new String(event.getAttrs().get("attr2")), fields.get("attr2"));
  }