INT-4114: Add missed <poller> to XSDs

JIRA: https://jira.spring.io/browse/INT-4114
This commit is contained in:
Artem Bilan
2018-10-26 12:28:07 -04:00
committed by Gary Russell
parent fef0a4db03
commit 674d5adfc0
21 changed files with 216 additions and 90 deletions

View File

@@ -651,6 +651,11 @@ Only files matching this regular expression will be picked up by this adapter.
</xsd:element>
<xsd:complexType name="transformerType">
<xsd:choice minOccurs="0" maxOccurs="2">
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
minOccurs="0" maxOccurs="1" />
</xsd:choice>
<xsd:attribute name="id" type="xsd:string">
<xsd:annotation>
<xsd:documentation>

View File

@@ -13,14 +13,18 @@
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
<si:channel id="input"/>
<si:channel id="input">
<si:queue/>
</si:channel>
<si:channel id="output"/>
<file:file-to-string-transformer id="transformer"
input-channel="input"
delete-files="${files.delete}"
output-channel="output"/>
output-channel="output">
<si:poller fixed-delay="100"/>
</file:file-to-string-transformer>
<context:property-placeholder location="org/springframework/integration/file/config/fileToStringTransformerParserTests.properties"/>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -24,23 +24,26 @@ import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.integration.file.transformer.FileToStringTransformer;
import org.springframework.integration.transformer.MessageTransformingHandler;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext
public class FileToStringTransformerParserTests {
@Autowired
@Qualifier("transformer")
EventDrivenConsumer endpoint;
PollingConsumer endpoint;
@Test
public void checkDeleteFilesValue() {

View File

@@ -1387,6 +1387,7 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
</xsd:choice>
<xsd:attribute name="default-overwrite">
<xsd:annotation>

View File

@@ -1,7 +1,7 @@
<?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:integration="http://www.springframework.org/schema/integration"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
@@ -10,9 +10,14 @@
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
<int:channel id="valueTestInput">
<int:queue/>
</int:channel>
<jms:header-enricher input-channel="valueTestInput" output-channel="output">
<jms:reply-to ref="testDestination"/>
<jms:correlation-id value="ABC"/>
<int:poller fixed-delay="100"/>
</jms:header-enricher>
<jms:header-enricher input-channel="expressionTestInput" output-channel="output">
@@ -21,8 +26,8 @@
<bean id="testDestination" class="org.springframework.integration.jms.StubDestination"/>
<integration:channel id="output">
<integration:queue capacity="1"/>
</integration:channel>
<int:channel id="output">
<int:queue capacity="1"/>
</int:channel>
</beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -39,6 +39,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@@ -59,19 +60,19 @@ public class JmsHeaderEnricherTests {
@Test // INT-804
public void verifyReplyToValue() throws Exception {
valueTestInput.send(new GenericMessage<String>("test"));
Message<?> result = output.receive(0);
assertEquals(testDestination, result.getHeaders().get(JmsHeaders.REPLY_TO));
this.valueTestInput.send(new GenericMessage<>("test"));
Message<?> result = output.receive(10_000);
assertEquals(this.testDestination, result.getHeaders().get(JmsHeaders.REPLY_TO));
StubTextMessage jmsMessage = new StubTextMessage();
DefaultJmsHeaderMapper headerMapper = new DefaultJmsHeaderMapper();
headerMapper.fromHeaders(result.getHeaders(), jmsMessage);
assertEquals(testDestination, jmsMessage.getJMSReplyTo());
assertEquals(this.testDestination, jmsMessage.getJMSReplyTo());
}
@Test
public void verifyCorrelationIdValue() throws Exception {
valueTestInput.send(new GenericMessage<String>("test"));
Message<?> result = output.receive(0);
this.valueTestInput.send(new GenericMessage<>("test"));
Message<?> result = output.receive(10_000);
assertEquals("ABC", result.getHeaders().get(JmsHeaders.CORRELATION_ID));
StubTextMessage jmsMessage = new StubTextMessage();
DefaultJmsHeaderMapper headerMapper = new DefaultJmsHeaderMapper();
@@ -81,7 +82,7 @@ public class JmsHeaderEnricherTests {
@Test // see INT-1122 and INT-1123
public void verifyCorrelationIdExpression() throws Exception {
expressionTestInput.send(new GenericMessage<String>("test"));
this.expressionTestInput.send(new GenericMessage<>("test"));
Message<?> result = output.receive(0);
assertEquals(123, result.getHeaders().get(JmsHeaders.CORRELATION_ID));
StubTextMessage jmsMessage = new StubTextMessage();

View File

@@ -298,6 +298,9 @@
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="transformerType">
<xsd:sequence>
<xsd:element ref="integration:poller" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="charset" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
@@ -314,7 +317,7 @@
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="transformerType">
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="subject" type="headerType"/>
<xsd:element name="to" type="headerType"/>
<xsd:element name="cc" type="headerType"/>
@@ -324,6 +327,7 @@
<xsd:element name="content-type" type="headerType"/>
<xsd:element name="attachment-filename" type="headerType"/>
<xsd:element name="multipart-mode" type="headerType"/>
<xsd:element ref="integration:poller" minOccurs="0"/>
</xsd:choice>
<xsd:attribute name="default-overwrite">
<xsd:annotation>

View File

@@ -2,8 +2,11 @@
<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"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="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/integration/mail
http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd">
@@ -18,7 +21,12 @@
<multipart-mode value="1"/>
</header-enricher>
<int:channel id="expressionsInput">
<int:queue />
</int:channel>
<header-enricher input-channel="expressionsInput">
<int:poller fixed-delay="100"/>
<to expression="payload + '.to'"/>
<cc expression="payload + '.cc'"/>
<bcc expression="payload + '.bcc'"/>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -30,14 +30,17 @@ import org.springframework.integration.mail.MailHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext
public class MailHeaderEnricherTests {
@Autowired
@@ -51,8 +54,8 @@ public class MailHeaderEnricherTests {
@Test
public void literalValues() {
MessagingTemplate template = new MessagingTemplate();
template.setDefaultDestination(literalValuesInput);
Message<?> result = template.sendAndReceive(new GenericMessage<String>("test"));
template.setDefaultDestination(this.literalValuesInput);
Message<?> result = template.sendAndReceive(new GenericMessage<>("test"));
Map<String, Object> headers = result.getHeaders();
assertEquals("test.to", headers.get(MailHeaders.TO));
assertEquals("test.cc", headers.get(MailHeaders.CC));
@@ -67,8 +70,8 @@ public class MailHeaderEnricherTests {
@Test
public void expressions() {
MessagingTemplate template = new MessagingTemplate();
template.setDefaultDestination(expressionsInput);
Message<?> result = template.sendAndReceive(new GenericMessage<String>("foo"));
template.setDefaultDestination(this.expressionsInput);
Message<?> result = template.sendAndReceive(new GenericMessage<>("foo"));
Map<String, Object> headers = result.getHeaders();
assertEquals("foo.to", headers.get(MailHeaders.TO));
assertEquals("foo.cc", headers.get(MailHeaders.CC));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 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.
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue;
import javax.mail.internet.MimeMessage;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.BeanDefinitionStoreException;
@@ -38,47 +38,52 @@ import org.springframework.messaging.support.GenericMessage;
* @author Mark Fisher
* @author Artem Bilan
*/
public class MailToStringTransformerParserTests {
class MailToStringTransformerParserTests {
@Test
public void topLevelTransformer() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"mailToStringTransformerParserTests.xml", this.getClass());
MessageChannel input = new BeanFactoryChannelResolver(context).resolveDestination("input");
PollableChannel output = (PollableChannel) new BeanFactoryChannelResolver(context).resolveDestination("output");
MimeMessage mimeMessage = Mockito.mock(MimeMessage.class);
Mockito.when(mimeMessage.getContent()).thenReturn("hello");
input.send(new GenericMessage<javax.mail.Message>(mimeMessage));
Message<?> result = output.receive(0);
assertNotNull(result);
assertEquals("hello", result.getPayload());
Mockito.verify(mimeMessage).getContent();
void topLevelTransformer() throws Exception {
try (ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("mailToStringTransformerParserTests.xml", this.getClass());) {
MessageChannel input = new BeanFactoryChannelResolver(context).resolveDestination("input");
PollableChannel output =
(PollableChannel) new BeanFactoryChannelResolver(context).resolveDestination("output");
MimeMessage mimeMessage = Mockito.mock(MimeMessage.class);
Mockito.when(mimeMessage.getContent()).thenReturn("hello");
input.send(new GenericMessage<javax.mail.Message>(mimeMessage));
Message<?> result = output.receive(10_000);
assertNotNull(result);
assertEquals("hello", result.getPayload());
Mockito.verify(mimeMessage).getContent();
}
}
@Test
public void transformerWithinChain() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"mailToStringTransformerWithinChain.xml", this.getClass());
MessageChannel input = new BeanFactoryChannelResolver(context).resolveDestination("input");
PollableChannel output = (PollableChannel) new BeanFactoryChannelResolver(context).resolveDestination("output");
MimeMessage mimeMessage = Mockito.mock(MimeMessage.class);
Mockito.when(mimeMessage.getContent()).thenReturn("foo");
input.send(new GenericMessage<javax.mail.Message>(mimeMessage));
Message<?> result = output.receive(0);
assertNotNull(result);
assertEquals("FOO!!!", result.getPayload());
Mockito.verify(mimeMessage).getContent();
void transformerWithinChain() throws Exception {
try (ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("mailToStringTransformerWithinChain.xml", this.getClass());) {
MessageChannel input = new BeanFactoryChannelResolver(context).resolveDestination("input");
PollableChannel output =
(PollableChannel) new BeanFactoryChannelResolver(context).resolveDestination("output");
MimeMessage mimeMessage = Mockito.mock(MimeMessage.class);
Mockito.when(mimeMessage.getContent()).thenReturn("foo");
input.send(new GenericMessage<javax.mail.Message>(mimeMessage));
Message<?> result = output.receive(0);
assertNotNull(result);
assertEquals("FOO!!!", result.getPayload());
Mockito.verify(mimeMessage).getContent();
}
}
@Test(expected = BeanDefinitionStoreException.class)
public void topLevelTransformerMissingInput() {
@Test
void topLevelTransformerMissingInput() {
try {
new ClassPathXmlApplicationContext("mailToStringTransformerWithoutInputChannel.xml", this.getClass())
.close();
}
catch (BeanDefinitionStoreException e) {
assertTrue(e.getMessage().contains("input-channel"));
throw e;
}
}

View File

@@ -2,20 +2,24 @@
<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"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="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/integration/mail
http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd">
http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd">
<integration:channel id="input"/>
<int:channel id="input">
<int:queue />
</int:channel>
<integration:channel id="output">
<integration:queue capacity="1"/>
</integration:channel>
<int:channel id="output">
<int:queue capacity="1"/>
</int:channel>
<mail-to-string-transformer input-channel="input" output-channel="output"/>
<mail-to-string-transformer input-channel="input" output-channel="output">
<int:poller fixed-delay="100"/>
</mail-to-string-transformer>
</beans:beans>

View File

@@ -116,6 +116,11 @@
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="mongodbAdapterType">
<xsd:choice minOccurs="0" maxOccurs="2">
<xsd:element ref="integration:poller" minOccurs="0"/>
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
minOccurs="0" />
</xsd:choice>
<xsd:attribute name="request-channel" type="xsd:string">
<xsd:annotation>
<xsd:documentation>

View File

@@ -8,13 +8,23 @@
http://www.springframework.org/schema/integration/mongodb http://www.springframework.org/schema/integration/mongodb/spring-integration-mongodb.xsd">
<int:channel id="in"/>
<int:channel id="inQueue">
<int:queue />
</int:channel>
<int:channel id="out"/>
<int-mongodb:outbound-gateway id="minimalConfig"
query="{'name' : 'foo'}"
collection-name="foo"
request-channel="in"
reply-channel="out"/>
request-channel="inQueue"
reply-channel="out">
<int:poller fixed-delay="1000"/>
<int-mongodb:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.RequestHandlerRetryAdvice"/>
</int-mongodb:request-handler-advice-chain>
</int-mongodb:outbound-gateway>
<int-mongodb:outbound-gateway id="fullConfigWithCollectionExpression"
mongodb-factory="mongoDbFactory"

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 the original author or authors.
* Copyright 2016-2018 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.
@@ -23,6 +23,9 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,14 +38,20 @@ import org.springframework.data.mongodb.core.CollectionCallback;
import org.springframework.data.mongodb.core.convert.MongoConverter;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.standard.SpelExpression;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
import org.springframework.integration.mongodb.outbound.MongoDbOutboundGateway;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageHandler;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @author Xavier Padró
* @author Artem Bilan
*
* @since 5.0
*/
@ContextConfiguration
@@ -61,8 +70,9 @@ public class MongoDbOutboundGatewayParserTests {
@Test
public void minimalConfig() {
AbstractEndpoint endpoint = this.context.getBean("minimalConfig", AbstractEndpoint.class);
MongoDbOutboundGateway gateway =
TestUtils.getPropertyValue(context.getBean("minimalConfig"), "handler", MongoDbOutboundGateway.class);
TestUtils.getPropertyValue(endpoint, "handler", MongoDbOutboundGateway.class);
assertNotNull(TestUtils.getPropertyValue(gateway, "mongoTemplate"));
assertSame(this.mongoDbFactory, TestUtils.getPropertyValue(gateway, "mongoDbFactory"));
@@ -70,6 +80,11 @@ public class MongoDbOutboundGatewayParserTests {
assertThat(TestUtils.getPropertyValue(gateway, "collectionNameExpression"),
instanceOf(LiteralExpression.class));
assertEquals("foo", TestUtils.getPropertyValue(gateway, "collectionNameExpression.literalValue"));
assertThat(endpoint, Matchers.instanceOf(PollingConsumer.class));
MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
List<?> advices = TestUtils.getPropertyValue(handler, "adviceChain", List.class);
assertThat(advices.get(0), Matchers.instanceOf(RequestHandlerRetryAdvice.class));
}
@Test

View File

@@ -465,8 +465,9 @@ this list can also be simple patterns to be matched against the header names (e.
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="transformerType">
<xsd:choice minOccurs="1" maxOccurs="1">
<xsd:choice maxOccurs="2">
<xsd:element name="soap-action" type="headerType"/>
<xsd:element ref="integration:poller" minOccurs="0"/>
</xsd:choice>
<xsd:attribute name="default-overwrite">
<xsd:annotation>

View File

@@ -1,14 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration/ws"
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
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="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/integration/ws
http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd">
<int:channel id="literalValueInput">
<int:queue/>
</int:channel>
<header-enricher input-channel="literalValueInput">
<soap-action value="http://test"/>
<int:poller fixed-delay="100"/>
</header-enricher>
<header-enricher input-channel="expressionInput">

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -30,15 +30,19 @@ import org.springframework.integration.ws.WebServiceHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
* @author Artem Bilan
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext
public class WebServiceHeaderEnricherTests {
@Autowired
@@ -53,7 +57,7 @@ public class WebServiceHeaderEnricherTests {
public void literalValue() {
MessagingTemplate template = new MessagingTemplate();
template.setDefaultDestination(literalValueInput);
Message<?> result = template.sendAndReceive(new GenericMessage<String>("foo"));
Message<?> result = template.sendAndReceive(new GenericMessage<>("foo"));
Map<String, Object> headers = result.getHeaders();
assertEquals("http://test", headers.get(WebServiceHeaders.SOAP_ACTION));
}
@@ -62,7 +66,7 @@ public class WebServiceHeaderEnricherTests {
public void expression() {
MessagingTemplate template = new MessagingTemplate();
template.setDefaultDestination(expressionInput);
Message<?> result = template.sendAndReceive(new GenericMessage<String>("foo"));
Message<?> result = template.sendAndReceive(new GenericMessage<>("foo"));
Map<String, Object> headers = result.getHeaders();
assertEquals("http://foo", headers.get(WebServiceHeaders.SOAP_ACTION));
}

View File

@@ -28,6 +28,10 @@
<xsd:complexType >
<xsd:complexContent>
<xsd:extension base="inputOutputEndpoint">
<xsd:sequence>
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="marshaller" type="xsd:string" use="required">
<xsd:annotation>
<xsd:appinfo>
@@ -83,6 +87,10 @@
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="inputOutputEndpoint">
<xsd:sequence>
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="unmarshaller" type="xsd:string" use="required">
<xsd:annotation>
<xsd:appinfo>
@@ -125,6 +133,8 @@
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="xslt-param-headers" type="xsd:string" use="optional">
<xsd:annotation>
@@ -262,6 +272,10 @@
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="inputOutputEndpoint">
<xsd:sequence>
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="xpath-expression" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
@@ -339,8 +353,10 @@
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="inputOutputEndpoint">
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:sequence maxOccurs="unbounded">
<xsd:element type="xpathHeaderType" name="header"/>
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="default-overwrite">
<xsd:annotation>
@@ -480,8 +496,8 @@
<xsd:complexContent>
<xsd:extension base="commonXPathRouterType">
<xsd:sequence>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
<xsd:element ref="xpath-expression" minOccurs="0" maxOccurs="1">
<xsd:element ref="integration:poller" minOccurs="0" />
<xsd:element ref="xpath-expression" minOccurs="0" >
<xsd:annotation>
<xsd:documentation><![CDATA[
Internally XPath expressions will be evaluated as
@@ -517,6 +533,8 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
minOccurs="0" />
</xsd:sequence>
<xsd:attributeGroup ref="integration:topLevelRouterAttributeGroup"/>
<xsd:attribute name="converter" type="xsd:string">
@@ -713,7 +731,9 @@
<xsd:complexContent>
<xsd:extension base="inputOutputEndpoint">
<xsd:sequence>
<xsd:element ref="xpath-expression" minOccurs="0" maxOccurs="1"/>
<xsd:element ref="xpath-expression" minOccurs="0" />
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="xpath-expression-ref" type="xsd:string" use="optional">
<xsd:annotation>
@@ -842,7 +862,8 @@
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
<xsd:element ref="integration:poller" minOccurs="0"/>
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="discard-channel" type="xsd:string">

View File

@@ -292,7 +292,7 @@
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="transformerType">
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="chat-to" type="headerType">
<xsd:annotation>
<xsd:documentation>
@@ -308,6 +308,7 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element ref="integration:poller" minOccurs="0"/>
</xsd:choice>
<xsd:attribute name="default-overwrite">
<xsd:annotation>

View File

@@ -8,11 +8,15 @@
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">
<channel id="input"/>
<channel id="input">
<queue/>
</channel>
<channel id="output"/>
<xmpp:header-enricher input-channel="input" output-channel="output">
<xmpp:chat-to value="test1@example.org"/>
<poller fixed-delay="100"/>
</xmpp:header-enricher>
</beans:beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -18,22 +18,28 @@ package org.springframework.integration.xmpp.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.doAnswer;
import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.willAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.xmpp.XmppHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -41,32 +47,39 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Mark Fisher
* @author Josh Long
* @author Gunnar Hillert
* @author Artem Bilan
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext
public class XmppHeaderEnricherParserTests {
@Value("#{input}")
private DirectChannel input;
@Autowired
private MessageChannel input;
@Value("#{output}")
@Autowired
private DirectChannel output;
@SuppressWarnings("rawtypes")
@Test
public void to() {
public void to() throws InterruptedException {
MessagingTemplate messagingTemplate = new MessagingTemplate();
CountDownLatch callLatch = new CountDownLatch(1);
MessageHandler handler = mock(MessageHandler.class);
doAnswer(invocation -> {
willAnswer(invocation -> {
Message message = invocation.getArgument(0);
String chatToUser = (String) message.getHeaders().get(XmppHeaders.TO);
assertNotNull(chatToUser);
assertEquals("test1@example.org", chatToUser);
callLatch.countDown();
return null;
}).when(handler).handleMessage(Mockito.any(Message.class));
output.subscribe(handler);
messagingTemplate.send(input, MessageBuilder.withPayload("foo").build());
})
.given(handler)
.handleMessage(Mockito.any(Message.class));
this.output.subscribe(handler);
messagingTemplate.send(this.input, MessageBuilder.withPayload("foo").build());
assertTrue(callLatch.await(10, TimeUnit.SECONDS));
verify(handler, times(1)).handleMessage(Mockito.any(Message.class));
}