Skip to content

Commit 674d5ad

Browse files
artembilangaryrussell
authored andcommitted
INT-4114: Add missed <poller> to XSDs
JIRA: https://jira.spring.io/browse/INT-4114
1 parent fef0a4d commit 674d5ad

File tree

21 files changed

+216
-90
lines changed

21 files changed

+216
-90
lines changed

spring-integration-file/src/main/resources/org/springframework/integration/file/config/spring-integration-file-5.1.xsd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,11 @@ Only files matching this regular expression will be picked up by this adapter.
651651
</xsd:element>
652652

653653
<xsd:complexType name="transformerType">
654+
<xsd:choice minOccurs="0" maxOccurs="2">
655+
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
656+
<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType"
657+
minOccurs="0" maxOccurs="1" />
658+
</xsd:choice>
654659
<xsd:attribute name="id" type="xsd:string">
655660
<xsd:annotation>
656661
<xsd:documentation>

spring-integration-file/src/test/java/org/springframework/integration/file/config/FileToStringTransformerParserTests-context.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@
1313
http://www.springframework.org/schema/integration/file
1414
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
1515

16-
<si:channel id="input"/>
16+
<si:channel id="input">
17+
<si:queue/>
18+
</si:channel>
1719

1820
<si:channel id="output"/>
1921

2022
<file:file-to-string-transformer id="transformer"
2123
input-channel="input"
2224
delete-files="${files.delete}"
23-
output-channel="output"/>
25+
output-channel="output">
26+
<si:poller fixed-delay="100"/>
27+
</file:file-to-string-transformer>
2428

2529
<context:property-placeholder location="org/springframework/integration/file/config/fileToStringTransformerParserTests.properties"/>
2630

spring-integration-file/src/test/java/org/springframework/integration/file/config/FileToStringTransformerParserTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,23 +24,26 @@
2424
import org.springframework.beans.DirectFieldAccessor;
2525
import org.springframework.beans.factory.annotation.Autowired;
2626
import org.springframework.beans.factory.annotation.Qualifier;
27-
import org.springframework.integration.endpoint.EventDrivenConsumer;
27+
import org.springframework.integration.endpoint.PollingConsumer;
2828
import org.springframework.integration.file.transformer.FileToStringTransformer;
2929
import org.springframework.integration.transformer.MessageTransformingHandler;
30+
import org.springframework.test.annotation.DirtiesContext;
3031
import org.springframework.test.context.ContextConfiguration;
3132
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
3233

3334
/**
3435
* @author Mark Fisher
3536
* @author Gary Russell
37+
* @author Artem Bilan
3638
*/
3739
@ContextConfiguration
3840
@RunWith(SpringJUnit4ClassRunner.class)
41+
@DirtiesContext
3942
public class FileToStringTransformerParserTests {
4043

4144
@Autowired
4245
@Qualifier("transformer")
43-
EventDrivenConsumer endpoint;
46+
PollingConsumer endpoint;
4447

4548
@Test
4649
public void checkDeleteFilesValue() {

spring-integration-jms/src/main/resources/org/springframework/integration/jms/config/spring-integration-jms-5.1.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,7 @@
13871387
</xsd:documentation>
13881388
</xsd:annotation>
13891389
</xsd:element>
1390+
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
13901391
</xsd:choice>
13911392
<xsd:attribute name="default-overwrite">
13921393
<xsd:annotation>
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<beans xmlns="http://www.springframework.org/schema/beans"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xmlns:integration="http://www.springframework.org/schema/integration"
4+
xmlns:int="http://www.springframework.org/schema/integration"
55
xmlns:jms="http://www.springframework.org/schema/integration/jms"
66
xsi:schemaLocation="http://www.springframework.org/schema/beans
77
http://www.springframework.org/schema/beans/spring-beans.xsd
@@ -10,9 +10,14 @@
1010
http://www.springframework.org/schema/integration/jms
1111
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
1212

13+
<int:channel id="valueTestInput">
14+
<int:queue/>
15+
</int:channel>
16+
1317
<jms:header-enricher input-channel="valueTestInput" output-channel="output">
1418
<jms:reply-to ref="testDestination"/>
1519
<jms:correlation-id value="ABC"/>
20+
<int:poller fixed-delay="100"/>
1621
</jms:header-enricher>
1722

1823
<jms:header-enricher input-channel="expressionTestInput" output-channel="output">
@@ -21,8 +26,8 @@
2126

2227
<bean id="testDestination" class="org.springframework.integration.jms.StubDestination"/>
2328

24-
<integration:channel id="output">
25-
<integration:queue capacity="1"/>
26-
</integration:channel>
29+
<int:channel id="output">
30+
<int:queue capacity="1"/>
31+
</int:channel>
2732

2833
</beans>

spring-integration-jms/src/test/java/org/springframework/integration/jms/config/JmsHeaderEnricherTests.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@
3939
* @author Mark Fisher
4040
* @author Oleg Zhurakousky
4141
* @author Gary Russell
42+
* @author Artem Bilan
4243
*/
4344
@ContextConfiguration
4445
@RunWith(SpringJUnit4ClassRunner.class)
@@ -59,19 +60,19 @@ public class JmsHeaderEnricherTests {
5960

6061
@Test // INT-804
6162
public void verifyReplyToValue() throws Exception {
62-
valueTestInput.send(new GenericMessage<String>("test"));
63-
Message<?> result = output.receive(0);
64-
assertEquals(testDestination, result.getHeaders().get(JmsHeaders.REPLY_TO));
63+
this.valueTestInput.send(new GenericMessage<>("test"));
64+
Message<?> result = output.receive(10_000);
65+
assertEquals(this.testDestination, result.getHeaders().get(JmsHeaders.REPLY_TO));
6566
StubTextMessage jmsMessage = new StubTextMessage();
6667
DefaultJmsHeaderMapper headerMapper = new DefaultJmsHeaderMapper();
6768
headerMapper.fromHeaders(result.getHeaders(), jmsMessage);
68-
assertEquals(testDestination, jmsMessage.getJMSReplyTo());
69+
assertEquals(this.testDestination, jmsMessage.getJMSReplyTo());
6970
}
7071

7172
@Test
7273
public void verifyCorrelationIdValue() throws Exception {
73-
valueTestInput.send(new GenericMessage<String>("test"));
74-
Message<?> result = output.receive(0);
74+
this.valueTestInput.send(new GenericMessage<>("test"));
75+
Message<?> result = output.receive(10_000);
7576
assertEquals("ABC", result.getHeaders().get(JmsHeaders.CORRELATION_ID));
7677
StubTextMessage jmsMessage = new StubTextMessage();
7778
DefaultJmsHeaderMapper headerMapper = new DefaultJmsHeaderMapper();
@@ -81,7 +82,7 @@ public void verifyCorrelationIdValue() throws Exception {
8182

8283
@Test // see INT-1122 and INT-1123
8384
public void verifyCorrelationIdExpression() throws Exception {
84-
expressionTestInput.send(new GenericMessage<String>("test"));
85+
this.expressionTestInput.send(new GenericMessage<>("test"));
8586
Message<?> result = output.receive(0);
8687
assertEquals(123, result.getHeaders().get(JmsHeaders.CORRELATION_ID));
8788
StubTextMessage jmsMessage = new StubTextMessage();

spring-integration-mail/src/main/resources/org/springframework/integration/mail/config/spring-integration-mail-5.1.xsd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@
298298
</xsd:annotation>
299299
<xsd:complexContent>
300300
<xsd:extension base="transformerType">
301+
<xsd:sequence>
302+
<xsd:element ref="integration:poller" minOccurs="0"/>
303+
</xsd:sequence>
301304
<xsd:attribute name="charset" type="xsd:string"/>
302305
</xsd:extension>
303306
</xsd:complexContent>
@@ -314,7 +317,7 @@
314317
</xsd:annotation>
315318
<xsd:complexContent>
316319
<xsd:extension base="transformerType">
317-
<xsd:choice minOccurs="1" maxOccurs="unbounded">
320+
<xsd:choice maxOccurs="unbounded">
318321
<xsd:element name="subject" type="headerType"/>
319322
<xsd:element name="to" type="headerType"/>
320323
<xsd:element name="cc" type="headerType"/>
@@ -324,6 +327,7 @@
324327
<xsd:element name="content-type" type="headerType"/>
325328
<xsd:element name="attachment-filename" type="headerType"/>
326329
<xsd:element name="multipart-mode" type="headerType"/>
330+
<xsd:element ref="integration:poller" minOccurs="0"/>
327331
</xsd:choice>
328332
<xsd:attribute name="default-overwrite">
329333
<xsd:annotation>

spring-integration-mail/src/test/java/org/springframework/integration/mail/config/MailHeaderEnricherTests-context.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
<beans:beans xmlns="http://www.springframework.org/schema/integration/mail"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns:beans="http://www.springframework.org/schema/beans"
5+
xmlns:int="http://www.springframework.org/schema/integration"
56
xsi:schemaLocation="http://www.springframework.org/schema/beans
67
http://www.springframework.org/schema/beans/spring-beans.xsd
8+
http://www.springframework.org/schema/integration
9+
http://www.springframework.org/schema/integration/spring-integration.xsd
710
http://www.springframework.org/schema/integration/mail
811
http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd">
912

@@ -18,7 +21,12 @@
1821
<multipart-mode value="1"/>
1922
</header-enricher>
2023

24+
<int:channel id="expressionsInput">
25+
<int:queue />
26+
</int:channel>
27+
2128
<header-enricher input-channel="expressionsInput">
29+
<int:poller fixed-delay="100"/>
2230
<to expression="payload + '.to'"/>
2331
<cc expression="payload + '.cc'"/>
2432
<bcc expression="payload + '.bcc'"/>

spring-integration-mail/src/test/java/org/springframework/integration/mail/config/MailHeaderEnricherTests.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,14 +30,17 @@
3030
import org.springframework.messaging.Message;
3131
import org.springframework.messaging.MessageChannel;
3232
import org.springframework.messaging.support.GenericMessage;
33+
import org.springframework.test.annotation.DirtiesContext;
3334
import org.springframework.test.context.ContextConfiguration;
3435
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
3536

3637
/**
3738
* @author Mark Fisher
39+
* @author Artem Bilan
3840
*/
3941
@ContextConfiguration
4042
@RunWith(SpringJUnit4ClassRunner.class)
43+
@DirtiesContext
4144
public class MailHeaderEnricherTests {
4245

4346
@Autowired
@@ -51,8 +54,8 @@ public class MailHeaderEnricherTests {
5154
@Test
5255
public void literalValues() {
5356
MessagingTemplate template = new MessagingTemplate();
54-
template.setDefaultDestination(literalValuesInput);
55-
Message<?> result = template.sendAndReceive(new GenericMessage<String>("test"));
57+
template.setDefaultDestination(this.literalValuesInput);
58+
Message<?> result = template.sendAndReceive(new GenericMessage<>("test"));
5659
Map<String, Object> headers = result.getHeaders();
5760
assertEquals("test.to", headers.get(MailHeaders.TO));
5861
assertEquals("test.cc", headers.get(MailHeaders.CC));
@@ -67,8 +70,8 @@ public void literalValues() {
6770
@Test
6871
public void expressions() {
6972
MessagingTemplate template = new MessagingTemplate();
70-
template.setDefaultDestination(expressionsInput);
71-
Message<?> result = template.sendAndReceive(new GenericMessage<String>("foo"));
73+
template.setDefaultDestination(this.expressionsInput);
74+
Message<?> result = template.sendAndReceive(new GenericMessage<>("foo"));
7275
Map<String, Object> headers = result.getHeaders();
7376
assertEquals("foo.to", headers.get(MailHeaders.TO));
7477
assertEquals("foo.cc", headers.get(MailHeaders.CC));

spring-integration-mail/src/test/java/org/springframework/integration/mail/config/MailToStringTransformerParserTests.java

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222

2323
import javax.mail.internet.MimeMessage;
2424

25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626
import org.mockito.Mockito;
2727

2828
import org.springframework.beans.factory.BeanDefinitionStoreException;
@@ -38,47 +38,52 @@
3838
* @author Mark Fisher
3939
* @author Artem Bilan
4040
*/
41-
public class MailToStringTransformerParserTests {
41+
class MailToStringTransformerParserTests {
4242

4343
@Test
44-
public void topLevelTransformer() throws Exception {
45-
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
46-
"mailToStringTransformerParserTests.xml", this.getClass());
47-
MessageChannel input = new BeanFactoryChannelResolver(context).resolveDestination("input");
48-
PollableChannel output = (PollableChannel) new BeanFactoryChannelResolver(context).resolveDestination("output");
49-
MimeMessage mimeMessage = Mockito.mock(MimeMessage.class);
50-
Mockito.when(mimeMessage.getContent()).thenReturn("hello");
51-
input.send(new GenericMessage<javax.mail.Message>(mimeMessage));
52-
Message<?> result = output.receive(0);
53-
assertNotNull(result);
54-
assertEquals("hello", result.getPayload());
55-
Mockito.verify(mimeMessage).getContent();
44+
void topLevelTransformer() throws Exception {
45+
try (ClassPathXmlApplicationContext context =
46+
new ClassPathXmlApplicationContext("mailToStringTransformerParserTests.xml", this.getClass());) {
47+
48+
MessageChannel input = new BeanFactoryChannelResolver(context).resolveDestination("input");
49+
PollableChannel output =
50+
(PollableChannel) new BeanFactoryChannelResolver(context).resolveDestination("output");
51+
MimeMessage mimeMessage = Mockito.mock(MimeMessage.class);
52+
Mockito.when(mimeMessage.getContent()).thenReturn("hello");
53+
input.send(new GenericMessage<javax.mail.Message>(mimeMessage));
54+
Message<?> result = output.receive(10_000);
55+
assertNotNull(result);
56+
assertEquals("hello", result.getPayload());
57+
Mockito.verify(mimeMessage).getContent();
58+
}
5659
}
5760

5861
@Test
59-
public void transformerWithinChain() throws Exception {
60-
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
61-
"mailToStringTransformerWithinChain.xml", this.getClass());
62-
MessageChannel input = new BeanFactoryChannelResolver(context).resolveDestination("input");
63-
PollableChannel output = (PollableChannel) new BeanFactoryChannelResolver(context).resolveDestination("output");
64-
MimeMessage mimeMessage = Mockito.mock(MimeMessage.class);
65-
Mockito.when(mimeMessage.getContent()).thenReturn("foo");
66-
input.send(new GenericMessage<javax.mail.Message>(mimeMessage));
67-
Message<?> result = output.receive(0);
68-
assertNotNull(result);
69-
assertEquals("FOO!!!", result.getPayload());
70-
Mockito.verify(mimeMessage).getContent();
62+
void transformerWithinChain() throws Exception {
63+
try (ClassPathXmlApplicationContext context =
64+
new ClassPathXmlApplicationContext("mailToStringTransformerWithinChain.xml", this.getClass());) {
65+
66+
MessageChannel input = new BeanFactoryChannelResolver(context).resolveDestination("input");
67+
PollableChannel output =
68+
(PollableChannel) new BeanFactoryChannelResolver(context).resolveDestination("output");
69+
MimeMessage mimeMessage = Mockito.mock(MimeMessage.class);
70+
Mockito.when(mimeMessage.getContent()).thenReturn("foo");
71+
input.send(new GenericMessage<javax.mail.Message>(mimeMessage));
72+
Message<?> result = output.receive(0);
73+
assertNotNull(result);
74+
assertEquals("FOO!!!", result.getPayload());
75+
Mockito.verify(mimeMessage).getContent();
76+
}
7177
}
7278

73-
@Test(expected = BeanDefinitionStoreException.class)
74-
public void topLevelTransformerMissingInput() {
79+
@Test
80+
void topLevelTransformerMissingInput() {
7581
try {
7682
new ClassPathXmlApplicationContext("mailToStringTransformerWithoutInputChannel.xml", this.getClass())
7783
.close();
7884
}
7985
catch (BeanDefinitionStoreException e) {
8086
assertTrue(e.getMessage().contains("input-channel"));
81-
throw e;
8287
}
8388
}
8489

0 commit comments

Comments
 (0)