RequestRecord { @Override public String toString() { finish(); try { JSONComposer<String> jc = JSON.std.composeString(); ObjectComposer<JSONComposer<String>> oc = jc.startObject(); for (Entry<String, Value> value: fields.entrySet()) { oc.putObject(value.getKey(), value.getValue().getValue()); } return oc.end().finish(); } catch (Exception ex) { return "{}"; } } RequestRecord(String layerKey);  RequestRecord(String layerKey, Direction direction); Value addValue(String key, Value value); String addTag(String key, String tag); String addContextTag(String key, String tag); void resetContext(); long start(); long stop(); @Override String toString();  }
@Test public void testDefaults() throws JSONObjectException, IOException { String layer = "testDefaults"; rrec = new RequestRecord(layer); assertThat(getField(Fields.DIRECTION), is(Direction.IN.toString())); assertThat(getField(Fields.LAYER), is(layer)); assertThat(getField(Fields.RESPONSE_SIZE_B), is("-1")); assertThat(getField(Fields.REQUEST_SIZE_B), is("-1")); assertThat(getField(Fields.REQUEST_RECEIVED_AT), not(nullValue())); assertThat(getField(Fields.REQUEST_RECEIVED_AT), not(nullValue())); assertThat(Double.valueOf(getField(Fields.RESPONSE_TIME_MS)), greaterThan(new Double(0.0))); assertThat(getField(Fields.REQUEST), is(Defaults.UNKNOWN)); assertThat(getField(Fields.REMOTE_IP), is(Defaults.UNKNOWN)); assertThat(getField(Fields.REMOTE_HOST), is(Defaults.UNKNOWN)); assertThat(getField(Fields.PROTOCOL), is(Defaults.UNKNOWN)); assertThat(getField(Fields.METHOD), is(Defaults.UNKNOWN)); assertThat(getField(Fields.REMOTE_IP), is(Defaults.UNKNOWN)); assertThat(getField(Fields.REMOTE_HOST), is(Defaults.UNKNOWN)); assertThat(getField(Fields.RESPONSE_CONTENT_TYPE), is(Defaults.UNKNOWN)); assertThat(getField(Fields.REFERER), is(nullValue())); assertThat(getField(Fields.X_FORWARDED_FOR), is(nullValue())); assertThat(getField(Fields.REMOTE_PORT), is(nullValue())); }