List of usage examples for org.springframework.integration MessageRejectedException getCause
public synchronized Throwable getCause()
From source file:biz.c24.io.spring.integration.selectors.ValidatingMessageSelectorTests.java
@Test public void testInvalid() { Employee employee = new Employee(); employee.setSalutation("Mr"); // Should fail due to non-capitalised first letter employee.setFirstName("andy"); employee.setLastName("Acheson"); // No job title set - should also cause a validation failure //employee.setJobTitle("Software Developer"); C24ValidatingMessageSelector selector = new C24ValidatingMessageSelector(); selector.setFailFast(true);/*from w ww .j a v a2s.c o m*/ selector.setThrowExceptionOnRejection(false); assertThat(selector.accept(MessageBuilder.withPayload(employee).build()), is(false)); selector.setFailFast(false); assertThat(selector.accept(MessageBuilder.withPayload(employee).build()), is(false)); selector.setFailFast(true); selector.setThrowExceptionOnRejection(true); try { selector.accept(MessageBuilder.withPayload(employee).build()); fail("Selector failed to throw an exception on invalid CDO"); } catch (MessageRejectedException ex) { // Expected behaviour assertThat(ex.getCause(), is(ValidationException.class)); } selector.setFailFast(false); try { selector.accept(MessageBuilder.withPayload(employee).build()); fail("Selector failed to throw an exception on invalid CDO"); } catch (C24AggregatedMessageValidationException ex) { // Expected behaviour ListIterator<ValidationEvent> failures = ex.getFailEvents(); int failureCount = 0; while (failures.hasNext()) { failureCount++; failures.next(); } assertThat(failureCount, is(2)); } }