Exemplo n.º 1
0
  @Test
  public void testMessage() throws Exception {
    failed = false;

    speaker1.send("MyUDPTopic", new MyMessage(MESSAGE + "1"));
    MyMessage m = queue.poll(2000l, TimeUnit.MILLISECONDS);
    assertNotNull(m);
    assertEquals(m.getMessage(), MESSAGE + "1");

    if (failed) {
      fail();
    }

    speaker1.send("BadTopic", new MyMessage(MESSAGE + "2"));
    m = queue.poll(500l, TimeUnit.MILLISECONDS);
    assertNull(m);

    queue.clear();

    speaker2.send("MyUDPTopic", new MyMessage(MESSAGE + "1"));
    m = queue.poll(2000l, TimeUnit.MILLISECONDS);
    assertNotNull(m);
    assertEquals(m.getMessage(), MESSAGE + "1");

    if (failed) {
      fail();
    }

    speaker2.send("BadTopic", new MyMessage(MESSAGE + "2"));
    m = queue.poll(500l, TimeUnit.MILLISECONDS);
    assertNull(m);

    queue.clear();
  }