Example usage for org.springframework.integration.handler ExpressionEvaluatingMessageProcessor ExpressionEvaluatingMessageProcessor

List of usage examples for org.springframework.integration.handler ExpressionEvaluatingMessageProcessor ExpressionEvaluatingMessageProcessor

Introduction

In this page you can find the example usage for org.springframework.integration.handler ExpressionEvaluatingMessageProcessor ExpressionEvaluatingMessageProcessor.

Prototype

public ExpressionEvaluatingMessageProcessor(String expression) 

Source Link

Document

Create an ExpressionEvaluatingMessageProcessor for the given expression.

Usage

From source file:org.springframework.integration.handler.ExpressionEvaluatingMessageProcessorTests.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test/*w  w w.  j  a  va 2 s.co  m*/
public void testProcessMessageExpressionThrowsRuntimeException() {
    expected.expect(new TypeSafeMatcher<Exception>(Exception.class) {
        private Throwable cause;

        @Override
        public boolean matchesSafely(Exception item) {
            logger.debug(item);
            cause = item.getCause();
            return cause instanceof UnsupportedOperationException;
        }

        public void describeTo(Description description) {
            description.appendText("cause to be UnsupportedOperationException but was ").appendValue(cause);
        }
    });
    Expression expression = expressionParser.parseExpression("payload.throwRuntimeException()");
    ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
    processor.setBeanFactory(mock(BeanFactory.class));
    assertEquals("foo", processor.processMessage(new GenericMessage<TestPayload>(new TestPayload())));
}

From source file:org.springframework.integration.handler.ExpressionEvaluatingMessageProcessorTests.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test//from  w w w .j ava 2  s  . c om
public void testProcessMessageExpressionThrowsCheckedException() {
    expected.expect(new TypeSafeMatcher<Exception>(Exception.class) {
        private Throwable cause;

        @Override
        public boolean matchesSafely(Exception item) {
            logger.debug(item);
            cause = item.getCause();
            return cause instanceof CheckedException;
        }

        public void describeTo(Description description) {
            description.appendText("cause to be CheckedException but was ").appendValue(cause);
        }
    });
    Expression expression = expressionParser.parseExpression("payload.throwCheckedException()");
    ExpressionEvaluatingMessageProcessor processor = new ExpressionEvaluatingMessageProcessor(expression);
    processor.setBeanFactory(mock(BeanFactory.class));
    assertEquals("foo", processor.processMessage(new GenericMessage<TestPayload>(new TestPayload())));
}

From source file:org.springframework.integration.jms.JmsOutboundGateway.java

/**
 * Set the SpEL Expression to be used for determining the request Destination instance
 * or request destination name. Either this or one of 'requestDestination' or
 * 'requestDestinationName' is required.
 *
 * @param requestDestinationExpression The request destination expression.
 *//*from  ww  w.j  a v a 2s .  c om*/
public void setRequestDestinationExpression(Expression requestDestinationExpression) {
    Assert.notNull(requestDestinationExpression, "'requestDestinationExpression' must not be null");
    this.requestDestinationExpressionProcessor = new ExpressionEvaluatingMessageProcessor<Object>(
            requestDestinationExpression);
    setPrimaryExpression(requestDestinationExpression);
}

From source file:org.springframework.integration.jms.JmsOutboundGateway.java

/**
 * Set the SpEL Expression to be used for determining the reply Destination instance
 * or reply destination name. Either this or one of 'replyDestination' or
 * 'replyDestinationName' is required./*from  w  ww  .  ja  v  a 2  s  .co m*/
 *
 * @param replyDestinationExpression The reply destination expression.
 */
public void setReplyDestinationExpression(Expression replyDestinationExpression) {
    Assert.notNull(replyDestinationExpression, "'replyDestinationExpression' must not be null");
    this.replyDestinationExpressionProcessor = new ExpressionEvaluatingMessageProcessor<Object>(
            replyDestinationExpression);
}