INT-1167 added namespace support for the 'should-skip-nulls' attribute on the <header-enricher> element
This commit is contained in:
@@ -66,6 +66,7 @@ public abstract class HeaderEnricherParserSupport extends AbstractTransformerPar
|
||||
this.processHeaders(element, headers, parserContext);
|
||||
builder.addConstructorArgValue(headers);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-overwrite");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "should-skip-nulls");
|
||||
this.postProcessHeaderEnricher(builder, element, parserContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -1264,6 +1264,18 @@
|
||||
<xsd:union memberTypes="xsd:boolean xsd:string" />
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="should-skip-nulls">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Specify whether null values, such as might be returned from an expression evaluation,
|
||||
should be skipped. The default value is true. Set this to false if a null value should
|
||||
trigger removal of the corresponding header instead.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="xsd:boolean xsd:string" />
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="ref" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
|
||||
@@ -7,8 +7,20 @@
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
|
||||
<header-enricher id="headerEnricherWithDefaults" input-channel="input">
|
||||
<header name="foo" value="bar"/>
|
||||
</header-enricher>
|
||||
|
||||
<header-enricher id="headerEnricherWithSendTimeout" input-channel="input" send-timeout="1234">
|
||||
<header name="foo" value="bar"/>
|
||||
</header-enricher>
|
||||
|
||||
<header-enricher id="headerEnricherWithShouldSkipNullsTrue" input-channel="input" should-skip-nulls="true">
|
||||
<header name="foo" value="bar"/>
|
||||
</header-enricher>
|
||||
|
||||
<header-enricher id="headerEnricherWithShouldSkipNullsFalse" input-channel="input" should-skip-nulls="false">
|
||||
<header name="foo" value="bar"/>
|
||||
</header-enricher>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -39,6 +39,13 @@ public class HeaderEnricherParserTests {
|
||||
private ApplicationContext context;
|
||||
|
||||
|
||||
@Test // INT-1154
|
||||
public void sendTimeoutDefault() {
|
||||
Object endpoint = context.getBean("headerEnricherWithDefaults");
|
||||
long sendTimeout = TestUtils.getPropertyValue(endpoint, "handler.channelTemplate.sendTimeout", Long.class).longValue();
|
||||
assertEquals(1000L, sendTimeout);
|
||||
}
|
||||
|
||||
@Test // INT-1154
|
||||
public void sendTimeoutConfigured() {
|
||||
Object endpoint = context.getBean("headerEnricherWithSendTimeout");
|
||||
@@ -46,4 +53,25 @@ public class HeaderEnricherParserTests {
|
||||
assertEquals(1234L, sendTimeout);
|
||||
}
|
||||
|
||||
@Test // INT-1167
|
||||
public void shouldSkipNullsDefault() {
|
||||
Object endpoint = context.getBean("headerEnricherWithDefaults");
|
||||
Boolean shouldSkipNulls = TestUtils.getPropertyValue(endpoint, "handler.transformer.shouldSkipNulls", Boolean.class);
|
||||
assertEquals(Boolean.TRUE, shouldSkipNulls);
|
||||
}
|
||||
|
||||
@Test // INT-1167
|
||||
public void shouldSkipNullsFalseConfigured() {
|
||||
Object endpoint = context.getBean("headerEnricherWithShouldSkipNullsFalse");
|
||||
Boolean shouldSkipNulls = TestUtils.getPropertyValue(endpoint, "handler.transformer.shouldSkipNulls", Boolean.class);
|
||||
assertEquals(Boolean.FALSE, shouldSkipNulls);
|
||||
}
|
||||
|
||||
@Test // INT-1167
|
||||
public void shouldSkipNullsTrueConfigured() {
|
||||
Object endpoint = context.getBean("headerEnricherWithShouldSkipNullsTrue");
|
||||
Boolean shouldSkipNulls = TestUtils.getPropertyValue(endpoint, "handler.transformer.shouldSkipNulls", Boolean.class);
|
||||
assertEquals(Boolean.TRUE, shouldSkipNulls);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user