Search in sources :

Example 1 with SimpleMessageInEarLibJar

use of org.jboss.as.test.integration.ejb.mdb.objectmessage.SimpleMessageInEarLibJar in project wildfly by wildfly.

the class ObjectMessageTestCase method testObjectMessage.

/**
     * Test that the MDB can process a {@link ObjectMessage} without any classloading issues
     *
     * @throws Exception
     */
@Test
public void testObjectMessage() throws Exception {
    final String goodAfternoon = "Good afternoon!";
    // create the message
    final SimpleMessageInEarLibJar message = new SimpleMessageInEarLibJar(goodAfternoon);
    // send as ObjectMessage
    this.jmsUtil.sendObjectMessage(message, this.objectMessageQueue, this.objectMessageReplyQueue);
    // wait for an reply
    final Message reply = this.jmsUtil.receiveMessage(objectMessageReplyQueue, 5000);
    // test the reply
    Assert.assertNotNull("Reply message was null on reply queue: " + this.objectMessageReplyQueue, reply);
    final SimpleMessageInEarLibJar replyMessage = (SimpleMessageInEarLibJar) ((ObjectMessage) reply).getObject();
    Assert.assertEquals("Unexpected reply message on reply queue: " + this.objectMessageReplyQueue, message, replyMessage);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) MDBAcceptingObjectMessage(org.jboss.as.test.integration.ejb.mdb.objectmessage.MDBAcceptingObjectMessage) SimpleMessageInEarLibJar(org.jboss.as.test.integration.ejb.mdb.objectmessage.SimpleMessageInEarLibJar) Test(org.junit.Test)

Example 2 with SimpleMessageInEarLibJar

use of org.jboss.as.test.integration.ejb.mdb.objectmessage.SimpleMessageInEarLibJar in project wildfly by wildfly.

the class ObjectMessageTestCase method testObjectMessageWithObjectArray.

/**
     * Test that the MDB can process a {@link ObjectMessage} which consists of an array of objects,
     * without any classloading issues
     *
     * @throws Exception
     */
@Test
public void testObjectMessageWithObjectArray() throws Exception {
    final String goodMorning = "Good morning";
    final String goodEvening = "Good evening";
    // create the message
    final SimpleMessageInEarLibJar[] multipleGreetings = new SimpleMessageInEarLibJar[2];
    final SimpleMessageInEarLibJar messageOne = new SimpleMessageInEarLibJar(goodMorning);
    final SimpleMessageInEarLibJar messageTwo = new SimpleMessageInEarLibJar(goodEvening);
    multipleGreetings[0] = messageOne;
    multipleGreetings[1] = messageTwo;
    // send as ObjectMessage
    this.jmsUtil.sendObjectMessage(multipleGreetings, this.objectMessageOfArrayTypeQueue, this.objectMessageOfArrayTypeReplyQueue);
    // wait for an reply
    final Message reply = this.jmsUtil.receiveMessage(objectMessageOfArrayTypeReplyQueue, 5000);
    // test the reply
    Assert.assertNotNull("Reply message was null on reply queue: " + this.objectMessageOfArrayTypeReplyQueue, reply);
    final SimpleMessageInEarLibJar[] replyMessage = (SimpleMessageInEarLibJar[]) ((ObjectMessage) reply).getObject();
    Assert.assertTrue("Unexpected reply message on reply queue: " + this.objectMessageOfArrayTypeReplyQueue, Arrays.equals(replyMessage, multipleGreetings));
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) MDBAcceptingObjectMessage(org.jboss.as.test.integration.ejb.mdb.objectmessage.MDBAcceptingObjectMessage) SimpleMessageInEarLibJar(org.jboss.as.test.integration.ejb.mdb.objectmessage.SimpleMessageInEarLibJar) Test(org.junit.Test)

Aggregations

Message (javax.jms.Message)2 ObjectMessage (javax.jms.ObjectMessage)2 MDBAcceptingObjectMessage (org.jboss.as.test.integration.ejb.mdb.objectmessage.MDBAcceptingObjectMessage)2 SimpleMessageInEarLibJar (org.jboss.as.test.integration.ejb.mdb.objectmessage.SimpleMessageInEarLibJar)2 Test (org.junit.Test)2