/** Test parsing of standard GELF message with additional fields. */ @Test public void testParseWithAdditionalData() throws Exception { GELFClientHandlerBase instance = new GELFClientHandlerBase(); instance.clientMessage = this.originalMessageWithAdditionalData; instance.parse(); GELFMessage message = instance.message; // There should be two additional data fields. assertEquals(message.getAdditionalData().size(), 2); // Test standard fields. assertEquals("something.", message.getShortMessage()); assertEquals("lol!", message.getFullMessage()); assertEquals("somehost", message.getHost()); assertEquals(2, message.getLevel()); assertEquals("example.php", message.getFile()); assertEquals(1337, message.getLine()); // Test additional fields. Map<String, String> additionalData = message.getAdditionalData(); assertEquals("yes", additionalData.get("s1")); assertEquals("yes, really", additionalData.get("s2")); }
/** Test parsing of standard GELF message with no additional fields. */ @Test public void testParseWithoutAdditionalData() throws Exception { GELFClientHandlerBase instance = new GELFClientHandlerBase(); instance.clientMessage = this.originalMessage; instance.parse(); GELFMessage message = instance.message; // There should be not additional data. assertEquals(message.getAdditionalData().size(), 0); // Test standard fields. assertEquals("something.", message.getShortMessage()); assertEquals("lol!", message.getFullMessage()); assertEquals("somehost", message.getHost()); assertEquals(2, message.getLevel()); assertEquals("example.php", message.getFile()); assertEquals(1337, message.getLine()); }