use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method invalidPayloadType.
// failure scenario
@Test
void invalidPayloadType() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class);
Session session = mock(Session.class);
// test is not a valid integer
assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() -> listener.onMessage(createSimpleJmsTextMessage("test"), session)).withCauseInstanceOf(MessageConversionException.class).withMessageContaining(// ref to method
getDefaultListenerMethod(Integer.class).toGenericString());
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveConvertedPayload.
@Test
void resolveConvertedPayload() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class);
Session session = mock(Session.class);
listener.onMessage(createSimpleJmsTextMessage("33"), session);
assertDefaultListenerMethodInvocation();
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveMessageHeaders.
@Test
void resolveMessageHeaders() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(MessageHeaders.class);
Session session = mock(Session.class);
StubTextMessage message = createSimpleJmsTextMessage("my payload");
message.setLongProperty("customLong", 4567L);
message.setJMSType("myMessageType");
listener.onMessage(message, session);
assertDefaultListenerMethodInvocation();
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method resolveCustomHeaderNameAndPayload.
@Test
void resolveCustomHeaderNameAndPayload() throws JMSException {
MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class);
Session session = mock(Session.class);
StubTextMessage message = createSimpleJmsTextMessage("my payload");
message.setIntProperty("myCounter", 24);
listener.onMessage(message, session);
assertDefaultListenerMethodInvocation();
}
use of jakarta.jms.Session in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method validatePayloadValid.
@Test
void validatePayloadValid() throws JMSException {
String methodName = "validatePayload";
DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
customFactory.setValidator(testValidator("invalid value"));
initializeFactory(customFactory);
Method method = getListenerMethod(methodName, String.class);
MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
Session session = mock(Session.class);
// test is a valid value
listener.onMessage(createSimpleJmsTextMessage("test"), session);
assertListenerMethodInvocation(this.sample, methodName);
}
Aggregations