m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw/cloudatlas
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/pl/edu/mimuw/cloudatlas')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java
index 5f0d1a7..133b3b9 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java
@@ -10,7 +10,7 @@ import pl.edu.mimuw.cloudatlas.agent.modules.TimerScheduler;
import java.util.ArrayList;
import java.util.HashMap;
-// TODO better task tests after enabling messaging from tasks
+// TODO better task tests with counters after enabling messaging from tasks
// TODO add wrong message test with switched types
public class SchedulerTest {
@@ -118,4 +118,43 @@ public class SchedulerTest {
Thread.sleep(1000);
}
+
+ @Test
+ public void scheduleTwoMessagingTasks() throws InterruptedException {
+ TimerSchedulerMessage messageToSend = new TimerSchedulerMessage(
+ "0",
+ AgentMessage.AgentModule.TIMER_SCHEDULER,
+ System.currentTimeMillis() / 1000L,
+ "1",
+ 20,
+ System.currentTimeMillis() / 1000L,
+ new TimerScheduledTask() {
+ @Override
+ public void run() {
+ System.out.println("Task 2 executed");
+ }
+ });
+
+ this.eventBus.addMessage(new TimerSchedulerMessage(
+ "0",
+ AgentMessage.AgentModule.TIMER_SCHEDULER,
+ System.currentTimeMillis() / 1000L,
+ "1",
+ 10,
+ System.currentTimeMillis() / 1000L,
+ new TimerScheduledTask() {
+ @Override
+ public void run() {
+ try {
+ this.sendMessage(messageToSend);
+ } catch (InterruptedException e) {
+ System.out.println("Task 1 message interrupted");
+ e.printStackTrace();
+ }
+ System.out.println("Task 1 executed");
+ }
+ }));
+
+ Thread.sleep(1000);
+ }
}