Search in sources :

Example 41 with Destination

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

the class JmsMessagingTemplateTests method convertDestinationResolutionExceptionOnReceive.

@Test
public void convertDestinationResolutionExceptionOnReceive() {
    Destination destination = new Destination() {
    };
    willThrow(DestinationResolutionException.class).given(jmsTemplate).receive(destination);
    thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
    messagingTemplate.receive(destination);
}
Also used : Destination(javax.jms.Destination) Test(org.junit.Test)

Example 42 with Destination

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

the class JmsMessagingTemplateTests method receive.

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

Example 43 with Destination

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

the class JmsMessagingTemplateTests method convertSendAndReceivePayload.

@Test
public void convertSendAndReceivePayload() throws JMSException {
    Destination destination = new Destination() {
    };
    javax.jms.Message replyJmsMessage = createJmsTextMessage("My reply");
    given(jmsTemplate.sendAndReceive(eq(destination), any())).willReturn(replyJmsMessage);
    String reply = messagingTemplate.convertSendAndReceive(destination, "my Payload", String.class);
    verify(jmsTemplate, times(1)).sendAndReceive(eq(destination), any());
    assertEquals("My reply", reply);
}
Also used : Destination(javax.jms.Destination) Test(org.junit.Test)

Example 44 with Destination

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

the class JmsMessagingTemplateTests method sendDefaultDestination.

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

Example 45 with Destination

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

the class JmsMessagingTemplateTests method receiveAndConvert.

@Test
public void receiveAndConvert() {
    Destination destination = new Destination() {
    };
    javax.jms.Message jmsMessage = createJmsTextMessage("my Payload");
    given(jmsTemplate.receive(destination)).willReturn(jmsMessage);
    String payload = messagingTemplate.receiveAndConvert(destination, String.class);
    assertEquals("my Payload", payload);
    verify(jmsTemplate).receive(destination);
}
Also used : Destination(javax.jms.Destination) Test(org.junit.Test)

Aggregations

Destination (javax.jms.Destination)178 Test (org.junit.Test)51 TextMessage (javax.jms.TextMessage)47 Session (javax.jms.Session)46 JMSException (javax.jms.JMSException)45 Connection (javax.jms.Connection)32 MessageProducer (javax.jms.MessageProducer)31 Message (javax.jms.Message)30 ConnectionFactory (javax.jms.ConnectionFactory)24 MessageConsumer (javax.jms.MessageConsumer)24 JMSContext (javax.jms.JMSContext)16 CountDownLatch (java.util.concurrent.CountDownLatch)15 ObjectMessage (javax.jms.ObjectMessage)12 StubTextMessage (org.springframework.jms.StubTextMessage)11 InitialContext (javax.naming.InitialContext)10 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)10 Queue (javax.jms.Queue)8 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)8 MapMessage (javax.jms.MapMessage)7 HashMap (java.util.HashMap)6