use of jakarta.jms.Destination in project spring-framework by spring-projects.
the class DynamicDestinationResolverTests method testResolveDestination.
private static void testResolveDestination(Session session, Destination expectedDestination, boolean isPubSub) throws JMSException {
DynamicDestinationResolver resolver = new DynamicDestinationResolver();
Destination destination = resolver.resolveDestinationName(session, DESTINATION_NAME, isPubSub);
assertThat(destination).isNotNull();
assertThat(destination).isSameAs(expectedDestination);
}
use of jakarta.jms.Destination in project spring-framework by spring-projects.
the class JndiDestinationResolverTests method testDelegatesToFallbackIfNotResolvedInJndi.
@Test
public void testDelegatesToFallbackIfNotResolvedInJndi() throws Exception {
Session session = mock(Session.class);
DestinationResolver dynamicResolver = mock(DestinationResolver.class);
given(dynamicResolver.resolveDestinationName(session, DESTINATION_NAME, true)).willReturn(DESTINATION);
JndiDestinationResolver resolver = new JndiDestinationResolver() {
@Override
protected <T> T lookup(String jndiName, Class<T> requiredClass) throws NamingException {
throw new NamingException();
}
};
resolver.setFallbackToDynamicDestination(true);
resolver.setDynamicDestinationResolver(dynamicResolver);
Destination destination = resolver.resolveDestinationName(session, DESTINATION_NAME, true);
assertThat(destination).isNotNull();
assertThat(destination).isSameAs(DESTINATION);
}
use of jakarta.jms.Destination in project spring-framework by spring-projects.
the class JmsMessagingTemplateTests method convertDestinationResolutionExceptionOnSend.
@Test
public void convertDestinationResolutionExceptionOnSend() {
Destination destination = new Destination() {
};
willThrow(DestinationResolutionException.class).given(this.jmsTemplate).send(eq(destination), any());
assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() -> this.messagingTemplate.send(destination, createTextMessage()));
}
use of jakarta.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");
this.messagingTemplate.convertAndSend(destination, "Hello", headers);
verify(this.jmsTemplate).send(eq(destination), this.messageCreator.capture());
// see createTextMessage
assertTextMessage(this.messageCreator.getValue());
}
use of jakarta.jms.Destination in project spring-framework by spring-projects.
the class JmsMessagingTemplateTests method receiveAndConvertDefaultDestination.
@Test
public void receiveAndConvertDefaultDestination() {
Destination destination = new Destination() {
};
this.messagingTemplate.setDefaultDestination(destination);
jakarta.jms.Message jmsMessage = createJmsTextMessage("my Payload");
given(this.jmsTemplate.receive(destination)).willReturn(jmsMessage);
String payload = this.messagingTemplate.receiveAndConvert(String.class);
assertThat(payload).isEqualTo("my Payload");
verify(this.jmsTemplate).receive(destination);
}
Aggregations