@Test
public void basicsAreIncluded() throws Exception {
final long timestamp = System.currentTimeMillis();
IAccessEvent event = mockBasicILoggingEvent();
when(event.getTimeStamp()).thenReturn(timestamp);
encoder.doEncode(event);
closeQuietly(outputStream);
JsonNode node = MAPPER.readTree(outputStream.toByteArray());
assertThat(node.get("@timestamp").textValue(), is(FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSSZZ").format
(timestamp)));
assertThat(node.get("@version").intValue(), is(1));
assertThat(node.get("@message").textValue(), is(String.format("%s - %s [%s] \"%s\" %s %s", event.getRemoteHost(), event.getRemoteUser(),
FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSSZZ").format
(event.getTimeStamp()), event.getRequestURL(), event.getStatusCode(),
event.getContentLength())));
assertThat(node.get("@fields.method").textValue(), is(event.getMethod()));
assertThat(node.get("@fields.protocol").textValue(), is(event.getProtocol()));
assertThat(node.get("@fields.status_code").asInt(), is(event.getStatusCode()));
assertThat(node.get("@fields.requested_url").textValue(), is(event.getRequestURL()));
assertThat(node.get("@fields.requested_uri").textValue(), is(event.getRequestURI()));
assertThat(node.get("@fields.remote_host").textValue(), is(event.getRemoteHost()));
assertThat(node.get("@fields.HOSTNAME").textValue(), is(event.getRemoteHost()));
assertThat(node.get("@fields.remote_user").textValue(), is(event.getRemoteUser()));
assertThat(node.get("@fields.content_length").asLong(), is(event.getContentLength()));
assertThat(node.get("@fields.elapsed_time").asLong(), is(event.getElapsedTime()));
}