ICalBean extends AbstractEntity { public static ICalBean parse(Reader r, String characterSet) { return BEANS.get(ICalVCardHelper.class).parse(r, characterSet, BEANS.get(ICalBean.class)); }  static ICalBean parse(Reader r, String characterSet); void write(Writer w, String charset); byte[] toBytes(String charset);  }
@Test public void testParse() { ICalVCardHelper helper = BEANS.get(ICalVCardHelper.class); Date prodDate = BEANS.get(IDateProvider.class).currentMillis(); Date startDate = DateUtility.addDays(BEANS.get(IDateProvider.class).currentMillis(), 1); Date endDate = DateUtility.addHours(startDate, 2); String uid = "478bb47d-c9a7-43d2-a920-c5a8b952d478"; final String ical = "BEGIN:VCALENDAR\r\n" + "VERSION:2.1\r\n" + "PRODID;CHARSET=utf-8:prodid doe corporation\r\n" + "BEGIN:VEVENT\r\n" + "DTSTAMP;CHARSET=utf-8:" + helper.createDateTime(prodDate) + "\r\n" + "UID;CHARSET=utf-8:" + uid + "\r\n" + "DTSTART;CHARSET=utf-8:" + helper.createDateTime(startDate) + "\r\n" + "DTEND;CHARSET=utf-8:" + helper.createDateTime(endDate) + "\r\n" + "ORGANIZER;CHARSET=utf-8;CN=\"John Doe\":mailto:john@doe.mail.com\r\n" + "END:VEVENT\r\n" + "END:VCALENDAR\r\n"; ICalBean bean = ICalBean.parse(new StringReader(ical), "utf-8"); assertNotNull(bean.getProperty(ICalProperties.PROP_NAME_BEGIN)); assertNotNull(bean.getProperty(ICalProperties.PROP_NAME_VERSION)); assertNotNull(bean.getProperty(ICalProperties.PROP_NAME_PRODID)); assertNotNull(bean.getProperty(ICalProperties.PROP_NAME_DTSTAMP)); assertNotNull(bean.getProperty(ICalProperties.PROP_NAME_UID)); assertNotNull(bean.getProperty(ICalProperties.PROP_NAME_DTSTART)); assertNotNull(bean.getProperty(ICalProperties.PROP_NAME_DTEND)); assertNotNull(bean.getProperty(ICalProperties.PROP_NAME_ORGANIZER)); assertEquals(ICalProperties.PROP_VALUE_VERSION_2_1, bean.getProperty(ICalProperties.PROP_NAME_VERSION).getValue()); assertEquals("prodid doe corporation", bean.getProperty(ICalProperties.PROP_NAME_PRODID).getValue()); assertEquals(helper.createDateTime(prodDate), bean.getProperty(ICalProperties.PROP_NAME_DTSTAMP).getValue()); assertEquals(uid, bean.getProperty(ICalProperties.PROP_NAME_UID).getValue()); assertEquals(helper.createDateTime(startDate), bean.getProperty(ICalProperties.PROP_NAME_DTSTART).getValue()); assertEquals(helper.createDateTime(endDate), bean.getProperty(ICalProperties.PROP_NAME_DTEND).getValue()); assertEquals("mailto:john@doe.mail.com", bean.getProperty(ICalProperties.PROP_NAME_ORGANIZER).getValue()); assertEquals("John Doe", bean.getProperty(ICalProperties.PROP_NAME_ORGANIZER).getParameter(ICalProperties.PARAM_NAME_CN).getValue()); List<Property> beginProps = bean.getProperties(ICalProperties.PROP_NAME_BEGIN); assertNotNull(beginProps); assertEquals(ICalProperties.PROP_VALUE_ICALENDAR, beginProps.get(0).getValue()); assertEquals(ICalProperties.PROP_VALUE_VEVENT, beginProps.get(1).getValue()); List<Property> endProps = bean.getProperties(ICalProperties.PROP_NAME_END); assertNotNull(endProps); assertEquals(ICalProperties.PROP_VALUE_VEVENT, endProps.get(0).getValue()); assertEquals(ICalProperties.PROP_VALUE_ICALENDAR, endProps.get(1).getValue()); }