INT-2068 fixed shouldSkipNulls logic
This commit is contained in:
committed by
Mark Fisher
parent
c035ce8b03
commit
7921d3f7e6
@@ -2,10 +2,8 @@
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<channel id="output">
|
||||
<queue/>
|
||||
@@ -22,6 +20,15 @@
|
||||
<header-enricher input-channel="expressionNotExecutedInput" output-channel="output">
|
||||
<header name="num" expression="headers.num / 0" />
|
||||
</header-enricher>
|
||||
|
||||
<header-enricher input-channel="headerNotRemovedInput" should-skip-nulls="false" output-channel="output">
|
||||
<header name="num" expression="null" overwrite="false"/>
|
||||
</header-enricher>
|
||||
|
||||
<header-enricher input-channel="headerRemovedInput" should-skip-nulls="false" output-channel="output"
|
||||
default-overwrite="true">
|
||||
<header name="num" expression="null"/>
|
||||
</header-enricher>
|
||||
|
||||
<beans:bean id="testBean" class="org.springframework.integration.transformer.SpelHeaderEnricherIntegrationTests$TestBean"/>
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.transformer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -32,6 +33,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author David Turanski
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -42,13 +44,19 @@ public class SpelHeaderEnricherIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private MessageChannel beanResolvingInput;
|
||||
|
||||
|
||||
@Autowired
|
||||
private MessageChannel expressionNotExecutedInput;
|
||||
|
||||
@Autowired @Qualifier("output")
|
||||
private PollableChannel output;
|
||||
@Autowired
|
||||
private MessageChannel headerNotRemovedInput;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel headerRemovedInput;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("output")
|
||||
private PollableChannel output;
|
||||
|
||||
@Test
|
||||
public void simple() {
|
||||
@@ -65,15 +73,30 @@ public class SpelHeaderEnricherIntegrationTests {
|
||||
Message<?> result = output.receive(0);
|
||||
assertEquals(243, result.getHeaders().get("num"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void suppressBeanExecution(){
|
||||
public void suppressBeanExecution() {
|
||||
Message<?> message = MessageBuilder.withPayload("test").setHeader("num", 3).build();
|
||||
this.expressionNotExecutedInput.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertEquals(3, result.getHeaders().get("num"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headerNotRemoved() {
|
||||
Message<?> message = MessageBuilder.withPayload("test").setHeader("num", 3).build();
|
||||
this.headerNotRemovedInput.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertEquals(3, result.getHeaders().get("num"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headerRemoved() {
|
||||
Message<?> message = MessageBuilder.withPayload("test").setHeader("num", 3).build();
|
||||
this.headerRemovedInput.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertNull(result.getHeaders().get("num"));
|
||||
}
|
||||
|
||||
static class TestBean {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user