Search in sources :

Example 41 with ObjectMessage

use of javax.jms.ObjectMessage in project spring-framework by spring-projects.

the class MessageListenerAdapterTests method testWithMessageContentsDelegateForObjectMessage.

@Test
public void testWithMessageContentsDelegateForObjectMessage() throws Exception {
    ObjectMessage objectMessage = mock(ObjectMessage.class);
    given(objectMessage.getObject()).willReturn(NUMBER);
    MessageContentsDelegate delegate = mock(MessageContentsDelegate.class);
    MessageListenerAdapter adapter = new MessageListenerAdapter(delegate);
    adapter.onMessage(objectMessage);
    verify(delegate).handleMessage(NUMBER);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Test(org.junit.Test)

Example 42 with ObjectMessage

use of javax.jms.ObjectMessage in project spring-framework by spring-projects.

the class MethodJmsListenerEndpointTests method resolveObjectPayload.

@Test
public void resolveObjectPayload() throws JMSException {
    MessagingMessageListenerAdapter listener = createDefaultInstance(MyBean.class);
    MyBean myBean = new MyBean();
    myBean.name = "myBean name";
    Session session = mock(Session.class);
    ObjectMessage message = mock(ObjectMessage.class);
    given(message.getObject()).willReturn(myBean);
    listener.onMessage(message, session);
    assertDefaultListenerMethodInvocation();
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) ObjectMessage(javax.jms.ObjectMessage) Session(javax.jms.Session) Test(org.junit.Test)

Example 43 with ObjectMessage

use of javax.jms.ObjectMessage in project spring-framework by spring-projects.

the class MessagingMessageConverterTests method simpleObject.

@Test
public void simpleObject() throws Exception {
    Session session = mock(Session.class);
    Serializable payload = mock(Serializable.class);
    ObjectMessage jmsMessage = mock(ObjectMessage.class);
    given(session.createObjectMessage(payload)).willReturn(jmsMessage);
    this.converter.toMessage(MessageBuilder.withPayload(payload).build(), session);
    verify(session).createObjectMessage(payload);
}
Also used : Serializable(java.io.Serializable) ObjectMessage(javax.jms.ObjectMessage) Session(javax.jms.Session) Test(org.junit.Test)

Example 44 with ObjectMessage

use of javax.jms.ObjectMessage in project spring-framework by spring-projects.

the class SimpleMessageConverterTests method testSerializableConversion.

@Test
public void testSerializableConversion() throws JMSException {
    Session session = mock(Session.class);
    ObjectMessage message = mock(ObjectMessage.class);
    Integer content = new Integer(5);
    given(session.createObjectMessage(content)).willReturn(message);
    given(message.getObject()).willReturn(content);
    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message msg = converter.toMessage(content, session);
    assertEquals(content, converter.fromMessage(msg));
}
Also used : TextMessage(javax.jms.TextMessage) MapMessage(javax.jms.MapMessage) ObjectMessage(javax.jms.ObjectMessage) BytesMessage(javax.jms.BytesMessage) Message(javax.jms.Message) ObjectMessage(javax.jms.ObjectMessage) SimpleMessageConverter(org.springframework.jms.support.converter.SimpleMessageConverter) Session(javax.jms.Session) Test(org.junit.Test)

Example 45 with ObjectMessage

use of javax.jms.ObjectMessage in project spring-framework by spring-projects.

the class SimpleMessageConverterTests method testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage.

@Test
public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
    Session session = mock(Session.class);
    ObjectMessage message = mock(ObjectMessage.class);
    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message msg = converter.toMessage(message, session);
    assertSame(message, msg);
}
Also used : TextMessage(javax.jms.TextMessage) MapMessage(javax.jms.MapMessage) ObjectMessage(javax.jms.ObjectMessage) BytesMessage(javax.jms.BytesMessage) Message(javax.jms.Message) ObjectMessage(javax.jms.ObjectMessage) SimpleMessageConverter(org.springframework.jms.support.converter.SimpleMessageConverter) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

ObjectMessage (javax.jms.ObjectMessage)71 JMSException (javax.jms.JMSException)29 Message (javax.jms.Message)24 Session (javax.jms.Session)18 Test (org.junit.Test)18 TextMessage (javax.jms.TextMessage)14 Serializable (java.io.Serializable)11 Destination (javax.jms.Destination)11 Map (java.util.Map)10 BytesMessage (javax.jms.BytesMessage)10 MapMessage (javax.jms.MapMessage)9 MessageProducer (javax.jms.MessageProducer)8 MessageConsumer (javax.jms.MessageConsumer)7 TreeMap (java.util.TreeMap)6 MessageCreator (org.springframework.jms.core.MessageCreator)5 DataNode (com.odysseusinc.arachne.portal.model.DataNode)4 HashMap (java.util.HashMap)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 RequestMessage (com.alliander.osgp.shared.infra.jms.RequestMessage)3 ConsumerTemplate (com.odysseusinc.arachne.commons.service.messaging.ConsumerTemplate)3