use of jakarta.jms.Destination in project spring-framework by spring-projects.
the class JmsMessageHeaderAccessorTests method validateJmsHeaders.
@Test
public void validateJmsHeaders() throws JMSException {
Destination destination = new Destination() {
};
Destination replyTo = new Destination() {
};
StubTextMessage jmsMessage = new StubTextMessage("test");
jmsMessage.setJMSCorrelationID("correlation-1234");
jmsMessage.setJMSPriority(9);
jmsMessage.setJMSDestination(destination);
jmsMessage.setJMSDeliveryMode(1);
jmsMessage.setJMSExpiration(1234L);
jmsMessage.setJMSMessageID("abcd-1234");
jmsMessage.setJMSPriority(9);
jmsMessage.setJMSReplyTo(replyTo);
jmsMessage.setJMSRedelivered(true);
jmsMessage.setJMSType("type");
jmsMessage.setJMSTimestamp(4567L);
Map<String, Object> mappedHeaders = new SimpleJmsHeaderMapper().toHeaders(jmsMessage);
Message<String> message = MessageBuilder.withPayload("test").copyHeaders(mappedHeaders).build();
JmsMessageHeaderAccessor headerAccessor = JmsMessageHeaderAccessor.wrap(message);
assertThat(headerAccessor.getCorrelationId()).isEqualTo("correlation-1234");
assertThat(headerAccessor.getDestination()).isEqualTo(destination);
assertThat(headerAccessor.getDeliveryMode()).isEqualTo(Integer.valueOf(1));
assertThat(headerAccessor.getExpiration()).isEqualTo(1234);
assertThat(headerAccessor.getMessageId()).isEqualTo("abcd-1234");
assertThat(headerAccessor.getPriority()).isEqualTo(Integer.valueOf(9));
assertThat(headerAccessor.getReplyTo()).isEqualTo(replyTo);
assertThat(headerAccessor.getRedelivered()).isTrue();
assertThat(headerAccessor.getType()).isEqualTo("type");
assertThat(headerAccessor.getTimestamp()).isEqualTo(4567);
// Making sure replyChannel is not mixed with replyTo
assertThat(headerAccessor.getReplyChannel()).isNull();
}
use of jakarta.jms.Destination in project spring-framework by spring-projects.
the class JndiDestinationResolverTests method testDoesNotUseCacheIfCachingIsTurnedOff.
@Test
public void testDoesNotUseCacheIfCachingIsTurnedOff() throws Exception {
Session session = mock(Session.class);
CountingCannedJndiDestinationResolver resolver = new CountingCannedJndiDestinationResolver();
resolver.setCache(false);
Destination destination = resolver.resolveDestinationName(session, DESTINATION_NAME, true);
assertThat(destination).isNotNull();
assertThat(destination).isSameAs(DESTINATION);
assertThat(resolver.getCallCount()).isEqualTo(1);
destination = resolver.resolveDestinationName(session, DESTINATION_NAME, true);
assertThat(destination).isNotNull();
assertThat(destination).isSameAs(DESTINATION);
assertThat(resolver.getCallCount()).isEqualTo(2);
}
use of jakarta.jms.Destination in project spring-framework by spring-projects.
the class JndiDestinationResolverTests method testHitsCacheSecondTimeThrough.
@Test
public void testHitsCacheSecondTimeThrough() throws Exception {
Session session = mock(Session.class);
JndiDestinationResolver resolver = new OneTimeLookupJndiDestinationResolver();
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 SimpleJmsHeaderMapperTests method attemptToWriteDisallowedReplyToPropertyIsNotFatal.
@Test
public void attemptToWriteDisallowedReplyToPropertyIsNotFatal() throws JMSException {
Message<String> message = initBuilder().setHeader(JmsHeaders.REPLY_TO, new Destination() {
}).setHeader("foo", "bar").build();
jakarta.jms.Message jmsMessage = new StubTextMessage() {
@Override
public void setJMSReplyTo(Destination replyTo) throws JMSException {
throw new JMSException("illegal property");
}
};
mapper.fromHeaders(message.getHeaders(), jmsMessage);
assertThat(jmsMessage.getJMSReplyTo()).isNull();
assertThat(jmsMessage.getStringProperty("foo")).isNotNull();
assertThat(jmsMessage.getStringProperty("foo")).isEqualTo("bar");
}
use of jakarta.jms.Destination in project spring-framework by spring-projects.
the class SimpleJmsHeaderMapperTests method jmsReplyToMappedFromHeader.
// Outbound mapping
@Test
public void jmsReplyToMappedFromHeader() throws JMSException {
Destination replyTo = new Destination() {
};
Message<String> message = initBuilder().setHeader(JmsHeaders.REPLY_TO, replyTo).build();
jakarta.jms.Message jmsMessage = new StubTextMessage();
mapper.fromHeaders(message.getHeaders(), jmsMessage);
assertThat(jmsMessage.getJMSReplyTo()).isNotNull();
assertThat(jmsMessage.getJMSReplyTo()).isSameAs(replyTo);
}
Aggregations