INT-1554 refactored XmppRosterEventOutboundEndpointParser, cleaned up XmppRosterEventMessageSendingHandler, added tests
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/integration/xmpp http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp-2.0.xsd"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-xmpp="http://www.springframework.org/schema/integration/xmpp">
|
||||
|
||||
<bean id="testConnection" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</bean>
|
||||
|
||||
<int:channel id="pollingChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
<int-xmpp:roster-event-outbound-channel-adapter id="pollingOutboundRosterAdapter"
|
||||
xmpp-connection="testConnection"
|
||||
channel="pollingChannel">
|
||||
<int:poller fixed-rate="1000" max-messages-per-poll="1"/>
|
||||
</int-xmpp:roster-event-outbound-channel-adapter>
|
||||
|
||||
|
||||
<int:channel id="eventChannel"/>
|
||||
|
||||
<int-xmpp:roster-event-outbound-channel-adapter id="eventOutboundRosterAdapter"
|
||||
xmpp-connection="testConnection"
|
||||
channel="eventChannel"
|
||||
message-mapper="mockMappper"/>
|
||||
|
||||
<bean id="mockMappper" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.mapping.OutboundMessageMapper"/>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.xmpp.config;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
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.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.endpoint.PollingConsumer;
|
||||
import org.springframework.integration.mapping.OutboundMessageMapper;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.xmpp.presence.XmppPresenceMessageMapper;
|
||||
import org.springframework.integration.xmpp.presence.XmppRosterEventMessageSendingHandler;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
public class XmppRosterEventOutboundChannelAdapterParserTests {
|
||||
|
||||
@Test
|
||||
public void testRosterEventOutboundChannelAdapterParserAsPollingConsumer(){
|
||||
ApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("XmppRosterEventOutboundChannelAdapterParserTests-context.xml", this.getClass());
|
||||
Object pollingConsumer = ac.getBean("pollingOutboundRosterAdapter");
|
||||
assertTrue(pollingConsumer instanceof PollingConsumer);
|
||||
}
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testRosterEventOutboundChannelAdapterParserDefaultMapper(){
|
||||
ApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("XmppRosterEventOutboundChannelAdapterParserTests-context.xml", this.getClass());
|
||||
Object pollingConsumer = ac.getBean("pollingOutboundRosterAdapter");
|
||||
XmppRosterEventMessageSendingHandler handler =
|
||||
TestUtils.getPropertyValue(pollingConsumer, "handler", XmppRosterEventMessageSendingHandler.class);
|
||||
OutboundMessageMapper mapper = TestUtils.getPropertyValue(handler, "messageMapper", OutboundMessageMapper.class);
|
||||
assertNotNull(mapper);
|
||||
assertTrue(mapper instanceof XmppPresenceMessageMapper);
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testRosterEventOutboundChannelAdapterParserCustomMapperEventDriven(){
|
||||
ApplicationContext ac =
|
||||
new ClassPathXmlApplicationContext("XmppRosterEventOutboundChannelAdapterParserTests-context.xml", this.getClass());
|
||||
Object eventConsumer = ac.getBean("eventOutboundRosterAdapter");
|
||||
assertTrue(eventConsumer instanceof EventDrivenConsumer);
|
||||
XmppRosterEventMessageSendingHandler handler =
|
||||
TestUtils.getPropertyValue(eventConsumer, "handler", XmppRosterEventMessageSendingHandler.class);
|
||||
OutboundMessageMapper mapper = TestUtils.getPropertyValue(handler, "messageMapper", OutboundMessageMapper.class);
|
||||
assertNotNull(mapper);
|
||||
assertFalse(mapper instanceof XmppPresenceMessageMapper);
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,6 @@
|
||||
host="${user.1.host}"
|
||||
port="${user.1.port}"
|
||||
resource="${user.1.resource}"
|
||||
sasl-mechanism-supported="${user.1.sasl.mechanism}"
|
||||
sasl-mechanism-supported-index="${user.1.sasl.index}"
|
||||
service-name="${user.1.service}"
|
||||
/>
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.xmpp.messages;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
public class XmppRosterEventMessageSendingHandlerTests {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user