use of org.springframework.integration.transformer.HeaderEnricher in project spring-integration by spring-projects.
the class MethodInvokingHeaderEnricherTests method overwriteTrue.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void overwriteTrue() {
TestBean testBean = new TestBean();
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(testBean, "process");
HeaderEnricher enricher = new HeaderEnricher();
enricher.setMessageProcessor(processor);
enricher.setDefaultOverwrite(true);
Message<?> message = MessageBuilder.withPayload("test").setHeader("bar", "XYZ").build();
Message<?> result = enricher.transform(message);
assertEquals("TEST", result.getHeaders().get("foo"));
assertEquals("ABC", result.getHeaders().get("bar"));
}
use of org.springframework.integration.transformer.HeaderEnricher in project spring-integration by spring-projects.
the class MethodInvokingHeaderEnricherTests method overwriteId.
@Test
public void overwriteId() {
HeaderEnricher enricher = new HeaderEnricher(Collections.singletonMap(MessageHeaders.ID, new StaticHeaderValueMessageProcessor<>("foo")));
try {
enricher.afterPropertiesSet();
fail("BeanInitializationException expected");
} catch (Exception e) {
assertThat(e, instanceOf(BeanInitializationException.class));
assertThat(e.getMessage(), containsString("HeaderEnricher cannot override 'id' and 'timestamp' read-only headers."));
}
}
use of org.springframework.integration.transformer.HeaderEnricher in project spring-integration by spring-projects.
the class MethodInvokingHeaderEnricherTests method overwriteFalseExplicit.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void overwriteFalseExplicit() {
TestBean testBean = new TestBean();
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(testBean, "process");
HeaderEnricher enricher = new HeaderEnricher();
enricher.setMessageProcessor(processor);
enricher.setDefaultOverwrite(false);
Message<?> message = MessageBuilder.withPayload("test").setHeader("bar", "XYZ").build();
Message<?> result = enricher.transform(message);
assertEquals("TEST", result.getHeaders().get("foo"));
assertEquals("XYZ", result.getHeaders().get("bar"));
}
use of org.springframework.integration.transformer.HeaderEnricher in project spring-integration by spring-projects.
the class MethodInvokingHeaderEnricherTests method overwriteFalseByDefault.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void overwriteFalseByDefault() {
TestBean testBean = new TestBean();
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(testBean, "process");
HeaderEnricher enricher = new HeaderEnricher();
enricher.setMessageProcessor(processor);
Message<?> message = MessageBuilder.withPayload("test").setHeader("bar", "XYZ").build();
Message<?> result = enricher.transform(message);
assertEquals("TEST", result.getHeaders().get("foo"));
assertEquals("XYZ", result.getHeaders().get("bar"));
}
use of org.springframework.integration.transformer.HeaderEnricher in project spring-integration by spring-projects.
the class MethodInvokingHeaderEnricherTests method emptyHeadersOnRequest.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void emptyHeadersOnRequest() {
TestBean testBean = new TestBean();
MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(testBean, "process");
HeaderEnricher enricher = new HeaderEnricher();
enricher.setMessageProcessor(processor);
enricher.setDefaultOverwrite(true);
Message<?> message = MessageBuilder.withPayload("test").build();
Message<?> result = enricher.transform(message);
assertEquals("TEST", result.getHeaders().get("foo"));
assertEquals("ABC", result.getHeaders().get("bar"));
}
Aggregations