List of usage examples for org.springframework.messaging.handler.annotation.support MethodArgumentTypeMismatchException MethodArgumentTypeMismatchException
public MethodArgumentTypeMismatchException(Message<?> message, MethodParameter parameter, String description)
From source file:org.springframework.amqp.rabbit.listener.ErrorHandlerTests.java
@Test public void testFatalsAreRejected() throws Exception { ConditionalRejectingErrorHandler handler = new ConditionalRejectingErrorHandler(); Log logger = spy(TestUtils.getPropertyValue(handler, "logger", Log.class)); willDoNothing().given(logger).warn(anyString(), any(Throwable.class)); new DirectFieldAccessor(handler).setPropertyValue("logger", logger); handler.handleError(new ListenerExecutionFailedException("intended", new RuntimeException())); try {/* w ww. j a va 2s .c o m*/ handler.handleError( new ListenerExecutionFailedException("intended", new MessageConversionException(""))); fail("Expected exception"); } catch (AmqpRejectAndDontRequeueException e) { } try { handler.handleError(new ListenerExecutionFailedException("intended", new org.springframework.messaging.converter.MessageConversionException(""))); fail("Expected exception"); } catch (AmqpRejectAndDontRequeueException e) { } Message<?> message = mock(Message.class); MethodParameter mp = new MethodParameter(Foo.class.getMethod("foo", String.class), 0); try { handler.handleError(new ListenerExecutionFailedException("intended", new MethodArgumentNotValidException(message, mp))); fail("Expected exception"); } catch (AmqpRejectAndDontRequeueException e) { } try { handler.handleError(new ListenerExecutionFailedException("intended", new MethodArgumentTypeMismatchException(message, mp, ""))); fail("Expected exception"); } catch (AmqpRejectAndDontRequeueException e) { } }