INT-1167 added namespace support for the 'should-skip-nulls' attribute on the <header-enricher> element

This commit is contained in:
Mark Fisher
2010-06-15 21:59:15 +00:00
parent 7ed5499287
commit 9f1913512d
4 changed files with 53 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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>

View File

@@ -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>

View File

@@ -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);
}
}