Java Code Examples for org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory#setValidator()
The following examples show how to use
org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory#setValidator() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note File: MethodJmsListenerEndpointTests.java License: MIT License | 5 votes |
@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(this.sample, methodName); }
Example 2
Source Project: spring-analysis-note File: MethodJmsListenerEndpointTests.java License: MIT License | 5 votes |
@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); // test is an invalid value assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() -> listener.onMessage(createSimpleJmsTextMessage("invalid value"), session)); }
Example 3
Source Project: java-technology-stack File: MethodJmsListenerEndpointTests.java License: MIT License | 5 votes |
@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(this.sample, methodName); }
Example 4
Source Project: java-technology-stack File: MethodJmsListenerEndpointTests.java License: MIT License | 5 votes |
@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); this.thrown.expect(ListenerExecutionFailedException.class); listener.onMessage(createSimpleJmsTextMessage("invalid value"), session); // test is an invalid value }
Example 5
Source Project: spring4-understanding File: MethodJmsListenerEndpointTests.java License: Apache License 2.0 | 5 votes |
@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); }
Example 6
Source Project: spring4-understanding File: MethodJmsListenerEndpointTests.java License: Apache License 2.0 | 5 votes |
@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 }
Example 7
Source Project: spring-analysis-note File: EnableJmsTests.java License: MIT License | 4 votes |
@Bean public MessageHandlerMethodFactory customMessageHandlerMethodFactory() { DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory(); factory.setValidator(new TestValidator()); return factory; }
Example 8
Source Project: java-technology-stack File: EnableJmsTests.java License: MIT License | 4 votes |
@Bean public MessageHandlerMethodFactory customMessageHandlerMethodFactory() { DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory(); factory.setValidator(new TestValidator()); return factory; }
Example 9
Source Project: spring4-understanding File: EnableJmsTests.java License: Apache License 2.0 | 4 votes |
@Bean public MessageHandlerMethodFactory customMessageHandlerMethodFactory() { DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory(); factory.setValidator(new TestValidator()); return factory; }