LogRecordDateBolt extends AbstractLoggingBolt { void validateDateFormat() throws ConfigurationException { try { new SimpleDateFormat(dateFormat); } catch (IllegalArgumentException e) { logger.error("Bad date format {}", dateFormat); throw new ConfigurationException(e); } }  @Override void configure(Configuration conf); static final String DATE_FORMAT; static final String SAMPLE; }
@Test public void testValidateDateFormat() throws Exception { bolt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; bolt.validateDateFormat(); }
@Test public void testValidateDateFormatFail() throws Exception { bolt.dateFormat = "yyyy-MM-ddTHH:mm:ss.SSSXXX"; thrown.expect(ConfigurationException.class); bolt.validateDateFormat(); }