summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2013-05-03 10:36:37 (EDT)
committerSteffen Pingel2013-05-03 10:36:37 (EDT)
commit2dc5856cb4a08832727818afd88cd809b29ff295 (patch)
tree41f989aa482b9c75d9238180758c7e039f8396b4
parentaf505574701f1e70b64d892666dac6f4cffe9945 (diff)
downloadorg.eclipse.mylyn.tasks-2dc5856cb4a08832727818afd88cd809b29ff295.zip
org.eclipse.mylyn.tasks-2dc5856cb4a08832727818afd88cd809b29ff295.tar.gz
org.eclipse.mylyn.tasks-2dc5856cb4a08832727818afd88cd809b29ff295.tar.bz2
cancel synchronization job after completing testrefs/changes/91/12491/1
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListSynchronizationSchedulerTest.java22
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListSynchronizationScheduler.java5
2 files changed, 18 insertions, 9 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListSynchronizationSchedulerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListSynchronizationSchedulerTest.java
index d6b6345..74e3d8c 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListSynchronizationSchedulerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListSynchronizationSchedulerTest.java
@@ -90,15 +90,19 @@ public class TaskListSynchronizationSchedulerTest extends TestCase {
public void testSynchronization() throws Exception {
TaskListSynchronizationScheduler scheduler = new TaskListSynchronizationScheduler(
TasksUiPlugin.getTaskJobFactory());
- scheduler.setInterval(1);
- assertTrue(connector.latch.await(10, TimeUnit.SECONDS));
-
- // cancel and reschedule
- scheduler.userAttentionLost();
- scheduler.userAttentionGained();
- release();
-
- assertTrue("Expected synchronization to run again", connector.latch.await(5, TimeUnit.SECONDS));
+ try {
+ scheduler.setInterval(1);
+ assertTrue(connector.latch.await(10, TimeUnit.SECONDS));
+
+ // cancel and reschedule
+ scheduler.userAttentionLost();
+ scheduler.userAttentionGained();
+ release();
+
+ assertTrue("Expected synchronization to run again", connector.latch.await(5, TimeUnit.SECONDS));
+ } finally {
+ scheduler.dispose();
+ }
}
private void release() throws Exception {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListSynchronizationScheduler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListSynchronizationScheduler.java
index cae5ebc..5e2d334 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListSynchronizationScheduler.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListSynchronizationScheduler.java
@@ -169,4 +169,9 @@ public class TaskListSynchronizationScheduler implements IUserAttentionListener
reschedule();
}
+ public void dispose() {
+ refreshJob.removeJobChangeListener(jobListener);
+ refreshJob.cancel();
+ }
+
}