m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java
index 170b76e..37fdbe7 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlTest.java
@@ -312,7 +312,7 @@ public class GossipGirlTest {
@Test
public void receiverSendsNoCoTamOnState() throws Exception {
gossipGirl.handleTyped(hejkaMessage);
- executor.messagesToPass.poll();
+ executor.messagesToPass.take();
gossipGirl.handleTyped(stateMessage);
AgentMessage receivedMessage = executor.messagesToPass.poll();
@@ -337,6 +337,31 @@ public class GossipGirlTest {
assertThat(querySet, hasItems(new Attribute("&query")));
}
+ @Test
+ public void receiverSendsInfoOnFirstReceivedInfo() throws Exception {
+ gossipGirl.handleTyped(hejkaMessage);
+ executor.messagesToPass.take();
+ gossipGirl.handleTyped(stateMessage);
+ executor.messagesToPass.take();
+
+ gossipGirl.handleTyped(attributesMessage1);
+
+ // 3 ZMIs, 2 queries, 1 own attributes update
+ assertEquals(6, executor.messagesToPass.size());
+
+ AgentMessage receivedMessage1 = executor.messagesToPass.poll();
+ assertAttributeMessage(receivedMessage1, "/son/bro", "/daughter");
+ AgentMessage receivedMessage2 = executor.messagesToPass.poll();
+ assertAttributeMessage(receivedMessage2, "/son/bro", "/son/sis");
+ AgentMessage receivedMessage3 = executor.messagesToPass.poll();
+ assertAttributeMessage(receivedMessage3, "/son/bro", "/son/grand");
+
+ AgentMessage receivedMessage4 = executor.messagesToPass.poll();
+ assertQueryMessage(receivedMessage4, "/son/bro", "&two", "SELECT 2 AS two");
+ AgentMessage receivedMessage5 = executor.messagesToPass.poll();
+ assertQueryMessage(receivedMessage5, "/son/bro", "&query", "SELECT sum(foo) AS foo");
+ }
+
private void assertQueryMessage(AgentMessage message, String recipientPath, String name, String query) throws Exception {
assertUDUPMessage(
message,