JsonLayout extends JsonLayoutBase<IAccessEvent> { protected void addInt(String key, boolean field, int intValue, Map<String, Object> map) { if (field) { String statusCode = String.valueOf(intValue); map.put(key, statusCode); } } JsonLayout(); boolean isIncludeRemoteAddr(); void setIncludeRemoteAddr(boolean includeRemoteAddr); boolean isIncludeRemoteUser(); void setIncludeRemoteUser(boolean includeRemoteUser); boolean isIncludeRequestTime(); void setIncludeRequestTime(boolean includeRequestTime); boolean isIncludeRequestURI(); void setIncludeRequestURI(boolean includeRequestURI); boolean isIncludeStatusCode(); void setIncludeStatusCode(boolean includeStatusCode); boolean isIncludeMethod(); void setIncludeMethod(boolean includeMethod); boolean isIncludeProtocol(); void setIncludeProtocol(boolean includeProtocol); boolean isIncludeContentLength(); void setIncludeContentLength(boolean includeContentLength); boolean isIncludeRequestURL(); void setIncludeRequestURL(boolean includeRequestURL); boolean isIncludeRemoteHost(); void setIncludeRemoteHost(boolean includeRemoteHost); boolean isIncludeServerName(); void setIncludeServerName(boolean includeServerName); boolean isIncludeRequestHeader(); void setIncludeRequestHeader(boolean includeRequestHeader); boolean isIncludeRequestParameter(); void setIncludeRequestParameter(boolean includeRequestParameter); boolean isIncludeLocalPort(); void setIncludeLocalPort(boolean includeLocalPort); boolean isIncludeRequestContent(); void setIncludeRequestContent(boolean includeRequestContent); boolean isIncludeResponseContent(); void setIncludeResponseContent(boolean includeResponseContent); static final String TIMESTAMP_ATTR_NAME; static final String REMOTEADDR_ATTR_NAME; static final String REMOTEUSER_ATTR_NAME; static final String REQUESTTIME_ATTR_NAME; static final String REQUESTURI_ATTR_NAME; static final String STATUSCODE_ATTR_NAME; static final String METHOD_ATTR_NAME; static final String PROTOCOL_ATTR_NAME; static final String CONTENTLENGTH_ATTR_NAME; static final String REQUESTURL_ATTR_NAME; static final String REMOTEHOST_ATTR_NAME; static final String SERVERNAME_ATTR_NAME; static final String REQUESTHEADER_ATTR_NAME; static final String REQUESTPARAMETER_ATTR_NAME; static final String LOCALPORT_ATTR_NAME; static final String REQUESTCONTENT_ATTR_NAME; static final String RESPONSECONTENT_ATTR_NAME; }
@Test public void addIntToJsonMap() throws Exception { Map<String, Object> map = new LinkedHashMap<String, Object>(); JsonLayout jsonLayout = new JsonLayout(); jsonLayout.addInt("key1", true, 1, map); jsonLayout.addInt("key2", false, 1, map); jsonLayout.addInt("key3", true, -1, map); assertThat(map.size(), is(2)); assertThat(map, hasKey("key1")); assertEquals(map.get("key1"), "1"); assertThat(map, not(hasKey("key2"))); assertThat(map, hasKey("key3")); assertEquals(map.get("key3"), "-1"); }