Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2010-10-28 04:41:23 +0000
committerPawel Piech2010-10-28 04:41:23 +0000
commit24af3b858a40ed1ea1a0b9968b06e7bb1723d772 (patch)
treed1f3029f1603745e0507f6c3575d77b0c42b283c /dsf/org.eclipse.cdt.tests.dsf
parentcb844bdaedf5d99c03803cd498e7a9ab32f5a971 (diff)
downloadorg.eclipse.cdt-24af3b858a40ed1ea1a0b9968b06e7bb1723d772.tar.gz
org.eclipse.cdt-24af3b858a40ed1ea1a0b9968b06e7bb1723d772.tar.xz
org.eclipse.cdt-24af3b858a40ed1ea1a0b9968b06e7bb1723d772.zip
Bug 310345 - Updated range cache to immediately return a valid range if range data is available.
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/RangeCacheTests.java53
1 files changed, 51 insertions, 2 deletions
diff --git a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/RangeCacheTests.java b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/RangeCacheTests.java
index b9b2d46d8f..bac51df6d2 100644
--- a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/RangeCacheTests.java
+++ b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/RangeCacheTests.java
@@ -162,6 +162,11 @@ public class RangeCacheTests {
Assert.assertTrue(cache.getStatus().isOK());
}
+ private void assertCacheValidWithError(ICache<List<Integer>> cache) {
+ Assert.assertTrue(cache.isValid());
+ Assert.assertFalse(cache.getStatus().isOK());
+ }
+
private void assertCacheWaiting(ICache<List<Integer>> cache) {
Assert.assertFalse(cache.isValid());
try {
@@ -388,16 +393,29 @@ public class RangeCacheTests {
}
@Test
- public void setOneRangeTest() throws InterruptedException, ExecutionException {
+ public void setRangeErrorTest() throws InterruptedException, ExecutionException {
+
+ // Retrieve a range of data.
getRange(0, 100, new long[] { 0 }, new int[] { 100 });
+ // Force an error status into the range cache.
fExecutor.submit(new DsfRunnable() {
public void run() {
fTestCache.set(0, 100, null, new Status(IStatus.ERROR, DsfTestPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Cache invalid", null));
};
}).get();
+
+ // Retrieve a range cache and check that it immediately contains the error status in it.
+ fRangeCache = null;
+ fExecutor.submit(new DsfRunnable() {
+ public void run() {
+ fRangeCache = fTestCache.getRange(0, 100);
+ }
+ }).get();
+
+ assertCacheValidWithError(fRangeCache);
- // Request data from cache
+ // Request an update from the range and check for exception.
TestQuery q = new TestQuery(10, 100);
fRangeCache = null;
@@ -410,6 +428,37 @@ public class RangeCacheTests {
Assert.fail("Expected an ExecutionException");
} catch (ExecutionException e) {}
}
+
+ @Test
+ public void getOneRangeUsingDifferentRangeInstanceTest() throws InterruptedException, ExecutionException {
+ // Request data from cache
+ TestQuery q = new TestQuery(0, 100);
+
+ fRangeCache = null;
+ fRetrieveInfos.clear();
+
+ fExecutor.execute(q);
+
+ // Wait until the cache requests the data.
+ waitForRetrieveRm(1);
+
+ assertCacheWaiting(fRangeCache);
+
+ // Set the data without using an executor.
+ Assert.assertEquals(1, fRetrieveInfos.size());
+ RetrieveInfo info = fRetrieveInfos.iterator().next();
+ completeInfo(info, 0, 100);
+
+ fExecutor.submit(new DsfRunnable() {
+ public void run() {
+ fRangeCache = fTestCache.getRange(0, 100);
+ }
+ }).get();
+
+ // Check state while waiting for data
+ assertCacheValidWithData(fRangeCache, 0, 100);
+ }
+
}

Back to the top