Search in sources :

Example 1 with Event

use of models.ChatRoom.Event 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 Event

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

the class ActiveMqTest method assertThatPluginReceivesMessages.

@Test
public void assertThatPluginReceivesMessages() throws Exception {
    assertEquals(0, ChatRoom.get().archive().size());
    // Send event via JMS
    Event event = new ChatRoom.Message("alex", "cool here");
    ObjectMessage objMsg = sendingSession.createObjectMessage(event);
    sendingPublisher.publish(objMsg);
    // short sleep to make sure the content arrives
    Thread.sleep(1000);
    assertEquals(1, ChatRoom.get().archive().size());
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) ObjectMessage(javax.jms.ObjectMessage) Event(models.ChatRoom.Event) UnitTest(play.test.UnitTest) Test(org.junit.Test)

Example 3 with Event

use of models.ChatRoom.Event 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 4 with Event

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

the class ActiveMqTest method assertThatPluginReceivesMessages.

@Test
public void assertThatPluginReceivesMessages() throws Exception {
    assertEquals(0, ChatRoom.get().archive().size());
    // Send event via JMS
    Event event = new ChatRoom.Message("alex", "cool here");
    ObjectMessage objMsg = sendingSession.createObjectMessage(event);
    sendingPublisher.publish(objMsg);
    // short sleep to make sure the content arrives
    Thread.sleep(1000);
    assertEquals(1, ChatRoom.get().archive().size());
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) ObjectMessage(javax.jms.ObjectMessage) Event(models.ChatRoom.Event) UnitTest(play.test.UnitTest) Test(org.junit.Test)

Aggregations

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