@Test public void testParseHeaderDelegate() throws ParseException { RuntimeDelegate rd = RuntimeDelegate.getInstance(); HeaderDelegate<Date> dateHeaderDelegate = rd.createHeaderDelegate(Date.class); if (dateHeaderDelegate == null) { fail("Date header delegate is not regestered in RuntimeDelegateImpl"); } SimpleDateFormat dateFormat = new SimpleDateFormat(RFC1123_DATE_FORMAT_PATTERN, Locale.US); Date expectedDate = dateFormat.parse(RFC1123_DATE); Date parsedDate = null; try { parsedDate = dateHeaderDelegate.fromString(RFC1123_DATE); assertEquals(expectedDate, parsedDate); } catch (Exception e) { fail("Failed to parse date " + RFC1123_DATE); } try { dateHeaderDelegate.fromString(RFC1036_DATE); assertEquals(expectedDate, parsedDate); } catch (Exception e) { fail("Failed to parse date " + RFC1036_DATE); } try { dateHeaderDelegate.fromString(ANSI_C_ASCTIME_DATE); assertEquals(expectedDate, parsedDate); } catch (Exception e) { fail("Failed to parse date " + ANSI_C_ASCTIME_DATE); } try { dateHeaderDelegate.fromString("Sundayy Nov 6 08:49:37 1994"); fail("Invalid date - IllegalArgumentException must be thrown"); } catch (IllegalArgumentException e) { } try { dateHeaderDelegate.fromString(null); fail("Date is null- IllegalArgumentException must be thrown"); } catch (IllegalArgumentException e) { } }
public Date fromString(String date) throws IllegalArgumentException { if (date == null) { throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "date")); } return HttpDateParser.parseHttpDate(date); }
DateHeaderDelegate implements HeaderDelegate<Date> { public Date fromString(String date) throws IllegalArgumentException { if (date == null) { throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "date")); } return HttpDateParser.parseHttpDate(date); } }
DateHeaderDelegate implements HeaderDelegate<Date> { public Date fromString(String date) throws IllegalArgumentException { if (date == null) { throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "date")); } return HttpDateParser.parseHttpDate(date); }  }
DateHeaderDelegate implements HeaderDelegate<Date> { public Date fromString(String date) throws IllegalArgumentException { if (date == null) { throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "date")); } return HttpDateParser.parseHttpDate(date); }  Date fromString(String date); String toString(Date date); }
DateHeaderDelegate implements HeaderDelegate<Date> { public Date fromString(String date) throws IllegalArgumentException { if (date == null) { throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "date")); } return HttpDateParser.parseHttpDate(date); }  Date fromString(String date); String toString(Date date);  }