LinuxSyslog5424ParserBase extends LinuxSyslogLineParser { @Override public Date toDate(String source, String s) { for (DateTimeFormatter fmt : dt_formatters) { try { final DateTime dt = fmt.withOffsetParsed().parseDateTime(s); m_dateTime = dt; return dt.toDate(); } catch (IllegalArgumentException e) { } } throw new IllegalArgumentException("Failed to parse date " + s); }  @Override Date toDate(String source, String s); @Override DateTime getLastDeterminedDateTime(); @Override boolean parseLine(String line); static final String RFC5424_TIMESTAMP; }
@Test(expected = IllegalArgumentException.class) public void testToDateWithEmptyStrings() { String s = ""; ls5424pb.toDate(source,s); }
@Test public void testToDateWithSecondPatternFormatter() { pattern = "1969-12-31T19:00:00-05:00"; assertEquals("Input time pattern is yyyy-MM-dd'T'H:m:sZ ",millisecondsOfDateWithOffset,ls5424pb.toDate(source,pattern)); }
@Test public void testToDateWithThirdPatternFormatter() { pattern = "1969-12-31T19:00:00-05:00"; assertEquals("Input time pattern is yyyy-MM-dd'T'H:m:s.SSSSSSZZ",millisecondsOfDateWithOffset,ls5424pb.toDate(source,pattern)); }
@Test public void testToDateWithFourthPatternFormatter() { pattern = "1969-12-31T19:00:00z"; assertEquals("Input time pattern is yyyy-MM-dd'T'H:m:sZZ ",millisecondsOfDateWithoutOffset,ls5424pb.toDate(source,pattern)); }