artembilan/spring-integration — comment on commit 48993a50a44d85edc299eedf431a8bd6f63d3b63
File: spring-integration-groovy/src/test/java/org/springframework/integration/groovy/config/GroovyControlBusTests.java line 98
By garyrussell:

I was thinking of something like this...

@Test
public void testFailOperationOnNonManagedComponent() {
try {
Message message = MessageBuilder.withPayload("def result = nonManagedService.convert('testString')").build();
this.input.send(message);
fail("Expected MissingPropertyException");
} catch (MessageHandlingException e) {
Throwable cause = e.getCause();
assertTrue(
"Expected BeanCreationNotAllowedException, got "
+ cause.getClass() + ":" + cause.getMessage(),
cause instanceof BeanCreationNotAllowedException);
assertTrue(cause.getMessage().contains("nonManagedService"));
}
}

This ensures the exception is not only the expected type, but the cause is as expected.