INT-1540, added extract-payload and auto-atartup to Inbound XMPP adapters, added tests
This commit is contained in:
@@ -74,6 +74,12 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-test</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
|
||||
@@ -123,6 +123,8 @@ public class XmppNamespaceHandler extends NamespaceHandlerSupport {
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
configureXMPPConnection(element, builder, parserContext);
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "channel", "requestChannel");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-payload");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +155,8 @@ public class XmppNamespaceHandler extends NamespaceHandlerSupport {
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
configureXMPPConnection(element, builder, parserContext);
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "channel", "requestChannel");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-payload");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
@@ -67,7 +68,7 @@ import org.springframework.integration.xmpp.XmppHeaders;
|
||||
* @see XMPPConnection the XMPPConnection (as
|
||||
* created by {@link XmppConnectionFactory}
|
||||
*/
|
||||
public class XmppMessageDrivenEndpoint extends AbstractEndpoint implements Lifecycle {
|
||||
public class XmppMessageDrivenEndpoint extends AbstractEndpoint {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(XmppMessageDrivenEndpoint.class);
|
||||
|
||||
|
||||
@@ -101,6 +101,8 @@
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="extract-payload" type="xsd:string" default="true"/>
|
||||
<xsd:attribute name="auto-startup" type="xsd:string" default="true"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
@@ -130,6 +132,8 @@
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="extract-payload" type="xsd:string" default="true"/>
|
||||
<xsd:attribute name="auto-startup" type="xsd:string" default="true"/>
|
||||
<xsd:attribute name="channel" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
|
||||
11
spring-integration-xmpp/src/test/java/log4j.properties
Normal file
11
spring-integration-xmpp/src/test/java/log4j.properties
Normal file
@@ -0,0 +1,11 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
|
||||
|
||||
|
||||
log4j.category.org.springframework=WARN
|
||||
# log4j.category.org.springframework.integration=DEBUG
|
||||
# log4j.category.org.springframework.integration.jdbc=DEBUG
|
||||
log4j.category.org.springframework=DEBUG
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans
|
||||
xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:xmpp="http://www.springframework.org/schema/integration/xmpp"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/xmpp
|
||||
http://www.springframework.org/schema/integration/xmpp/spring-integration-xmpp.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
|
||||
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd">
|
||||
|
||||
<beans:bean id="testConnection" class="org.mockito.Mockito" factory-method="mock">
|
||||
<beans:constructor-arg value="org.jivesoftware.smack.XMPPConnection"/>
|
||||
</beans:bean>
|
||||
|
||||
<channel id="xmppInbound"/>
|
||||
|
||||
<xmpp:message-inbound-channel-adapter id="xmppInboundAdapter" channel="xmppInbound"
|
||||
xmpp-connection="testConnection" extract-payload="false" auto-startup="false"/>
|
||||
|
||||
|
||||
|
||||
</beans:beans>
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.springframework.integration.xmpp.messages;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
|
||||
/**
|
||||
* @author ozhurakousky
|
||||
*
|
||||
*/
|
||||
public class InboundXmppEndpointParserTests {
|
||||
|
||||
@Test
|
||||
public void testInboundAdapter(){
|
||||
ApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("InboundXmppEndpointParserTests-context.xml", this.getClass());
|
||||
XmppMessageDrivenEndpoint xmde = context.getBean("xmppInboundAdapter", XmppMessageDrivenEndpoint.class);
|
||||
assertFalse(xmde.isAutoStartup());
|
||||
DirectChannel channel = (DirectChannel) TestUtils.getPropertyValue(xmde, "requestChannel");
|
||||
assertEquals("xmppInbound", channel.getComponentName());
|
||||
XMPPConnection connection = (XMPPConnection)TestUtils.getPropertyValue(xmde, "xmppConnection");
|
||||
assertEquals(connection, context.getBean("testConnection"));
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 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.
|
||||
-->
|
||||
<beans:beans
|
||||
xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
@@ -35,7 +20,7 @@
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.xmpp"/>
|
||||
|
||||
<context:property-placeholder location="#{ systemProperties['user.home'] }/Desktop/test.properties"/>
|
||||
<context:property-placeholder location="classpath:test.properties"/>
|
||||
|
||||
<channel id="xmppInbound"/>
|
||||
|
||||
@@ -51,7 +36,7 @@
|
||||
service-name="${user.2.service}"
|
||||
/>
|
||||
|
||||
<xmpp:message-inbound-channel-adapter channel="xmppInbound" xmpp-connection="testConnection"/>
|
||||
<xmpp:message-inbound-channel-adapter channel="xmppInbound" xmpp-connection="testConnection" extract-payload="false" auto-startup="false"/>
|
||||
|
||||
<service-activator input-channel="xmppInbound" ref="xmppMessageConsumer"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user