Search in sources :

Example 6 with DefaultTransactionSynchronizationFactory

use of org.springframework.integration.transaction.DefaultTransactionSynchronizationFactory 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)6 DefaultTransactionSynchronizationFactory (org.springframework.integration.transaction.DefaultTransactionSynchronizationFactory)6 ExpressionEvaluatingTransactionSynchronizationProcessor (org.springframework.integration.transaction.ExpressionEvaluatingTransactionSynchronizationProcessor)6 BeanFactory (org.springframework.beans.factory.BeanFactory)5 SpelExpressionParser (org.springframework.expression.spel.standard.SpelExpressionParser)5 QueueChannel (org.springframework.integration.channel.QueueChannel)5 Message (org.springframework.messaging.Message)5 PollableChannel (org.springframework.messaging.PollableChannel)5 GenericMessage (org.springframework.messaging.support.GenericMessage)5 PseudoTransactionManager (org.springframework.integration.transaction.PseudoTransactionManager)3 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)3 IntegrationResourceHolder (org.springframework.integration.transaction.IntegrationResourceHolder)2 MessageChannel (org.springframework.messaging.MessageChannel)2 Log (org.apache.commons.logging.Log)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1 Expression (org.springframework.expression.Expression)1 SpelExpression (org.springframework.expression.spel.standard.SpelExpression)1 NullChannel (org.springframework.integration.channel.NullChannel)1 TransactionSynchronizationProcessor (org.springframework.integration.transaction.TransactionSynchronizationProcessor)1