Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracUtils.java22
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracOfflineTaskHandlerTest.java48
2 files changed, 35 insertions, 35 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracUtils.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracUtils.java
index be7b91c55..7358134db 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracUtils.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracUtils.java
@@ -8,11 +8,7 @@
package org.eclipse.mylar.internal.trac.core.util;
-import java.util.Calendar;
import java.util.Date;
-import java.util.TimeZone;
-
-import org.eclipse.mylar.internal.trac.core.ITracClient;
/**
* Provides static helper methods.
@@ -22,17 +18,19 @@ import org.eclipse.mylar.internal.trac.core.ITracClient;
public class TracUtils {
public static Date parseDate(long seconds) {
- Calendar c = Calendar.getInstance();
- c.setTimeZone(TimeZone.getTimeZone(ITracClient.TIME_ZONE));
- c.setTimeInMillis(seconds * 1000l);
- return c.getTime();
+ return new Date(seconds * 1000l);
+// Calendar c = Calendar.getInstance();
+// c.setTimeZone(TimeZone.getTimeZone(ITracClient.TIME_ZONE));
+// c.setTimeInMillis(seconds * 1000l);
+// return c.getTime();
}
public static long toTracTime(Date date) {
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- c.setTimeZone(TimeZone.getTimeZone(ITracClient.TIME_ZONE));
- return c.getTimeInMillis() / 1000l;
+// Calendar c = Calendar.getInstance();
+// c.setTime(date);
+// c.setTimeZone(TimeZone.getTimeZone(ITracClient.TIME_ZONE));
+// return c.getTimeInMillis() / 1000l;
+ return date.getTime() / 1000l;
}
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracOfflineTaskHandlerTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracOfflineTaskHandlerTest.java
index b28748999..434713d7c 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracOfflineTaskHandlerTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracOfflineTaskHandlerTest.java
@@ -22,6 +22,8 @@ import org.eclipse.mylar.core.core.tests.support.MylarTestUtils.PrivilegeLevel;
import org.eclipse.mylar.internal.trac.core.ITracClient;
import org.eclipse.mylar.internal.trac.core.TracCorePlugin;
import org.eclipse.mylar.internal.trac.core.ITracClient.Version;
+import org.eclipse.mylar.internal.trac.core.model.TracTicket;
+import org.eclipse.mylar.internal.trac.core.model.TracTicket.Key;
import org.eclipse.mylar.internal.trac.ui.TracRepositoryConnector;
import org.eclipse.mylar.internal.trac.ui.TracTask;
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
@@ -97,7 +99,7 @@ public class TracOfflineTaskHandlerTest extends TestCase {
init(Constants.TEST_TRAC_010_URL, Version.XML_RPC);
TracTask task = (TracTask) connector.createTaskFromExistingKey(repository, data.offlineHandlerTicketId + "");
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
-// int lastModified = Integer.parseInt(task.getTaskData().getLastModified());
+ int lastModified = Integer.parseInt(task.getTaskData().getLastModified());
Set<AbstractRepositoryTask> tasks = new HashSet<AbstractRepositoryTask>();
tasks.add(task);
@@ -107,28 +109,28 @@ public class TracOfflineTaskHandlerTest extends TestCase {
assertEquals(tasks, result);
// always returns the ticket because time comparison mode is >=
-// repository.setSyncTimeStamp(lastModified + "");
-// result = offlineHandler.getChangedSinceLastSync(repository, tasks);
-// assertEquals(tasks, result);
-//
-// repository.setSyncTimeStamp((lastModified + 1) + "");
-// result = offlineHandler.getChangedSinceLastSync(repository, tasks);
-// assertTrue(result.isEmpty());
-//
-// // change ticket making sure it gets a new change time
-// Thread.currentThread().wait(1000);
-// ITracClient client = connector.getClientManager().getRepository(repository);
-// TracTicket ticket = client.getTicket(data.offlineHandlerTicketId);
-// if (ticket.getValue(Key.DESCRIPTION).equals(lastModified + "")) {
-// ticket.putBuiltinValue(Key.DESCRIPTION, lastModified + "x");
-// } else {
-// ticket.putBuiltinValue(Key.DESCRIPTION, lastModified + "");
-// }
-// client.updateTicket(ticket, "comment");
-//
-// repository.setSyncTimeStamp((lastModified + 1) + "");
-// result = offlineHandler.getChangedSinceLastSync(repository, tasks);
-// assertEquals(tasks, result);
+ repository.setSyncTimeStamp(lastModified + "");
+ result = offlineHandler.getChangedSinceLastSync(repository, tasks);
+ assertEquals(tasks, result);
+
+ repository.setSyncTimeStamp((lastModified + 1) + "");
+ result = offlineHandler.getChangedSinceLastSync(repository, tasks);
+ assertTrue(result.isEmpty());
+
+ // change ticket making sure it gets a new change time
+ Thread.sleep(1000);
+ ITracClient client = connector.getClientManager().getRepository(repository);
+ TracTicket ticket = client.getTicket(data.offlineHandlerTicketId);
+ if (ticket.getValue(Key.DESCRIPTION).equals(lastModified + "")) {
+ ticket.putBuiltinValue(Key.DESCRIPTION, lastModified + "x");
+ } else {
+ ticket.putBuiltinValue(Key.DESCRIPTION, lastModified + "");
+ }
+ client.updateTicket(ticket, "comment");
+
+ repository.setSyncTimeStamp((lastModified + 1) + "");
+ result = offlineHandler.getChangedSinceLastSync(repository, tasks);
+ assertEquals(tasks, result);
}
}

Back to the top