Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2011-11-29 20:03:17 -0500
committerRoberto E. Escobar2011-11-29 20:03:17 -0500
commitfc562254e2e5eca7ca9ddac93bcc4f4a057acb38 (patch)
tree873dba65a1af5240e5eb898671c031497dafe73d /plugins/org.eclipse.osee.executor.admin.test
parentfaed6b7cf2d4f5b92c7669f84d6f59f29b4c635a (diff)
downloadorg.eclipse.osee-fc562254e2e5eca7ca9ddac93bcc4f4a057acb38.tar.gz
org.eclipse.osee-fc562254e2e5eca7ca9ddac93bcc4f4a057acb38.tar.xz
org.eclipse.osee-fc562254e2e5eca7ca9ddac93bcc4f4a057acb38.zip
feature[ats_18K4T]: Make Future get method wait for callback to execute
Diffstat (limited to 'plugins/org.eclipse.osee.executor.admin.test')
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutionCallbackTest.java6
-rw-r--r--plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockExecutionCallback.java23
2 files changed, 26 insertions, 3 deletions
diff --git a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutionCallbackTest.java b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutionCallbackTest.java
index 9299923f0c..e851748094 100644
--- a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutionCallbackTest.java
+++ b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutionCallbackTest.java
@@ -36,7 +36,7 @@ public class ExecutionCallbackTest {
final String expected = "Was Called";
- MockExecutionCallback<String> callback = new MockExecutionCallback<String>();
+ MockExecutionCallback<String> callback = new MockExecutionCallback<String>(500);
Callable<String> callable = new Callable<String>() {
@Override
@@ -66,7 +66,7 @@ public class ExecutionCallbackTest {
admin.start(new HashMap<String, Object>());
final Exception expectedException = new IllegalStateException();
- MockExecutionCallback<String> callback = new MockExecutionCallback<String>();
+ MockExecutionCallback<String> callback = new MockExecutionCallback<String>(500);
Callable<String> callable = new Callable<String>() {
@Override
@@ -102,7 +102,7 @@ public class ExecutionCallbackTest {
final String results = "results";
- MockExecutionCallback<String> callback = new MockExecutionCallback<String>();
+ MockExecutionCallback<String> callback = new MockExecutionCallback<String>(500);
TestCancellableCallable callable = new TestCancellableCallable(results);
Future<String> future = admin.schedule(callable, callback);
diff --git a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockExecutionCallback.java b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockExecutionCallback.java
index 165c165cf7..10eb250392 100644
--- a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockExecutionCallback.java
+++ b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/mock/MockExecutionCallback.java
@@ -22,20 +22,43 @@ public class MockExecutionCallback<T> implements ExecutionCallback<T> {
private boolean wasOnFailure;
private Throwable throwable;
private T result;
+ private final long waitTime;
+
+ public MockExecutionCallback(long waitTime) {
+ this.waitTime = waitTime;
+ wasOnCancelled = false;
+ wasOnSuccess = false;
+ wasOnFailure = false;
+ throwable = null;
+ result = null;
+ }
+
+ private void waitIfNeeded() {
+ if (waitTime > 0) {
+ try {
+ Thread.sleep(waitTime);
+ } catch (InterruptedException ex) {
+ // Do nothing;
+ }
+ }
+ }
@Override
public void onCancelled() {
+ waitIfNeeded();
this.wasOnCancelled = true;
}
@Override
public void onSuccess(T result) {
+ waitIfNeeded();
this.result = result;
this.wasOnSuccess = true;
}
@Override
public void onFailure(Throwable throwable) {
+ waitIfNeeded();
this.wasOnFailure = true;
this.throwable = throwable;
}

Back to the top