本文整理汇总了Java中org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory.setValidator方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMessageHandlerMethodFactory.setValidator方法的具体用法?Java DefaultMessageHandlerMethodFactory.setValidator怎么用?Java DefaultMessageHandlerMethodFactory.setValidator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory
的用法示例。
在下文中一共展示了DefaultMessageHandlerMethodFactory.setValidator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validatePayloadValid
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory; //导入方法依赖的package包/类
@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);
listener.onMessage(createSimpleJmsTextMessage("test"), session); // test is a valid value
assertListenerMethodInvocation(sample, methodName);
}
示例2: validatePayloadInvalid
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory; //导入方法依赖的package包/类
@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);
listener.onMessage(createSimpleJmsTextMessage("invalid value"), session); // test is an invalid value
}
示例3: customMessageHandlerMethodFactory
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory; //导入方法依赖的package包/类
@Bean
public MessageHandlerMethodFactory customMessageHandlerMethodFactory() {
DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
factory.setValidator(new TestValidator());
return factory;
}