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");
}
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));
}
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);
}
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);
}
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()));
}
Aggregations