/** * Transforms the specified component according to the transformer implementation. * @param component a component to transform * @return a calendar containing the transformed component */ public final Calendar transform(final CalendarComponent component) { return transform(Calendars.wrap(component)); } }
/** * */ public void testGetContentType() { assertEquals(expectedContentType, Calendars.getContentType(calendar, charset)); }
/** * Test loading of calendars. * * @throws IOException * @throws ParserException */ public void testLoad() throws IOException, ParserException { assertNotNull(Calendars.load(resource)); }
/** * Test calendar split. */ public void testSplit() throws IOException, ParserException { Calendar[] split = Calendars.split(calendar); assertEquals(expectedCount, split.length); }
/** * Test merging of calendars. */ public void testMerge() throws IOException, ParserException { Calendar result = calendars[0]; for (int i = 1; i < calendars.length; i++) { result = Calendars.merge(result, calendars[i]); } for (int i = 0; i < calendars.length; i++) { for (Property p : calendars[i].getProperties()) { assertTrue("Property [" + p + "] not found in merged calendar", result.getProperties().contains(p)); } for (Component c : calendars[i].getComponents()) { assertTrue("Component [" + c + "] not found in merged calendar", result.getComponents().contains(c)); } } }
/** * Transforms the specified component according to the transformer implementation. * @param component a component to transform * @return a calendar containing the transformed component */ public final Calendar transform(final CalendarComponent component) { return transform(Calendars.wrap(component)); } }
/** * @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; }
/** * Transforms the specified component according to the transformer implementation. * @param component a component to transform * @return a calendar containing the transformed component */ public final Calendar transform(final Component component) { return transform(Calendars.wrap(component)); } }
/** * 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()); } }
@SafeVarargs protected final Calendar wrap(Method method, T... component) { Calendar calendar = Calendars.wrap(component); calendar.getProperties().add(prodId); calendar.getProperties().add(Version.VERSION_2_0); return transform(method, calendar); }
/** * 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()); } }
@SafeVarargs protected final Calendar wrap(Method method, T... component) { Calendar calendar = Calendars.wrap(component); calendar.getProperties().add(prodId); calendar.getProperties().add(Version.VERSION_2_0); return transform(method, calendar); }
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()); }