use of javax.jms.Destination in project spring-framework by spring-projects.
the class JmsMessagingTemplateTests method convertSendAndReceiveDefaultDestination.
@Test
public void convertSendAndReceiveDefaultDestination() throws JMSException {
Destination destination = new Destination() {
};
messagingTemplate.setDefaultDestination(destination);
javax.jms.Message replyJmsMessage = createJmsTextMessage("My reply");
given(jmsTemplate.sendAndReceive(eq(destination), any())).willReturn(replyJmsMessage);
String reply = messagingTemplate.convertSendAndReceive("my Payload", String.class);
verify(jmsTemplate, times(1)).sendAndReceive(eq(destination), any());
assertEquals("My reply", reply);
}
use of javax.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(jmsTemplate).sendAndReceive(eq(destination), any());
thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
messagingTemplate.sendAndReceive(destination, createTextMessage());
}
use of javax.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);
assertNotNull(destination);
assertSame(DESTINATION, destination);
assertEquals(1, resolver.getCallCount());
destination = resolver.resolveDestinationName(session, DESTINATION_NAME, true);
assertNotNull(destination);
assertSame(DESTINATION, destination);
assertEquals(2, resolver.getCallCount());
}
use of javax.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);
assertNotNull(destination);
assertSame(DESTINATION, destination);
}
use of javax.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);
assertEquals("correlation-1234", headerAccessor.getCorrelationId());
assertEquals(destination, headerAccessor.getDestination());
assertEquals(Integer.valueOf(1), headerAccessor.getDeliveryMode());
assertEquals(1234L, headerAccessor.getExpiration(), 0.0);
assertEquals("abcd-1234", headerAccessor.getMessageId());
assertEquals(Integer.valueOf(9), headerAccessor.getPriority());
assertEquals(replyTo, headerAccessor.getReplyTo());
assertEquals(true, headerAccessor.getRedelivered());
assertEquals("type", headerAccessor.getType());
assertEquals(4567L, headerAccessor.getTimestamp(), 0.0);
// Making sure replyChannel is not mixed with replyTo
assertNull(headerAccessor.getReplyChannel());
}
Aggregations