/** * Test loading of calendars. * * @throws IOException * @throws ParserException */ public void testLoad() throws IOException, ParserException { assertNotNull(Calendars.load(resource)); }
/** * @param filename * @return */ private net.fortuna.ical4j.model.Calendar loadCalendar(String resourceString) throws IOException, ParserException, ValidationException { net.fortuna.ical4j.model.Calendar calendar = Calendars.load( getClass().getResource(resourceString)); calendar.validate(); log.info("Resource: " + resourceString); if (log.isDebugEnabled()) { log.debug("Calendar:\n=========\n" + calendar.toString()); } return calendar; }
/** * Test loading of calendars. * * @throws IOException */ public void testLoadParserException() throws IOException { try { Calendars.load(resource); fail("Should throw ParserException"); } catch (ParserException pe) { LOG.info("Caught exception: " + pe.getMessage()); } }
/** * Test loading of calendars. * * @throws IOException * @throws ParserException */ public void testLoadFileNotFoundException() throws IOException, ParserException { try { Calendars.load(path); fail("Should throw FileNotFoundException"); } catch (NoSuchFileException fnfe) { LOG.info("Caught exception: " + fnfe.getMessage()); } }
public void testRelaxedParsing() throws IOException, ParserException { try { Calendars.load(getClass().getResource("/samples/invalid/groupwise.ics")); fail("Should throw URISyntaxException"); } catch (ParserException pe) { LOG.info("Caught exception: " + pe.getMessage()); } CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); Calendar calendar = Calendars.load(getClass().getResource("/samples/invalid/groupwise.ics")); Attendee attendee = (Attendee) calendar.getComponent(Component.VEVENT).getProperty(Property.ATTENDEE); assertNotNull(attendee.getCalAddress()); } }
/** * Test correct parsing of quoted text. * @throws IOException * @throws ParserException */ public void testQuotedText() throws IOException, ParserException { Calendar calendar = Calendars.load(getClass().getResource("/samples/valid/mansour.ics")); Component event = calendar.getComponent(Component.VEVENT); assertEquals("At \"The Terrace\" Complex > Melbourne \"\\,", event.getProperty(Property.LOCATION).getValue()); }
/** * @return * @throws ParserException * @throws IOException */ public static TestSuite suite() throws IOException, ParserException { TestSuite suite = new TestSuite(); // Test correct parsing of text with tabs. Calendar calendar = Calendars.load(DescriptionTest.class.getResource("/samples/valid/mansour.ics")); Component event = calendar.getComponent(Component.VEVENT); suite.addTest(new DescriptionTest(event .getProperty(Property.DESCRIPTION), "Test\t\ttabs")); return suite; } }
/** * @return * @throws ParserException * @throws IOException */ public static TestSuite suite() throws IOException, ParserException { TestSuite suite = new TestSuite(); //testQuotedText.. Calendar calendar = Calendars.load(LocationTest.class.getResource("/samples/valid/mansour.ics")); Component event = calendar.getComponent(Component.VEVENT); Location location = (Location) event.getProperty(Property.LOCATION); suite.addTest(new LocationTest(location, "At \"The Terrace\" Complex > Melbourne \"\\,")); return suite; } }
calendars.add(Calendars.load(CalendarsTest.class.getResource("/samples/valid/Australian32Holidays.ics"))); calendars.add(Calendars.load(CalendarsTest.class.getResource("/samples/valid/OZMovies.ics"))); suite.addTest(new CalendarsTest("testMerge", (Calendar[]) calendars.toArray(new Calendar[calendars.size()]))); Calendar calendar = Calendars.load(CalendarsTest.class.getResource("/samples/valid/Australian32Holidays.ics")); suite.addTest(new CalendarsTest("testSplit", calendar, 10)); calendar = Calendars.load(CalendarsTest.class.getResource("/samples/valid/OZMovies.ics")); suite.addTest(new CalendarsTest("testGetContentType", calendar, null, "text/calendar; method=PUBLISH")); suite.addTest(new CalendarsTest("testGetContentType", calendar, Charset.forName("US-ASCII"), "text/calendar; method=PUBLISH; charset=US-ASCII")); suite.addTest(new CalendarsTest("testShouldSerializeDeserializeCorrectly", Calendars.load(CalendarsTest.class.getResource("/samples/valid/Australian32Holidays.ics")), -1));
/** * Test the accuracy of parser exception line number. * * @throws IOException */ public void testParserException() throws IOException { try { Calendars.load(resource); fail("Should throw ParserException: [" + resource + "]"); } catch (ParserException pe) { LOG.info(pe.getMessage()); assertEquals(expectedErrorLineNo, pe.getLineNo()); } }
/** * @return * @throws ParserException * @throws IOException */ public static TestSuite suite() throws IOException, ParserException { TestSuite suite = new TestSuite(); // Test correct parsing of quoted text.. Calendar calendar = Calendars.load(SummaryTest.class.getResource("/samples/valid/mansour.ics")); Component event = calendar.getComponent(Component.VEVENT); Summary summary = (Summary) event.getProperty(Property.SUMMARY); suite.addTest(new SummaryTest(summary, "A colon with spaces on either side : like that")); suite.addTest(new SummaryTest("testValidation", summary)); suite.addTest(new SummaryTest("testEquals", summary)); return suite; } }
/** * Test method for {@link net.fortuna.ical4j.data.HCalendarParser#parse(java.io.Reader, net.fortuna.ical4j.data.ContentHandler)}. */ public void testParseReaderContentHandler() throws IOException, ParserException { Calendar icsCalendar = Calendars.load(getClass().getResource("/samples/hcalendar/example1.ics")); // remove prod-id which seems to be not handled by hcalendar.. icsCalendar.getProperties().remove(icsCalendar.getProperty(Property.PRODID)); CalendarBuilder builder = new CalendarBuilder(new HCalendarParser()); Calendar hcalCalendar = builder.build(getClass().getResourceAsStream("/samples/hcalendar/example1.html")); // assertEquals(icsCalendar, hcalCalendar); assertEquals(icsCalendar.getProperties().size(), hcalCalendar.getProperties().size()); assertEquals(icsCalendar.getComponents().size(), hcalCalendar.getComponents().size()); }
Calendar exCal = Calendars.load(PeriodRuleTest.class.getResource("/samples/valid/friday13.ics")); cal = java.util.Calendar.getInstance(); cal.set(1997, 8, 2, 9, 0, 0); exCal = Calendars.load(PeriodRuleTest.class.getResource("/samples/valid/friday13-NOT.ics")); cal = java.util.Calendar.getInstance(); cal.set(1997, 8, 2, 9, 0, 0); calendar = Calendars.load(PeriodRuleTest.class.getResource("/samples/valid/2207678.ics")); CompatibilityHints.clearHintEnabled(CompatibilityHints.KEY_RELAXED_UNFOLDING);
Calendar calendar = Calendars.load(CategoriesTest.class.getResource("/samples/valid/categories.ics")); Categories orig = (Categories) calendar.getComponent(Component.VEVENT) .getProperty(Property.CATEGORIES);
for (int i = 0; i < testFiles.length; i++) { log.info("Sample [" + testFiles[i] + "]"); net.fortuna.ical4j.model.Calendar calendar = Calendars.load(testFiles[i]); if (Method.PUBLISH.equals(calendar.getProperty(Property.METHOD))) { calendar.getComponents(Component.VEVENT).forEach(calendarComponent -> {