public void testBasicParsing() {
final List<LogEntry> list = new LinkedList<LogEntry>();
try {
loadLogFile("server.10-11-09.log.txt");
createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
APatternDialect dialect = (APatternDialect) getLogResource().getDialect();
ILogEntryCollector coll = new ALogEntryCollector(null) {
/* (non-Javadoc)
* @see net.sf.logsaw.core.framework.support.ALogEntryCollector#doCollect(net.sf.logsaw.core.model.LogEntry)
*/
@Override
protected boolean doCollect(LogEntry entry) throws IOException {
list.add(entry);
return true;
}
};
try {
getLogResource().synchronize(coll, null);
fail("Should throw exception because it is not configured");
} catch (AssertionFailedException e) {
// should be configured
}
dialect.configure(APatternDialect.OPTION_PATTERN, "%d %-5p [%c] (%t) %m%n");
getLogResource().synchronize(coll, null);
assertEquals(4, list.size());
assertEquals(4, coll.getTotalCollected());
assertEquals("INFO", list.get(1).get(Log4JFieldProvider.FIELD_LEVEL).getName());