Skip to content

Commit

Permalink
Test code provided by Armin Novak
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin Novak authored and benfortuna committed Jul 8, 2019
1 parent 58c87ac commit b1cf42a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/test/java/net/fortuna/ical4j/model/property/ExDateTest.java
Expand Up @@ -31,21 +31,17 @@
*/
package net.fortuna.ical4j.model.property;

import java.text.ParseException;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import junit.framework.TestCase;
import net.fortuna.ical4j.data.CalendarBuilder;
import net.fortuna.ical4j.model.Calendar;
import net.fortuna.ical4j.model.Component;
import net.fortuna.ical4j.model.Date;
import net.fortuna.ical4j.model.DateTime;
import net.fortuna.ical4j.model.ParameterList;
import net.fortuna.ical4j.model.Property;
import net.fortuna.ical4j.model.*;
import net.fortuna.ical4j.model.component.VEvent;
import net.fortuna.ical4j.model.component.VTimeZone;
import net.fortuna.ical4j.util.CompatibilityHints;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.ParseException;
import java.util.List;

/**
* $Id$
Expand Down Expand Up @@ -90,7 +86,22 @@ public void testTimeZones() throws Exception {
}
}


public void testDstOnlyVTimeZones() throws Exception {
CalendarBuilder builder = new CalendarBuilder();

Calendar ical = builder.build(getClass().getResourceAsStream("/samples/valid/dst-only-vtimezone.ics"));
VTimeZone vTZ = (VTimeZone) ical.getComponent(VTimeZone.VTIMEZONE);

String id = vTZ.getTimeZoneId().getValue();
assertEquals("Europe/Berlin", id);
assertEquals(vTZ.getObservances().get(0), vTZ.getApplicableObservance(new Date("20180403")));

VEvent vEvent = (VEvent) ical.getComponent(VEvent.VEVENT);
DtStart start = vEvent.getStartDate();
assertEquals(vTZ, start.getTimeZone().getVTimeZone());
assertEquals(1522738800000L, start.getDate().getTime());
}

public void testShouldPreserveUtcTimezoneForExDate() throws Exception {
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(getClass().getResourceAsStream("/samples/valid/EXDATE-IN-UTC.ics"));
Expand Down
21 changes: 21 additions & 0 deletions src/test/resources/samples/valid/dst-only-vtimezone.ics
@@ -0,0 +1,21 @@
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:20180325T030000
TZNAME:CEST
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:only-dst@example.com
DTSTAMP:20180329T084939Z
DTSTART;TZID=Europe/Berlin:20180403T090000
DTEND;TZID=Europe/Berlin:20180403T101500
SUMMARY:Sample Event
CREATED:20180329T084939Z
LAST-MODIFIED:20180329T084939Z
END:VEVENT
END:VCALENDAR

0 comments on commit b1cf42a

Please sign in to comment.