added tests and modified schema to make sure that XMPP outbound adapters do not require 'channel' atribute

This commit is contained in:
Oleg Zhurakousky
2010-11-09 07:13:32 -05:00
parent b9dbb20982
commit 016e3a249a
6 changed files with 35 additions and 5 deletions

View File

@@ -26,5 +26,10 @@
xmpp-connection="testConnection">
<int:poller fixed-rate="1000" max-messages-per-poll="1"/>
</int-xmpp:message-outbound-channel-adapter>
<int-xmpp:message-outbound-channel-adapter id="outboundNoChannelAdapter"
xmpp-connection="testConnection">
<!-- <int:poller fixed-rate="1000" max-messages-per-poll="1"/>-->
</int-xmpp:message-outbound-channel-adapter>
</beans>

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.integration.xmpp.config;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -31,9 +32,12 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.xmpp.XmppHeaders;
/**
@@ -47,15 +51,25 @@ public class XmppMessageOutboundEndpointParserTests {
ApplicationContext context =
new ClassPathXmlApplicationContext("XmppMessageOutboundEndpointParserTests-context.xml", XmppMessageOutboundEndpointParserTests.class);
Object pollingConsumer = context.getBean("outboundPollingAdapter");
QueueChannel channel = (QueueChannel) TestUtils.getPropertyValue(pollingConsumer, "inputChannel");
assertEquals("outboundPollingChannel", channel.getComponentName());
assertTrue(pollingConsumer instanceof PollingConsumer);
}
@Test
public void testEventConsumerWithNoChannel(){
ApplicationContext context =
new ClassPathXmlApplicationContext("XmppMessageOutboundEndpointParserTests-context.xml", XmppMessageOutboundEndpointParserTests.class);
Object eventConsumer = context.getBean("outboundNoChannelAdapter");
assertTrue(eventConsumer instanceof SubscribableChannel);
}
@Test
public void testEventConsumer(){
ApplicationContext context =
new ClassPathXmlApplicationContext("XmppMessageOutboundEndpointParserTests-context.xml", XmppMessageOutboundEndpointParserTests.class);
Object pollingConsumer = context.getBean("outboundEventAdapter");
assertTrue(pollingConsumer instanceof EventDrivenConsumer);
Object eventConsumer = context.getBean("outboundEventAdapter");
assertTrue(eventConsumer instanceof EventDrivenConsumer);
}
@Test

View File

@@ -28,5 +28,8 @@
xmpp-connection="testConnection"
channel="eventChannel"/>
<int-xmpp:roster-event-outbound-channel-adapter id="eventOutboundRosterChannel"
xmpp-connection="testConnection"/>
</beans>

View File

@@ -20,6 +20,7 @@ import static junit.framework.Assert.assertTrue;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.PollingConsumer;
@@ -44,4 +45,12 @@ public class XmppRosterEventOutboundChannelAdapterParserTests {
Object eventConsumer = ac.getBean("eventOutboundRosterAdapter");
assertTrue(eventConsumer instanceof EventDrivenConsumer);
}
@Test
public void testRosterEventOutboundChannel(){
ApplicationContext ac =
new ClassPathXmlApplicationContext("XmppRosterEventOutboundChannelAdapterParserTests-context.xml", this.getClass());
Object channel = ac.getBean("eventOutboundRosterChannel");
assertTrue(channel instanceof SubscribableChannel);
}
}