Search in sources :

Example 1 with Join

use of models.ChatRoom.Join in project play-cookbook by spinscale.

the class ActiveMqTest method assertThatPluginSendsMessages.

@Test
public void assertThatPluginSendsMessages() throws Exception {
    assertEquals(0, ChatRoom.get().archive().size());
    Event event = new Join("user");
    ChatRoom.get().publish(event);
    // Check chatroom
    int currentEventCount = ChatRoom.get().archive().size();
    assertEquals(1, currentEventCount);
    // Check for messages
    Message msg = receiveSubscriber.receive(2000);
    Event evt = (ChatRoom.Event) ((ObjectMessage) msg).getObject();
    assertEquals("join", evt.type);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) Event(models.ChatRoom.Event) Join(models.ChatRoom.Join) UnitTest(play.test.UnitTest) Test(org.junit.Test)

Example 2 with Join

use of models.ChatRoom.Join in project play-cookbook by spinscale.

the class ActiveMqTest method assertThatPluginSendsMessages.

@Test
public void assertThatPluginSendsMessages() throws Exception {
    assertEquals(0, ChatRoom.get().archive().size());
    Event event = new Join("user");
    ChatRoom.get().publish(event);
    // Check chatroom
    int currentEventCount = ChatRoom.get().archive().size();
    assertEquals(1, currentEventCount);
    // Check for messages
    Message msg = receiveSubscriber.receive(2000);
    Event evt = (ChatRoom.Event) ((ObjectMessage) msg).getObject();
    assertEquals("join", evt.type);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) Event(models.ChatRoom.Event) Join(models.ChatRoom.Join) UnitTest(play.test.UnitTest) Test(org.junit.Test)

Aggregations

Message (javax.jms.Message)2 ObjectMessage (javax.jms.ObjectMessage)2 Event (models.ChatRoom.Event)2 Join (models.ChatRoom.Join)2 Test (org.junit.Test)2 UnitTest (play.test.UnitTest)2