Added tests for mail header-enricher.

This commit is contained in:
Mark Fisher
2009-08-20 22:15:36 +00:00
parent 8723427e1a
commit a1b1b0d068
2 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration/mail"
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-2.5.xsd
http://www.springframework.org/schema/integration/mail
http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd">
<header-enricher input-channel="input"
to="test.to"
cc="test.cc"
bcc="test.bcc"
from="test.from"
reply-to="test.reply-to"
subject="test.subject"/>
</beans:beans>

View File

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