Search in sources :

Example 6 with ParserTypes

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));
    }
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) ParserTypes(alma.acs.logging.engine.parser.ACSLogParserFactory.ParserTypes) IsoDateFormat(alma.acs.util.IsoDateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

ParserTypes (alma.acs.logging.engine.parser.ACSLogParserFactory.ParserTypes)6 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)5 AdditionalData (com.cosylab.logging.engine.log.ILogEntry.AdditionalData)3 ACSLogParser (alma.acs.logging.engine.parser.ACSLogParser)2 XMLConverter (alma.acs.logging.tools.XMLConverter)1 IsoDateFormat (alma.acs.util.IsoDateFormat)1 LogField (com.cosylab.logging.engine.log.LogField)1 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1