public void testEventLogger() {
EventData data[] = new EventData[2];
data[0] = new EventData();
data[0].setEventType("Login");
data[0].setEventId("1");
data[0].setEventDateTime(new Date());
data[0].put("Userid", "TestUser");
EventLogger.logEvent(data[0]);
data[1] = new EventData();
data[1].setEventType("Update");
data[1].setEventId("2");
data[1].setEventDateTime(new Date());
data[1].put("FileName", "/etc/hosts");
EventLogger.logEvent(data[1]);
assertEquals(2, listAppender.list.size());
for (int i = 0; i < 2; ++i) {
LoggingEvent event = listAppender.list.get(i);
verify(event, data[i].toXML());
LocationInfo li = event.getLocationInformation();
assertEquals(this.getClass().getName(), li.getClassName());
assertEquals(event.getMDC("hostname"), "localhost");
}
}
EventLoggerTest.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:bartleby
作者:
评论列表
文章目录