Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-11-20 14:25:42 -0500
committerAngel Avila2014-11-20 14:25:42 -0500
commit6dd03468f7101d06bc7a36fcfd2b0b9c710a92da (patch)
treee20582c4309a296717ccbab3b51796fa41342ffd /plugins/org.eclipse.osee.executor.admin.test
parentcfac7d6a0a966ecf613e9cb3f76352b57fba1c98 (diff)
downloadorg.eclipse.osee-6dd03468f7101d06bc7a36fcfd2b0b9c710a92da.tar.gz
org.eclipse.osee-6dd03468f7101d06bc7a36fcfd2b0b9c710a92da.tar.xz
org.eclipse.osee-6dd03468f7101d06bc7a36fcfd2b0b9c710a92da.zip
feature: Add fixed rate scheduling to ExecutorAdmin
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/ExecutorAdminTest.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminTest.java b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminTest.java
index eb1d1ccaae..47a0d6ed4f 100644
--- a/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminTest.java
+++ b/plugins/org.eclipse.osee.executor.admin.test/src/org/eclipse/osee/executor/admin/internal/ExecutorAdminTest.java
@@ -11,7 +11,10 @@
package org.eclipse.osee.executor.admin.internal;
import java.util.HashMap;
+import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.osee.logger.Log;
import org.junit.After;
import org.junit.Assert;
@@ -74,4 +77,25 @@ public class ExecutorAdminTest {
ExecutorService third = admin.getExecutor("hello");
Assert.assertFalse(third.equals(second));
}
+
+ @Test
+ public void testScheduleExecutor() throws InterruptedException {
+ final AtomicInteger executed = new AtomicInteger();
+ admin.scheduleAtFixedRate("schedule.test", new Callable<Void>() {
+
+ @Override
+ public Void call() throws Exception {
+ executed.incrementAndGet();
+ return null;
+ }
+ }, -1, 250, TimeUnit.MILLISECONDS);
+ synchronized (this) {
+ this.wait(1000L);
+ }
+ admin.shutdown("schedule.test");
+ int numOfExecutions = executed.get();
+ int limit = 3;
+ Assert.assertTrue("Number of executions was [" + numOfExecutions + "] expected > " + limit,
+ numOfExecutions > limit);
+ }
}

Back to the top