Search in sources :

Example 6 with Destination

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

the class JmsMessagingTemplateTests method convertSendAndReceivePayload.

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

Example 7 with Destination

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

the class JmsMessagingTemplateTests method sendAndReceive.

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

Example 8 with Destination

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

the class JmsMessagingTemplateTests method convertAndSendDefaultDestination.

@Test
public void convertAndSendDefaultDestination() throws JMSException {
    Destination destination = new Destination() {
    };
    this.messagingTemplate.setDefaultDestination(destination);
    this.messagingTemplate.convertAndSend("my Payload");
    verify(this.jmsTemplate).send(eq(destination), this.messageCreator.capture());
    TextMessage textMessage = createTextMessage(this.messageCreator.getValue());
    assertThat(textMessage.getText()).isEqualTo("my Payload");
}
Also used : Destination(jakarta.jms.Destination) StubTextMessage(org.springframework.jms.StubTextMessage) TextMessage(jakarta.jms.TextMessage) Test(org.junit.jupiter.api.Test)

Example 9 with Destination

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

the class JmsMessagingTemplateTests method sendDefaultDestination.

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

Example 10 with Destination

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

the class JmsResponseTests method resolveDestinationForQueue.

@Test
public void resolveDestinationForQueue() throws JMSException {
    Session session = mock(Session.class);
    DestinationResolver destinationResolver = mock(DestinationResolver.class);
    Destination destination = mock(Destination.class);
    given(destinationResolver.resolveDestinationName(session, "myQueue", false)).willReturn(destination);
    JmsResponse<String> jmsResponse = JmsResponse.forQueue("foo", "myQueue");
    Destination actual = jmsResponse.resolveDestination(destinationResolver, session);
    assertThat(actual).isSameAs(destination);
}
Also used : Destination(jakarta.jms.Destination) DestinationResolver(org.springframework.jms.support.destination.DestinationResolver) Session(jakarta.jms.Session) Test(org.junit.jupiter.api.Test)

Aggregations

Destination (jakarta.jms.Destination)41 Test (org.junit.jupiter.api.Test)31 StubTextMessage (org.springframework.jms.StubTextMessage)11 Session (jakarta.jms.Session)8 TextMessage (jakarta.jms.TextMessage)5 JMSException (jakarta.jms.JMSException)3 HashMap (java.util.HashMap)3 DestinationResolutionException (org.springframework.jms.support.destination.DestinationResolutionException)3 DestinationResolver (org.springframework.jms.support.destination.DestinationResolver)3 MessageProducer (jakarta.jms.MessageProducer)2 QueueSender (jakarta.jms.QueueSender)2 NamingException (javax.naming.NamingException)2 StubQueue (org.springframework.jms.StubQueue)2 Connection (jakarta.jms.Connection)1 ConnectionFactory (jakarta.jms.ConnectionFactory)1 Message (jakarta.jms.Message)1 MessageConsumer (jakarta.jms.MessageConsumer)1 Map (java.util.Map)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 JmsTemplate (org.springframework.jms.core.JmsTemplate)1