INT-3115 Fix EvaluationContext Initialization

There were several "helper" classes where the context was initialized
in the constructor, before the BeanFactory was passed in.

Generally fixed by adding the BeanFactory to the constructor args.

Other cases where the container-managed bean instantiated a helper
and never passed in the BeanFactory.

Finally, a fix to ExpressionUtils where the caller had a BeanFactory
but the BF did not contain an EvaluationContext factory bean, the
BeanResolver was not set up. This is unlikely in a Spring Integration
application, but added for completeness.

INT-3115 Add a BeanFactory to Test Cases

Change the WARN log in ExpressionUtils to a fatal exception to detect
cases where an EvaluationContext was created without a BeanFactory.

While this was generally in test cases, it also exposed some cases
in code where the context was initialized without a BF.

polishing on merge
This commit is contained in:
Gary Russell
2013-08-26 20:45:48 -04:00
committed by Mark Fisher
parent 06b06b1c8f
commit 52b340956f
55 changed files with 531 additions and 119 deletions

View File

@@ -19,8 +19,11 @@ package org.springframework.integration.gemfire.inbound;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.data.gemfire.RegionAttributesFactoryBean;
import org.springframework.data.gemfire.RegionFactoryBean;
@@ -52,6 +55,7 @@ public class CacheListeningMessageProducerTests {
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setPayloadExpression("key + '=' + newValue");
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
producer.start();
assertNull(channel.receive(0));
@@ -77,6 +81,7 @@ public class CacheListeningMessageProducerTests {
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setPayloadExpression("newValue");
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
producer.start();
assertNull(channel.receive(0));
@@ -107,6 +112,7 @@ public class CacheListeningMessageProducerTests {
producer.setSupportedEventTypes(EventType.DESTROYED);
producer.setPayloadExpression("oldValue");
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
producer.start();
assertNull(channel.receive(0));
@@ -135,6 +141,7 @@ public class CacheListeningMessageProducerTests {
producer.setSupportedEventTypes(EventType.INVALIDATED);
producer.setPayloadExpression("key + ' was ' + oldValue");
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
producer.start();
assertNull(channel.receive(0));