Search in sources :

Example 1 with DefaultMessageHandlerMethodFactory

use of org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory in project spring-framework by spring-projects.

the class MethodJmsListenerEndpointTests method validatePayloadValid.

@Test
public 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(sample, methodName);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) DefaultMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory) Method(java.lang.reflect.Method) Session(javax.jms.Session) Test(org.junit.Test)

Example 2 with DefaultMessageHandlerMethodFactory

use of org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory in project spring-framework by spring-projects.

the class MethodJmsListenerEndpointTests method validatePayloadInvalid.

@Test
public void validatePayloadInvalid() throws JMSException {
    DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
    customFactory.setValidator(testValidator("invalid value"));
    Method method = getListenerMethod("validatePayload", String.class);
    MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
    Session session = mock(Session.class);
    thrown.expect(ListenerExecutionFailedException.class);
    // test is an invalid value
    listener.onMessage(createSimpleJmsTextMessage("invalid value"), session);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) DefaultMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory) Method(java.lang.reflect.Method) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

Method (java.lang.reflect.Method)2 Session (javax.jms.Session)2 Test (org.junit.Test)2 MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)2 DefaultMessageHandlerMethodFactory (org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory)2