Added tests for MailTargetAdapterParser. Also, adjusted ApplicationEvent adapter tests to have an explicit context.stop() call rather than relying on context.close() for the stop event (after 2.5.2 upgrade).
This commit is contained in:
@@ -86,14 +86,15 @@ public class ApplicationEventSourceAdapterTests {
|
||||
context.start();
|
||||
Message<?> startedEventMessage = channel.receive(0);
|
||||
assertNotNull(startedEventMessage);
|
||||
assertEquals(ContextStartedEvent.class, startedEventMessage.getPayload().getClass());
|
||||
assertEquals(ContextStartedEvent.class, startedEventMessage.getPayload().getClass());
|
||||
context.stop();
|
||||
Message<?> stoppedEventMessage = channel.receive(0);
|
||||
assertNotNull(stoppedEventMessage);
|
||||
assertEquals(ContextStoppedEvent.class, stoppedEventMessage.getPayload().getClass());
|
||||
context.close();
|
||||
Message<?> closedEventMessage = channel.receive(0);
|
||||
assertNotNull(closedEventMessage);
|
||||
assertEquals(ContextClosedEvent.class, closedEventMessage.getPayload().getClass());
|
||||
Message<?> stoppedEventMessage = channel.receive(0);
|
||||
assertNotNull(stoppedEventMessage);
|
||||
assertEquals(ContextStoppedEvent.class, stoppedEventMessage.getPayload().getClass());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2002-2007 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.adapter.mail.config;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.adapter.mail.MailTargetAdapter;
|
||||
import org.springframework.integration.endpoint.DefaultMessageEndpoint;
|
||||
import org.springframework.integration.handler.MessageHandler;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MailTargetAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void testAdapterWithMailSenderReference() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"mailTargetAdapterParserTests.xml", this.getClass());
|
||||
DefaultMessageEndpoint endpoint = (DefaultMessageEndpoint) context.getBean("adapterWithMailSenderReference");
|
||||
MessageHandler handler = endpoint.getHandler();
|
||||
assertNotNull(handler);
|
||||
assertTrue(handler instanceof MailTargetAdapter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdapterWithHostProperty() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"mailTargetAdapterParserTests.xml", this.getClass());
|
||||
DefaultMessageEndpoint endpoint = (DefaultMessageEndpoint) context.getBean("adapterWithHostProperty");
|
||||
MessageHandler handler = endpoint.getHandler();
|
||||
assertNotNull(handler);
|
||||
assertTrue(handler instanceof MailTargetAdapter);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:si="http://www.springframework.org/schema/integration"
|
||||
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
|
||||
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
|
||||
|
||||
<si:message-bus/>
|
||||
|
||||
<si:channel id="testChannel"/>
|
||||
|
||||
<si:mail-target id="adapterWithMailSenderReference" mail-sender="mailSender" channel="testChannel"/>
|
||||
|
||||
<si:mail-target id="adapterWithHostProperty" host="somehost" username="someuser" password="somepassword"
|
||||
channel="testChannel"/>
|
||||
|
||||
<bean id="mailSender" class="org.springframework.integration.adapter.mail.StubJavaMailSender">
|
||||
<constructor-arg>
|
||||
<bean class="javax.mail.internet.MimeMessage">
|
||||
<constructor-arg type="javax.mail.Session"><null/></constructor-arg>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user