Search in sources :

Example 1 with TransactionSynchronizationProcessor

use of org.springframework.integration.transaction.TransactionSynchronizationProcessor in project spring-integration by spring-projects.

the class TransactionSynchronizationFactoryParserTests method validateFullConfiguration.

@Test
public void validateFullConfiguration() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("TransactionSynchronizationFactoryParserTests-config.xml", this.getClass());
    DefaultTransactionSynchronizationFactory syncFactory = context.getBean("syncFactoryComplete", DefaultTransactionSynchronizationFactory.class);
    assertNotNull(syncFactory);
    TransactionSynchronizationProcessor processor = TestUtils.getPropertyValue(syncFactory, "processor", ExpressionEvaluatingTransactionSynchronizationProcessor.class);
    assertNotNull(processor);
    MessageChannel beforeCommitResultChannel = TestUtils.getPropertyValue(processor, "beforeCommitChannel", MessageChannel.class);
    assertNotNull(beforeCommitResultChannel);
    assertEquals(beforeCommitResultChannel, context.getBean("beforeCommitChannel"));
    Object beforeCommitExpression = TestUtils.getPropertyValue(processor, "beforeCommitExpression");
    assertNull(beforeCommitExpression);
    MessageChannel afterCommitResultChannel = TestUtils.getPropertyValue(processor, "afterCommitChannel", MessageChannel.class);
    assertNotNull(afterCommitResultChannel);
    assertEquals(afterCommitResultChannel, context.getBean("nullChannel"));
    Expression afterCommitExpression = TestUtils.getPropertyValue(processor, "afterCommitExpression", Expression.class);
    assertNotNull(afterCommitExpression);
    assertEquals("'afterCommit'", ((SpelExpression) afterCommitExpression).getExpressionString());
    MessageChannel afterRollbackResultChannel = TestUtils.getPropertyValue(processor, "afterRollbackChannel", MessageChannel.class);
    assertNotNull(afterRollbackResultChannel);
    assertEquals(afterRollbackResultChannel, context.getBean("afterRollbackChannel"));
    Expression afterRollbackExpression = TestUtils.getPropertyValue(processor, "afterRollbackExpression", Expression.class);
    assertNotNull(afterRollbackExpression);
    assertEquals("'afterRollback'", ((SpelExpression) afterRollbackExpression).getExpressionString());
    context.close();
}
Also used : DefaultTransactionSynchronizationFactory(org.springframework.integration.transaction.DefaultTransactionSynchronizationFactory) MessageChannel(org.springframework.messaging.MessageChannel) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) TransactionSynchronizationProcessor(org.springframework.integration.transaction.TransactionSynchronizationProcessor) ExpressionEvaluatingTransactionSynchronizationProcessor(org.springframework.integration.transaction.ExpressionEvaluatingTransactionSynchronizationProcessor) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Expression(org.springframework.expression.Expression) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1 Expression (org.springframework.expression.Expression)1 SpelExpression (org.springframework.expression.spel.standard.SpelExpression)1 DefaultTransactionSynchronizationFactory (org.springframework.integration.transaction.DefaultTransactionSynchronizationFactory)1 ExpressionEvaluatingTransactionSynchronizationProcessor (org.springframework.integration.transaction.ExpressionEvaluatingTransactionSynchronizationProcessor)1 TransactionSynchronizationProcessor (org.springframework.integration.transaction.TransactionSynchronizationProcessor)1 MessageChannel (org.springframework.messaging.MessageChannel)1