diff options
Diffstat (limited to 'dsf/org.eclipse.cdt.tests.dsf')
-rw-r--r-- | dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/CacheTests.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/CacheTests.java b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/CacheTests.java index c9cd8021ab8..b7092fbbabd 100644 --- a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/CacheTests.java +++ b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/CacheTests.java @@ -521,6 +521,14 @@ public class CacheTests { @Test public void cancelWhilePendingWithoutClientNotificationTest() throws InterruptedException, ExecutionException { + final boolean canceledCalled[] = new boolean[] { false }; + + fTestCache = new TestCache() { + protected synchronized void canceled() { + canceledCalled[0] = true; + }; + }; + // Request data from cache Query<Integer> q = new Query<Integer>() { @Override @@ -550,12 +558,21 @@ public class CacheTests { q.cancel(true); assertCacheInvalidAndWithCanceledRM(); + + // AbstractCache.canceled() should be called after isCanceled() + // discovers that the client has canceled its request. The canceled() method is + // called in a separate dispatch cycle, so we have to wait one cycle of the executor + // after is canceled is called. + fRetrieveRm.isCanceled(); + fExecutor.submit(new Runnable() { public void run() {} }).get(); + Assert.assertTrue(canceledCalled[0]); try { q.get(); Assert.fail("Expected a cancellation exception"); } catch (CancellationException e) {} // Expected exception; + // Completed the retrieve RM fExecutor.submit(new DsfRunnable() { public void run() { |