use of alma.acs.logging.engine.parser.ACSLogParserFactory.ParserTypes in project ACS by ACS-Community.
the class ACSLogParserTest method testFields.
/**
* Check if the fields are read as expected
*
* @throws Exception
*/
public void testFields() throws Exception {
// Cycle through all available parsers
for (ParserTypes type : ParserTypes.values()) {
System.out.println("testFields: Testing parser " + type);
parser = ACSLogParserFactory.getParser(type);
assertNotNull(parser);
assertEquals(type, ACSLogParserFactory.getParserType(parser));
ILogEntry log = parser.parse(xmlLogInfo1);
assertNotNull(log);
// Check the date
Long logDate = (Long) log.getField(LogField.TIMESTAMP);
assertNotNull(logDate);
Long xmlDate = null;
SimpleDateFormat dateFormat = new IsoDateFormat();
Date date = dateFormat.parse("2006-03-28T00:26:29.238");
xmlDate = Long.valueOf(date.getTime());
assertEquals("The dates differ", xmlDate, logDate);
// Check the log type
assertEquals(LogTypeHelper.INFO, (LogTypeHelper) log.getField(LogField.ENTRYTYPE));
// Check the file
assertEquals("maciContainerImpl.cpp", log.getField(LogField.FILE));
// Check the line
assertEquals(Integer.valueOf(1454), log.getField(LogField.LINE));
// Check the routine
assertEquals("maci::ContainerImpl::initThread", log.getField(LogField.ROUTINE));
// Check the host
assertEquals("gas", log.getField(LogField.HOST));
// Check the process
assertEquals("maciContainer", log.getField(LogField.PROCESS));
// Check the thread
assertEquals("ARCHIVE_BULKSENDER::actionThread", log.getField(LogField.THREAD));
// Check the Antenna
assertEquals("CTXT", log.getField(LogField.CONTEXT));
// Check the source object
assertEquals("ARCHIVE_BULKSENDER::source", log.getField(LogField.SOURCEOBJECT));
// Check the stack level
assertEquals(10, log.getField(LogField.STACKLEVEL));
// Check the stack level
assertEquals(3, log.getField(LogField.PRIORITY));
// Check the stack level
assertEquals("TheStackID", log.getField(LogField.STACKID));
// Check the Audience
assertEquals("Operator", log.getField(LogField.AUDIENCE));
// Check the Array
assertEquals("AnArray", log.getField(LogField.ARRAY));
// Check the Antenna
assertEquals("ThisIsTheAntenna", log.getField(LogField.ANTENNA));
}
}
Aggregations