Skip to content

Commit

Permalink
Refactored test data
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Oct 6, 2016
1 parent 7328d41 commit 7bf5c49
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 42 deletions.
9 changes: 4 additions & 5 deletions src/main/java/net/fortuna/ical4j/model/Component.java
Expand Up @@ -191,16 +191,15 @@ public final Property getProperty(final String name) {
}

/**
* Convenience method for retrieving a named property.
* Convenience method for retrieving a required named property.
*
* @param name name of the property to retrieve
* @param optional flag to indicate whether an exception should be thrown for missing property
* @return the first matching property in the property list with the specified name
* @throws ConstraintViolationException when a property is not found and the optional flag is false
* @throws ConstraintViolationException when a property is not found
*/
protected final Property getProperty(String name, boolean optional) throws ConstraintViolationException {
protected final Property getRequiredProperty(String name) throws ConstraintViolationException {
Property p = getProperties().getProperty(name);
if (p == null && !optional) {
if (p == null) {
throw new ConstraintViolationException(String.format("Missing %s property", name));
}
return p;
Expand Down
Expand Up @@ -155,7 +155,7 @@ public final Date getLatestOnset(final Date date) {

if (initialOnset == null) {
try {
DtStart dtStart = (DtStart) getProperty(Property.DTSTART, false);
DtStart dtStart = (DtStart) getRequiredProperty(Property.DTSTART);
initialOnset = applyOffsetFrom(calculateOnset(dtStart.getDate()));
} catch (ParseException e) {
Logger log = LoggerFactory.getLogger(Observance.class);
Expand Down
Expand Up @@ -13,42 +13,7 @@ class CalendarBuilderSpec extends Specification {

def 'test relaxed parsing'() {
given: 'a calendar object string'
String cal2 = '''BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//xxxx//xxxxxx//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:(GMT-03:00)
BEGIN:STANDARD
DTSTART:16010101T230000
TZOFFSETFROM:-0200
TZOFFSETTO:-0300
RRULE:FREQ=YEARLY;BYMONTH=2;BYDAY=3SU
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:-0300
TZOFFSETTO:-0200
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=4SU
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:1047216278.801463535396580.JavaMail.root(a)xxxx.xxxxx.xxxx
LAST-MODIFIED:20160519T090547Z
DTSTAMP:20160519T090547Z
DTSTART;TZID="(GMT-03:00)":20160518T123000
DTEND;TZID="(GMT-03:00)":20160518T133000
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
PRIORITY:5
TRANSP:OPAQUE
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
SEQUENCE:0
SUMMARY:xxxxxxx S-xxxxx
X-SCALIX-LABEL:0
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
'''
String cal2 = getClass().getResource('test-relaxed-parsing.ics').text

and: 'relaxed parsing is enabled'
CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_UNFOLDING, true)
Expand Down
@@ -0,0 +1,35 @@
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//xxxx//xxxxxx//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:(GMT-03:00)
BEGIN:STANDARD
DTSTART:16010101T230000
TZOFFSETFROM:-0200
TZOFFSETTO:-0300
RRULE:FREQ=YEARLY;BYMONTH=2;BYDAY=3SU
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:-0300
TZOFFSETTO:-0200
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=4SU
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:1047216278.801463535396580.JavaMail.root(a)xxxx.xxxxx.xxxx
LAST-MODIFIED:20160519T090547Z
DTSTAMP:20160519T090547Z
DTSTART;TZID="(GMT-03:00)":20160518T123000
DTEND;TZID="(GMT-03:00)":20160518T133000
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
PRIORITY:5
TRANSP:OPAQUE
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
SEQUENCE:0
SUMMARY:xxxxxxx S-xxxxx
X-SCALIX-LABEL:0
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR

0 comments on commit 7bf5c49

Please sign in to comment.