xlawrence 2004/12/20 11:16:57 CET
Modified files:
src/java/org/jahia/suite/calendar/test
DummyCalendarServer.java
Log:
Added selection. The user can now test the MS-Outlook SyncSource or the
iCalendar SyncSource
Revision Changes Path
1.9 +55 -29
uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalendarServer.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalendarServer.java.diff?r1=1.8&r2=1.9&f=h
Index: DummyCalendarServer.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/test/DummyCalendarServer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DummyCalendarServer.java 17 Dec 2004 15:47:01 -0000 1.8
+++ DummyCalendarServer.java 20 Dec 2004 10:16:57 -0000 1.9
@@ -58,6 +58,8 @@
import org.apache.log4j.Logger;
+import javax.swing.JOptionPane;
+
/**
* This class simulates a calendar server. It contains a unique and simple
* calendar made of a small number of events. It will respond to any requests
@@ -74,15 +76,9 @@
private JMSAgent agent;
private Calendar calendar;
private DummyCalServerGUI gui;
+ private boolean outlook;
- private final String data0 =
-// "VERSION:2.0\n"+
-// "X-WR-CALNAME:UK Holidays\n"+
-// "PRODID:-//Apple Computer\\, Inc//iCal 1.5//EN\n"+
-// "X-WR-RELCALID:9DE52D32-D020-11D8-9530-000A958A3252\n"+
-// "X-WR-TIMEZONE:Europe/Paris\n"+
-// "CALSCALE:GREGORIAN\n"+
-// "METHOD:PUBLISH";
+ private final String contentOutlook =
"BEGIN:VEVENT\n"+
"DTSTART;VALUE=DATE:20041116\n"+
"DTEND;VALUE=DATE:20041116\n"+
@@ -91,6 +87,15 @@
"DTSTAMP:20040707T140415Z\n"+
"END:VEVENT";
+ private final String contentIcal =
+ "VERSION:2.0\n"+
+ "X-WR-CALNAME:UK Holidays\n"+
+ "PRODID:-//Apple Computer\\, Inc//iCal 1.5//EN\n"+
+ "X-WR-RELCALID:9DE52D32-D020-11D8-9530-000A958A3252\n"+
+ "X-WR-TIMEZONE:Europe/Paris\n"+
+ "CALSCALE:GREGORIAN\n"+
+ "METHOD:PUBLISH";
+
private final String data1 =
"BEGIN:VEVENT\n"+
"DTSTART;VALUE=DATE:20041116\n"+
@@ -118,12 +123,11 @@
"DTSTAMP:20040707T140415Z\n"+
"END:VEVENT";
- /**
- * Creates a new instance of SyncServerTest
+ /**
+ * Creates a new instance of SyncServerTest
*/
- public DummyCalendarServer() {
- System.setProperty("file.encoding", "ISO-8859-1");
- System.setProperty("string.encoding", "ISO-8859-1");
+ public DummyCalendarServer(boolean outlook) {
+ this.outlook = outlook;
agent = new JMSAgent(JMSAgent.CAL_SERVER_QUEUE,
"calServer", "calServer");
agent.start();
@@ -134,12 +138,13 @@
* Creates the calendar instance for the test
*/
public void start() {
+ final String data0 = fill();
try {
SyncEvent[] events = new SyncEvent[4];
- events[0] = new SyncEvent("key0", data0.getBytes("ISO-8859-1"),
SyncEvent.UNKNOWN);
- events[1] = new SyncEvent("key1", data1.getBytes("ISO-8859-1"),
SyncEvent.UNKNOWN);
- events[2] = new SyncEvent("key2", data2.getBytes("ISO-8859-1"),
SyncEvent.UNKNOWN);
- events[3] = new SyncEvent("key3", data3.getBytes("ISO-8859-1"),
SyncEvent.UNKNOWN);
+ events[0] = new SyncEvent("key0", data0.getBytes(),
SyncEvent.UNKNOWN);
+ events[1] = new SyncEvent("key1", data1.getBytes(),
SyncEvent.UNKNOWN);
+ events[2] = new SyncEvent("key2", data2.getBytes(),
SyncEvent.UNKNOWN);
+ events[3] = new SyncEvent("key3", data3.getBytes(),
SyncEvent.UNKNOWN);
calendar = new Calendar(events);
respID = 4;
} catch (Exception e) {
@@ -147,6 +152,13 @@
}
}
+ private String fill() {
+ if (outlook)
+ return contentOutlook;
+ else
+ return contentIcal;
+ }
+
/**
* @see MessageListener
*/
@@ -165,7 +177,7 @@
UpdateCalendarRequest req = (UpdateCalendarRequest)msg;
Response resp;
try {
- log.info("UpdateCalendarRequest:
"+req.getOperations().length+
+ log.info("UpdateCalendarRequest:
"+req.getOperations().length+
" operations");
SyncOperation[] ops = req.getOperations();
for (int i=0; i<ops.length; i++) {
@@ -207,11 +219,11 @@
}
}
- } catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
resp = req.makeResponse(newID(),
UpdateCalendarRequestResponse.FAILED);
agent.sendResponse(resp, req);
- log.error(e.getMessage());
+ log.error(e.getMessage());
}
// GetGUIDRequests
@@ -261,14 +273,28 @@
* @param args the command line arguments
*/
public static void main(String[] args) {
- log.info("Starting server...");
- DummyCalServerGUI.setLookAndFeel();
- DummyCalendarServer app = new DummyCalendarServer();
- app.start();
- app.gui = new DummyCalServerGUI(app);
- app.gui.pack();
- app.gui.setFrameLocation();
- app.gui.show();
- log.info("Waiting for requests...");
+ try {
+ boolean outlook = false;
+ log.info("Starting server...");
+ DummyCalServerGUI.setLookAndFeel();
+ if (JOptionPane.showConfirmDialog(null,
+ "Are you testing the MS-Outlook SyncSource ?\n\n" +
+ "Note: you cannot test the MS-Outlook SyncSource and the\n" +
+ "iCalandar SyncSource together !", "SyncSource Selection",
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
+ outlook = true;
+ }
+ DummyCalendarServer app = new DummyCalendarServer(outlook);
+ app.start();
+ app.gui = new DummyCalServerGUI(app);
+ app.gui.pack();
+ app.gui.setFrameLocation();
+ app.gui.show();
+ log.info("Waiting for requests...");
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(-1);
+ }
}
}