m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw/cloudatlas/agent/MockExecutor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent/MockExecutor.java')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/MockExecutor.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/MockExecutor.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/MockExecutor.java
new file mode 100644
index 0000000..1da50ad
--- /dev/null
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/MockExecutor.java
@@ -0,0 +1,24 @@
+package pl.edu.mimuw.cloudatlas.agent;
+
+import java.util.concurrent.LinkedBlockingQueue;
+
+import pl.edu.mimuw.cloudatlas.agent.modules.Module;
+import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage;
+
+/*
+ * Instead of passing messages to an EventBus, this one just collects them
+ * locally for inspection in unit tests.
+ */
+public class MockExecutor extends Executor {
+ public LinkedBlockingQueue<AgentMessage> messagesToPass;
+
+ public MockExecutor(Module module) {
+ super(module);
+ messagesToPass = new LinkedBlockingQueue<AgentMessage>();
+ }
+
+ @Override
+ public void passMessage(AgentMessage message) throws InterruptedException {
+ messagesToPass.put(message);
+ }
+}