use of io.fabric8.insight.log.LogEvent in project fabric8 by jboss-fuse.
the class ExceptionMavenCoordsTest method testQueryOfLogMessages.
@Test
public void testQueryOfLogMessages() throws Exception {
Logger testLog = LoggerFactory.getLogger("io.fabric8.insight.log.log4j.TestLogger");
// now lets force an exception with a stack trace from camel...
try {
CamelContextHelper.getMandatoryEndpoint(null, null);
} catch (Throwable e) {
testLog.error("Expected exception for testing: " + e, e);
}
// now lets find the error
LogResults results = logQuery.allLogResults();
List<LogEvent> logEvents = Log4jTest.assertNotEmpty(results);
LogEvent log = logEvents.get(0);
assertNotNull("Should have a log event", log);
List<String> list = Arrays.asList(log.getException());
assertTrue("Should have more than 1 items in the stack trace but got: " + list, list.size() > 1);
String first = list.get(1);
LOG.info("First line: " + first);
String expects = "[org.apache.camel:camel-core:";
assertTrue("Should have camel coordinate '" + expects + "' but got " + first, first.indexOf(expects) > 0);
for (String line : list) {
LOG.info(line);
}
}
Aggregations