diff options
author | Magdalena Grodzińska <mag.grodzinska@gmail.com> | 2019-12-25 12:52:48 +0100 |
---|---|---|
committer | Magdalena Grodzińska <mag.grodzinska@gmail.com> | 2019-12-25 12:52:48 +0100 |
commit | 28795098ebebd6a244b249355808a37912656f9d (patch) | |
tree | 73227531ed661361fdeffb671b76948f8de663ee /src/test/java/pl/edu | |
parent | 6bd93c4fc80624eb83e9a1eb9b93e5781a796505 (diff) |
Add timer scheduler tests with messages
Diffstat (limited to 'src/test/java/pl/edu')
-rw-r--r-- | src/test/java/pl/edu/mimuw/cloudatlas/agent/SchedulerTest.java | 41 |
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); + } } |