Search in sources :

Example 1 with Destination

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

the class JmsMessagingTemplateTests method convertSendAndReceiveDefaultDestination.

@Test
public void convertSendAndReceiveDefaultDestination() throws JMSException {
    Destination destination = new Destination() {
    };
    this.messagingTemplate.setDefaultDestination(destination);
    jakarta.jms.Message replyJmsMessage = createJmsTextMessage("My reply");
    given(this.jmsTemplate.sendAndReceive(eq(destination), any())).willReturn(replyJmsMessage);
    String reply = this.messagingTemplate.convertSendAndReceive("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 2 with Destination

use of jakarta.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(this.jmsTemplate).receive(destination);
    assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() -> this.messagingTemplate.receive(destination));
}
Also used : Destination(jakarta.jms.Destination) DestinationResolutionException(org.springframework.jms.support.destination.DestinationResolutionException) Test(org.junit.jupiter.api.Test)

Example 3 with Destination

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

the class JmsMessagingTemplateTests method receiveAndConvert.

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

Example 4 with Destination

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

the class JmsMessagingTemplateTests method receive.

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

Example 5 with Destination

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

the class JmsMessagingTemplateTests method convertInvalidDestinationExceptionOnSendAndReceive.

@Test
public void convertInvalidDestinationExceptionOnSendAndReceive() {
    Destination destination = new Destination() {
    };
    willThrow(InvalidDestinationException.class).given(this.jmsTemplate).sendAndReceive(eq(destination), any());
    assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() -> this.messagingTemplate.sendAndReceive(destination, createTextMessage()));
}
Also used : Destination(jakarta.jms.Destination) DestinationResolutionException(org.springframework.jms.support.destination.DestinationResolutionException) 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