Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=I contain \\\" double quotes\"", event.toString());
}
@Test
public void addThrowableWorks() {
SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
try {
throw new Exception("This is a test of the Java emergency broadcast system.");
} catch (Exception e) {
event.addThrowableWithStacktrace(e);
}
String expectedString = "\"name=name\" \"event_id=event-id\" " +
"\"throwable_class=java.lang.Exception\" \"throwable_message=This is a test of the Java " +
"emergency broadcast system.\" \"stacktrace_elements=SplunkCimLogEventUnitTest." +
"addThrowableWorks(SplunkCimLogEventUnitTest.java:???),";
String foundString = event.toString();
foundString = foundString.replaceAll(":\\d+\\)", ":???)"); // Get rid of line numbers.
Assert.assertEquals(expectedString, foundString.substring(0, expectedString.length()));
}