2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
5 package net
.bionicmessage
.funambol
.datakit
;
7 import com
.funambol
.common
.pim
.converter
.CalendarToSIFE
;
8 import com
.funambol
.common
.pim
.converter
.VCalendarContentConverter
;
9 import com
.funambol
.common
.pim
.converter
.VCalendarConverter
;
10 import com
.funambol
.common
.pim
.model
.VCalendar
;
12 import java
.io
.FileInputStream
;
13 import net
.fortuna
.ical4j
.data
.CalendarBuilder
;
14 import net
.fortuna
.ical4j
.model
.Calendar
;
15 import net
.fortuna
.ical4j
.model
.component
.CalendarComponent
;
16 import org
.junit
.After
;
17 import org
.junit
.AfterClass
;
18 import org
.junit
.Before
;
19 import org
.junit
.BeforeClass
;
20 import org
.junit
.Test
;
21 import static org
.junit
.Assert
.*;
27 public class ical4j2funambolTest
{
29 public ical4j2funambolTest() {
33 public static void setUpClass() throws Exception
{
37 public static void tearDownClass() throws Exception
{
45 public void tearDown() {
49 * Test of convertIcal4jToFunambolEvent method, of class ical4j2funambol.
52 public void convertIcal4jToFunambolEvent() throws Exception
{
53 File testFile
= new File("doc/problem-samples/ogo-allday.ics");
54 FileInputStream fis
= new FileInputStream(testFile
);
55 CalendarBuilder cbuild
= new CalendarBuilder();
56 Calendar cal
= cbuild
.build(fis
);
57 com
.funambol
.common
.pim
.calendar
.Calendar fnblcal
=
58 ical4j2funambol
.convertIcal4jToFunambolEvent(cal
, "text/x-vcalendar");
59 VCalendarConverter vcc
= new VCalendarConverter(null, "UTF-8");
60 VCalendar vc
= vcc
.calendar2vcalendar(fnblcal
, false);
61 String text
= vc
.toString();
62 System
.out
.println(text
);
66 /** Test attaching alarm
70 public void testAlarmDurationM15() throws Exception
{
71 File testFile
= new File("doc/testData/korganizer-15min-alarm.ics");
72 FileInputStream fis
= new FileInputStream(testFile
);
73 CalendarBuilder cbuild
= new CalendarBuilder();
74 Calendar cal
= cbuild
.build(fis
);
75 com
.funambol
.common
.pim
.calendar
.Calendar fnblcal
=
76 ical4j2funambol
.convertIcal4jToFunambolEvent(cal
, "text/x-vcalendar");
77 ical4j2funambol
.attachAlarm(fnblcal
.getCalendarContent(),
78 (CalendarComponent
)cal
.getComponents().get(0));
79 VCalendarConverter vcc
= new VCalendarConverter(null, "UTF-8");
80 VCalendar vc
= vcc
.calendar2vcalendar(fnblcal
, false);
81 String text
= vc
.toString();
82 System
.out
.println(text
);
86 * Test of attachAllDayDtEnd method, of class ical4j2funambol.
89 public void attachAllDayDtEnd() {
93 * Test of attachAllDayDtStart method, of class ical4j2funambol.
96 public void attachAllDayDtStart() {
99 public void testAttendees() throws Exception
{
100 File testFile
= new File("doc/testData/attendees.ics");
101 FileInputStream fis
= new FileInputStream(testFile
);
102 CalendarBuilder cbuild
= new CalendarBuilder();
103 Calendar cal
= cbuild
.build(fis
);
104 com
.funambol
.common
.pim
.calendar
.Calendar fnblcal
=
105 ical4j2funambol
.convertIcal4jToFunambolEvent(cal
, "text/x-vcalendar");
106 ical4j2funambol
.attachAlarm(fnblcal
.getCalendarContent(),
107 (CalendarComponent
)cal
.getComponents().get(0));
108 // No attendees under vcal. yet
109 CalendarToSIFE cale
= new CalendarToSIFE(null, "UTF-8");
110 String text
= (String
)cale
.convert(fnblcal
);
111 System
.out
.println(text
);
114 public void testRecurrence() throws Exception
{
115 File testFile
= new File("doc/testData/recur.ics");
116 FileInputStream fis
= new FileInputStream(testFile
);
117 CalendarBuilder cbuild
= new CalendarBuilder();
118 Calendar cal
= cbuild
.build(fis
);
119 com
.funambol
.common
.pim
.calendar
.Calendar fnblcal
=
120 ical4j2funambol
.convertIcal4jToFunambolEvent(cal
, "text/x-vcalendar");
121 ical4j2funambol
.attachAlarm(fnblcal
.getCalendarContent(),
122 (CalendarComponent
)cal
.getComponents().get(0));
123 // No attendees under vcal. yet
124 CalendarToSIFE cale
= new CalendarToSIFE(null, "UTF-8");
125 String text
= (String
)cale
.convert(fnblcal
);
126 System
.out
.println(text
);
128 VCalendarConverter vcc
= new VCalendarContentConverter(null, "UTF-8", false);
129 VCalendar vc
= vcc
.calendar2vcalendar(fnblcal
, false);
130 String vcal
= vc
.toString();
131 System
.out
.println(vcal
);
134 public void testQPDecode() throws Exception
{
135 File testFile
= new File("doc/testData/qp.ics");
136 FileInputStream fis
= new FileInputStream(testFile
);
137 CalendarBuilder cbuild
= new CalendarBuilder();
138 Calendar cal
= cbuild
.build(fis
);
139 com
.funambol
.common
.pim
.calendar
.Calendar fnblcal
=
140 ical4j2funambol
.convertIcal4jToFunambolEvent(cal
, "text/x-vcalendar");
142 VCalendarConverter vcc
= new VCalendarContentConverter(null, "UTF-8", false);
143 VCalendar vc
= vcc
.calendar2vcalendar(fnblcal
, true);
144 String vcal
= vc
.toString();
145 System
.out
.println(vcal
);
146 assertTrue(vcal
.contains("Test f=C3"));