Search in sources :

Example 86 with Destination

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

the class JmsMessagingTemplateTests method receiveDefaultDestination.

@Test
public void receiveDefaultDestination() {
    Destination destination = new Destination() {
    };
    messagingTemplate.setDefaultDestination(destination);
    javax.jms.Message jmsMessage = createJmsTextMessage();
    given(jmsTemplate.receive(destination)).willReturn(jmsMessage);
    Message<?> message = messagingTemplate.receive();
    verify(jmsTemplate).receive(destination);
    assertTextMessage(message);
}
Also used : Destination(javax.jms.Destination) Test(org.junit.Test)

Example 87 with Destination

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

the class JmsMessagingTemplateTests method sendAndReceiveDefaultDestination.

@Test
public void sendAndReceiveDefaultDestination() {
    Destination destination = new Destination() {
    };
    messagingTemplate.setDefaultDestination(destination);
    Message<String> request = createTextMessage();
    javax.jms.Message replyJmsMessage = createJmsTextMessage();
    given(jmsTemplate.sendAndReceive(eq(destination), any())).willReturn(replyJmsMessage);
    Message<?> actual = messagingTemplate.sendAndReceive(request);
    verify(jmsTemplate, times(1)).sendAndReceive(eq(destination), any());
    assertTextMessage(actual);
}
Also used : Destination(javax.jms.Destination) Test(org.junit.Test)

Example 88 with Destination

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

the class JmsMessagingTemplateTests method convertAndSendPayloadAndHeaders.

@Test
public void convertAndSendPayloadAndHeaders() throws JMSException {
    Destination destination = new Destination() {
    };
    Map<String, Object> headers = new HashMap<>();
    headers.put("foo", "bar");
    messagingTemplate.convertAndSend(destination, "Hello", headers);
    verify(jmsTemplate).send(eq(destination), messageCreator.capture());
    // see createTextMessage
    assertTextMessage(messageCreator.getValue());
}
Also used : Destination(javax.jms.Destination) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 89 with Destination

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

the class JmsMessagingTemplateTests method send.

@Test
public void send() {
    Destination destination = new Destination() {
    };
    Message<String> message = createTextMessage();
    messagingTemplate.send(destination, message);
    verify(jmsTemplate).send(eq(destination), messageCreator.capture());
    assertTextMessage(messageCreator.getValue());
}
Also used : Destination(javax.jms.Destination) Test(org.junit.Test)

Example 90 with Destination

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

the class JmsMessagingTemplateTests method convertAndSendPayload.

@Test
public void convertAndSendPayload() throws JMSException {
    Destination destination = new Destination() {
    };
    messagingTemplate.convertAndSend(destination, "my Payload");
    verify(jmsTemplate).send(eq(destination), messageCreator.capture());
    TextMessage textMessage = createTextMessage(messageCreator.getValue());
    assertEquals("my Payload", textMessage.getText());
}
Also used : Destination(javax.jms.Destination) StubTextMessage(org.springframework.jms.StubTextMessage) TextMessage(javax.jms.TextMessage) Test(org.junit.Test)

Aggregations

Destination (javax.jms.Destination)137 Test (org.junit.Test)41 TextMessage (javax.jms.TextMessage)38 JMSException (javax.jms.JMSException)33 Message (javax.jms.Message)27 Session (javax.jms.Session)27 MessageProducer (javax.jms.MessageProducer)22 Connection (javax.jms.Connection)15 ConnectionFactory (javax.jms.ConnectionFactory)15 JMSContext (javax.jms.JMSContext)15 CountDownLatch (java.util.concurrent.CountDownLatch)13 MessageConsumer (javax.jms.MessageConsumer)12 StubTextMessage (org.springframework.jms.StubTextMessage)11 ObjectMessage (javax.jms.ObjectMessage)10 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)10 MapMessage (javax.jms.MapMessage)7 Queue (javax.jms.Queue)7 Map (java.util.Map)6 HashMap (java.util.HashMap)5 JMSConsumer (javax.jms.JMSConsumer)5