diff --git a/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/MailHeaderEnricherTests-context.xml b/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/MailHeaderEnricherTests-context.xml new file mode 100644 index 0000000000..9cc0cc9c68 --- /dev/null +++ b/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/MailHeaderEnricherTests-context.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/MailHeaderEnricherTests.java b/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/MailHeaderEnricherTests.java new file mode 100644 index 0000000000..1ebc474404 --- /dev/null +++ b/org.springframework.integration.mail/src/test/java/org/springframework/integration/mail/config/MailHeaderEnricherTests.java @@ -0,0 +1,59 @@ +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.mail.config; + +import static org.junit.Assert.assertEquals; + +import java.util.Map; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.integration.channel.MessageChannelTemplate; +import org.springframework.integration.core.Message; +import org.springframework.integration.core.MessageChannel; +import org.springframework.integration.mail.MailHeaders; +import org.springframework.integration.message.StringMessage; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * @author Mark Fisher + */ +@ContextConfiguration +@RunWith(SpringJUnit4ClassRunner.class) +public class MailHeaderEnricherTests { + + @Autowired @Qualifier("input") + private MessageChannel channel; + + @Test + public void test() { + MessageChannelTemplate template = new MessageChannelTemplate(channel); + Message result = template.sendAndReceive(new StringMessage("test")); + Map headers = result.getHeaders(); + assertEquals("test.to", headers.get(MailHeaders.TO)); + assertEquals("test.cc", headers.get(MailHeaders.CC)); + assertEquals("test.bcc", headers.get(MailHeaders.BCC)); + assertEquals("test.from", headers.get(MailHeaders.FROM)); + assertEquals("test.reply-to", headers.get(MailHeaders.REPLY_TO)); + assertEquals("test.subject", headers.get(MailHeaders.SUBJECT)); + } + +}