Fix some tests for not closed application context

This commit is contained in:
Artem Bilan
2020-02-11 12:41:42 -05:00
parent aeab030104
commit ede9528c19
4 changed files with 106 additions and 72 deletions

View File

@@ -17,6 +17,7 @@
package org.springframework.integration.config.xml; package org.springframework.integration.config.xml;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.util.Collection; import java.util.Collection;
@@ -25,13 +26,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.junit.Test; import org.junit.jupiter.api.AfterEach;
import org.junit.runner.RunWith; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.InputStreamResource;
import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.integration.IntegrationMessageHeaderAccessor;
@@ -42,8 +44,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel; import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage; import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -51,18 +52,27 @@ import org.springframework.util.StringUtils;
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
* @author Gunnar Hillert * @author Gunnar Hillert
* @author Gary Russell * @author Gary Russell
* @author Artem Bilan
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @SpringJUnitConfig
@ContextConfiguration
public class InnerDefinitionHandlerAwareEndpointParserTests { public class InnerDefinitionHandlerAwareEndpointParserTests {
@Autowired @Autowired
private Properties testConfigurations; private Properties testConfigurations;
private ConfigurableApplicationContext applicationContext;
@AfterEach
public void tearDown() {
if (this.applicationContext != null) {
this.applicationContext.close();
}
}
@Test @Test
public void testInnerSplitterDefinitionSuccess() { public void testInnerSplitterDefinitionSuccess() {
String configProperty = testConfigurations.getProperty("splitter-inner-success"); String configProperty = testConfigurations.getProperty("splitter-inner-success");
this.testSplitterDefinitionSuccess(configProperty); testSplitterDefinitionSuccess(configProperty);
} }
@Test @Test
@@ -83,10 +93,11 @@ public class InnerDefinitionHandlerAwareEndpointParserTests {
this.testSplitterDefinitionSuccess(configProperty); this.testSplitterDefinitionSuccess(configProperty);
} }
@Test(expected = BeanDefinitionStoreException.class) @Test
public void testInnerSplitterDefinitionFailureRefAndInner() { public void testInnerSplitterDefinitionFailureRefAndInner() {
String xmlConfig = testConfigurations.getProperty("splitter-failure-refAndBean"); String xmlConfig = testConfigurations.getProperty("splitter-failure-refAndBean");
this.bootStrap(xmlConfig); assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> bootStrap(xmlConfig));
} }
@Test @Test
@@ -98,31 +109,33 @@ public class InnerDefinitionHandlerAwareEndpointParserTests {
@Test @Test
public void testRefTransformerDefinitionSuccess() { public void testRefTransformerDefinitionSuccess() {
String configProperty = testConfigurations.getProperty("transformer-ref-success"); String configProperty = testConfigurations.getProperty("transformer-ref-success");
this.testTransformerDefinitionSuccess(configProperty); testTransformerDefinitionSuccess(configProperty);
} }
@Test(expected = BeanDefinitionStoreException.class) @Test
public void testInnerTransformerDefinitionFailureRefAndInner() { public void testInnerTransformerDefinitionFailureRefAndInner() {
String xmlConfig = testConfigurations.getProperty("transformer-failure-refAndBean"); String xmlConfig = testConfigurations.getProperty("transformer-failure-refAndBean");
this.bootStrap(xmlConfig); assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> bootStrap(xmlConfig));
} }
@Test @Test
public void testInnerRouterDefinitionSuccess() { public void testInnerRouterDefinitionSuccess() {
String configProperty = testConfigurations.getProperty("router-inner-success"); String configProperty = testConfigurations.getProperty("router-inner-success");
this.testRouterDefinitionSuccess(configProperty); testRouterDefinitionSuccess(configProperty);
} }
@Test @Test
public void testRefRouterDefinitionSuccess() { public void testRefRouterDefinitionSuccess() {
String configProperty = testConfigurations.getProperty("router-ref-success"); String configProperty = testConfigurations.getProperty("router-ref-success");
this.testRouterDefinitionSuccess(configProperty); testRouterDefinitionSuccess(configProperty);
} }
@Test(expected = BeanDefinitionStoreException.class) @Test
public void testInnerRouterDefinitionFailureRefAndInner() { public void testInnerRouterDefinitionFailureRefAndInner() {
String xmlConfig = testConfigurations.getProperty("router-failure-refAndBean"); String xmlConfig = testConfigurations.getProperty("router-failure-refAndBean");
this.bootStrap(xmlConfig); assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> bootStrap(xmlConfig));
} }
@Test @Test
@@ -137,10 +150,11 @@ public class InnerDefinitionHandlerAwareEndpointParserTests {
this.testSADefinitionSuccess(configProperty); this.testSADefinitionSuccess(configProperty);
} }
@Test(expected = BeanDefinitionStoreException.class) @Test
public void testInnerSADefinitionFailureRefAndInner() { public void testInnerSADefinitionFailureRefAndInner() {
String xmlConfig = testConfigurations.getProperty("sa-failure-refAndBean"); String xmlConfig = testConfigurations.getProperty("sa-failure-refAndBean");
this.bootStrap(xmlConfig); assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> bootStrap(xmlConfig));
} }
@Test @Test
@@ -157,7 +171,8 @@ public class InnerDefinitionHandlerAwareEndpointParserTests {
@Test @Test
public void testInnerConcurrentAggregatorDefinitionSuccessReorderBeanPoller() { public void testInnerConcurrentAggregatorDefinitionSuccessReorderBeanPoller() {
String configProperty = testConfigurations.getProperty("aggregator-inner-concurrent-success-reorder-bean-poller"); String configProperty = testConfigurations
.getProperty("aggregator-inner-concurrent-success-reorder-bean-poller");
this.testAggregatorDefinitionSuccess(configProperty); this.testAggregatorDefinitionSuccess(configProperty);
} }
@@ -167,10 +182,11 @@ public class InnerDefinitionHandlerAwareEndpointParserTests {
this.testAggregatorDefinitionSuccess(configProperty); this.testAggregatorDefinitionSuccess(configProperty);
} }
@Test(expected = BeanDefinitionStoreException.class) @Test
public void testInnerAggregatorDefinitionFailureRefAndInner() { public void testInnerAggregatorDefinitionFailureRefAndInner() {
String xmlConfig = testConfigurations.getProperty("aggregator-failure-refAndBean"); String xmlConfig = testConfigurations.getProperty("aggregator-failure-refAndBean");
this.bootStrap(xmlConfig); assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> bootStrap(xmlConfig));
} }
@Test @Test
@@ -185,103 +201,104 @@ public class InnerDefinitionHandlerAwareEndpointParserTests {
this.testFilterDefinitionSuccess(configProperty); this.testFilterDefinitionSuccess(configProperty);
} }
@Test(expected = BeanDefinitionStoreException.class) @Test
public void testInnerFilterDefinitionFailureRefAndInner() { public void testInnerFilterDefinitionFailureRefAndInner() {
String xmlConfig = testConfigurations.getProperty("filter-failure-refAndBean"); String xmlConfig = testConfigurations.getProperty("filter-failure-refAndBean");
this.bootStrap(xmlConfig); assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> bootStrap(xmlConfig));
} }
private void testSplitterDefinitionSuccess(String configProperty) { private void testSplitterDefinitionSuccess(String configProperty) {
ApplicationContext ac = this.bootStrap(configProperty); bootStrap(configProperty);
EventDrivenConsumer splitter = (EventDrivenConsumer) ac.getBean("testSplitter"); EventDrivenConsumer splitter = this.applicationContext.getBean("testSplitter", EventDrivenConsumer.class);
assertThat(splitter).isNotNull(); assertThat(splitter).isNotNull();
MessageBuilder<String[]> inChannelMessageBuilder = MessageBuilder.withPayload(new String[]{"One", "Two"}); MessageBuilder<String[]> inChannelMessageBuilder = MessageBuilder.withPayload(new String[] { "One", "Two" });
Message<String[]> inMessage = inChannelMessageBuilder.build(); Message<String[]> inMessage = inChannelMessageBuilder.build();
MessageChannel inChannel = (MessageChannel) ac.getBean("inChannel"); MessageChannel inChannel = this.applicationContext.getBean("inChannel", MessageChannel.class);
inChannel.send(inMessage); inChannel.send(inMessage);
PollableChannel outChannel = (PollableChannel) ac.getBean("outChannel"); PollableChannel outChannel = this.applicationContext.getBean("outChannel", PollableChannel.class);
assertThat(outChannel.receive().getPayload() instanceof String).isTrue(); assertThat(outChannel.receive().getPayload() instanceof String).isTrue();
outChannel = (PollableChannel) ac.getBean("outChannel"); outChannel = this.applicationContext.getBean("outChannel", PollableChannel.class);
assertThat(outChannel.receive().getPayload() instanceof String).isTrue(); assertThat(outChannel.receive().getPayload() instanceof String).isTrue();
} }
private void testTransformerDefinitionSuccess(String configProperty) { private void testTransformerDefinitionSuccess(String configProperty) {
ApplicationContext ac = this.bootStrap(configProperty); bootStrap(configProperty);
EventDrivenConsumer transformer = (EventDrivenConsumer) ac.getBean("testTransformer"); EventDrivenConsumer transformer = this.applicationContext.getBean("testTransformer", EventDrivenConsumer.class);
assertThat(transformer).isNotNull(); assertThat(transformer).isNotNull();
MessageBuilder<String[]> inChannelMessageBuilder = MessageBuilder.withPayload(new String[]{"One", "Two"}); MessageBuilder<String[]> inChannelMessageBuilder = MessageBuilder.withPayload(new String[] { "One", "Two" });
Message<String[]> inMessage = inChannelMessageBuilder.build(); Message<String[]> inMessage = inChannelMessageBuilder.build();
DirectChannel inChannel = (DirectChannel) ac.getBean("inChannel"); DirectChannel inChannel = this.applicationContext.getBean("inChannel", DirectChannel.class);
inChannel.send(inMessage); inChannel.send(inMessage);
PollableChannel outChannel = (PollableChannel) ac.getBean("outChannel"); PollableChannel outChannel = this.applicationContext.getBean("outChannel", PollableChannel.class);
String payload = (String) outChannel.receive().getPayload(); String payload = (String) outChannel.receive().getPayload();
assertThat(payload.equals("One,Two")).isTrue(); assertThat(payload.equals("One,Two")).isTrue();
} }
private void testRouterDefinitionSuccess(String configProperty) { private void testRouterDefinitionSuccess(String configProperty) {
ApplicationContext ac = this.bootStrap(configProperty); bootStrap(configProperty);
EventDrivenConsumer splitter = (EventDrivenConsumer) ac.getBean("testRouter"); EventDrivenConsumer splitter = this.applicationContext.getBean("testRouter", EventDrivenConsumer.class);
assertThat(splitter).isNotNull(); assertThat(splitter).isNotNull();
MessageBuilder<String> inChannelMessageBuilder = MessageBuilder.withPayload("1"); MessageBuilder<String> inChannelMessageBuilder = MessageBuilder.withPayload("1");
Message<String> inMessage = inChannelMessageBuilder.build(); Message<String> inMessage = inChannelMessageBuilder.build();
DirectChannel inChannel = (DirectChannel) ac.getBean("inChannel"); DirectChannel inChannel = this.applicationContext.getBean("inChannel", DirectChannel.class);
inChannel.send(inMessage); inChannel.send(inMessage);
PollableChannel channel1 = (PollableChannel) ac.getBean("channel1"); PollableChannel channel1 = this.applicationContext.getBean("channel1", PollableChannel.class);
assertThat(channel1.receive().getPayload().equals("1")).isTrue(); assertThat(channel1.receive().getPayload().equals("1")).isTrue();
inChannelMessageBuilder = MessageBuilder.withPayload("2"); inChannelMessageBuilder = MessageBuilder.withPayload("2");
inMessage = inChannelMessageBuilder.build(); inMessage = inChannelMessageBuilder.build();
inChannel.send(inMessage); inChannel.send(inMessage);
PollableChannel channel2 = (PollableChannel) ac.getBean("channel2"); PollableChannel channel2 = this.applicationContext.getBean("channel2", PollableChannel.class);
assertThat(channel2.receive().getPayload().equals("2")).isTrue(); assertThat(channel2.receive().getPayload().equals("2")).isTrue();
} }
private void testSADefinitionSuccess(String configProperty) { private void testSADefinitionSuccess(String configProperty) {
ApplicationContext ac = this.bootStrap(configProperty); bootStrap(configProperty);
EventDrivenConsumer splitter = (EventDrivenConsumer) ac.getBean("testServiceActivator"); EventDrivenConsumer splitter = this.applicationContext
.getBean("testServiceActivator", EventDrivenConsumer.class);
assertThat(splitter).isNotNull(); assertThat(splitter).isNotNull();
MessageBuilder<String> inChannelMessageBuilder = MessageBuilder.withPayload("1"); MessageBuilder<String> inChannelMessageBuilder = MessageBuilder.withPayload("1");
Message<String> inMessage = inChannelMessageBuilder.build(); Message<String> inMessage = inChannelMessageBuilder.build();
DirectChannel inChannel = (DirectChannel) ac.getBean("inChannel"); DirectChannel inChannel = this.applicationContext.getBean("inChannel", DirectChannel.class);
inChannel.send(inMessage); inChannel.send(inMessage);
PollableChannel channel1 = (PollableChannel) ac.getBean("outChannel"); PollableChannel channel1 = this.applicationContext.getBean("outChannel", PollableChannel.class);
assertThat(channel1.receive().getPayload().equals("1")).isTrue(); assertThat(channel1.receive().getPayload().equals("1")).isTrue();
} }
private void testAggregatorDefinitionSuccess(String configProperty) { private void testAggregatorDefinitionSuccess(String configProperty) {
ApplicationContext ac = this.bootStrap(configProperty); bootStrap(configProperty);
MessageChannel inChannel = (MessageChannel) ac.getBean("inChannel"); MessageChannel inChannel = this.applicationContext.getBean("inChannel", MessageChannel.class);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
Map<String, Object> headers = stubHeaders(i, 5, 1); Map<String, Object> headers = stubHeaders(i, 5, 1);
Message<Integer> message = MessageBuilder.withPayload(i).copyHeaders(headers).build(); Message<Integer> message = MessageBuilder.withPayload(i).copyHeaders(headers).build();
inChannel.send(message); inChannel.send(message);
} }
PollableChannel output = (PollableChannel) ac.getBean("outChannel"); PollableChannel output = this.applicationContext.getBean("outChannel", PollableChannel.class);
Message<?> receivedMessage = output.receive(10000); Message<?> receivedMessage = output.receive(10000);
assertThat(receivedMessage).isNotNull(); assertThat(receivedMessage).isNotNull();
assertThat(receivedMessage.getPayload()).isEqualTo(0 + 1 + 2 + 3 + 4); assertThat(receivedMessage.getPayload()).isEqualTo(0 + 1 + 2 + 3 + 4);
} }
private void testFilterDefinitionSuccess(String configProperty) { private void testFilterDefinitionSuccess(String configProperty) {
ApplicationContext ac = this.bootStrap(configProperty); bootStrap(configProperty);
MessageChannel input = (MessageChannel) ac.getBean("inChannel"); MessageChannel input = this.applicationContext.getBean("inChannel", MessageChannel.class);
PollableChannel output = (PollableChannel) ac.getBean("outChannel"); PollableChannel output = this.applicationContext.getBean("outChannel", PollableChannel.class);
input.send(new GenericMessage<String>("foo")); input.send(new GenericMessage<>("foo"));
Message<?> reply = output.receive(0); Message<?> reply = output.receive(0);
assertThat(reply.getPayload()).isEqualTo("foo"); assertThat(reply.getPayload()).isEqualTo("foo");
} }
private ApplicationContext bootStrap(String configProperty) { private void bootStrap(String configProperty) {
ByteArrayInputStream stream = new ByteArrayInputStream(configProperty.getBytes()); ByteArrayInputStream stream = new ByteArrayInputStream(configProperty.getBytes());
GenericApplicationContext ac = new GenericApplicationContext(); this.applicationContext = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ac); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.applicationContext);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
reader.loadBeanDefinitions(new InputStreamResource(stream)); reader.loadBeanDefinitions(new InputStreamResource(stream));
ac.refresh(); this.applicationContext.refresh();
return ac;
} }
private Map<String, Object> stubHeaders(int sequenceNumber, int sequenceSize, int correllationId) { private Map<String, Object> stubHeaders(int sequenceNumber, int sequenceSize, int correllationId) {
Map<String, Object> headers = new HashMap<String, Object>(); Map<String, Object> headers = new HashMap<>();
headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, sequenceNumber); headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, sequenceNumber);
headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE, sequenceSize); headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE, sequenceSize);
headers.put(IntegrationMessageHeaderAccessor.CORRELATION_ID, correllationId); headers.put(IntegrationMessageHeaderAccessor.CORRELATION_ID, correllationId);
@@ -290,30 +307,39 @@ public class InnerDefinitionHandlerAwareEndpointParserTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static class TestSplitter { public static class TestSplitter {
public Collection<String> split(String[] payload) { public Collection<String> split(String[] payload) {
return CollectionUtils.arrayToList(payload); return CollectionUtils.arrayToList(payload);
} }
} }
public static class TestTransformer { public static class TestTransformer {
public String split(String[] payload) { public String split(String[] payload) {
return StringUtils.arrayToDelimitedString(payload, ","); return StringUtils.arrayToDelimitedString(payload, ",");
} }
} }
public static class TestRouter { public static class TestRouter {
public String route(String value) { public String route(String value) {
return (value.equals("1")) ? "channel1" : "channel2"; return (value.equals("1")) ? "channel1" : "channel2";
} }
} }
public static class TestServiceActivator { public static class TestServiceActivator {
public String foo(String value) { public String foo(String value) {
return value; return value;
} }
} }
public static class TestAggregator { public static class TestAggregator {
public Integer sum(List<Integer> numbers) { public Integer sum(List<Integer> numbers) {
int result = 0; int result = 0;
for (Integer number : numbers) { for (Integer number : numbers) {
@@ -321,12 +347,15 @@ public class InnerDefinitionHandlerAwareEndpointParserTests {
} }
return result; return result;
} }
} }
public static class TestMessageFilter { public static class TestMessageFilter {
public boolean filter(String value) { public boolean filter(String value) {
return value.equals("foo"); return value.equals("foo");
} }
} }
} }

View File

@@ -18,43 +18,50 @@ package org.springframework.integration.router.config;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.channel.QueueChannel;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.GenericMessage; import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/** /**
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
* @author Gunnar Hillert * @author Gunnar Hillert
* @author Artem Bilan
* *
*/ */
@SpringJUnitConfig
@DirtiesContext
public class ExceptionTypeRouterParserTests { public class ExceptionTypeRouterParserTests {
@Autowired
private ApplicationContext context;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testExceptionTypeRouterConfig() { public void testExceptionTypeRouterConfig() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( MessageChannel inputChannel = this.context.getBean("inChannel", MessageChannel.class);
"ExceptionTypeRouterParserTests-context.xml", this.getClass());
MessageChannel inputChannel = context.getBean("inChannel", MessageChannel.class);
inputChannel.send(new GenericMessage<Throwable>(new NullPointerException())); inputChannel.send(new GenericMessage<Throwable>(new NullPointerException()));
QueueChannel nullPointerChannel = context.getBean("nullPointerChannel", QueueChannel.class); QueueChannel nullPointerChannel = this.context.getBean("nullPointerChannel", QueueChannel.class);
Message<Throwable> npeMessage = (Message<Throwable>) nullPointerChannel.receive(1000); Message<Throwable> npeMessage = (Message<Throwable>) nullPointerChannel.receive(1000);
assertThat(npeMessage).isNotNull(); assertThat(npeMessage).isNotNull();
assertThat(npeMessage.getPayload() instanceof NullPointerException).isTrue(); assertThat(npeMessage.getPayload() instanceof NullPointerException).isTrue();
inputChannel.send(new GenericMessage<Throwable>(new IllegalArgumentException())); inputChannel.send(new GenericMessage<Throwable>(new IllegalArgumentException()));
QueueChannel illegalArgumentChannel = context.getBean("illegalArgumentChannel", QueueChannel.class); QueueChannel illegalArgumentChannel = this.context.getBean("illegalArgumentChannel", QueueChannel.class);
Message<Throwable> iaMessage = (Message<Throwable>) illegalArgumentChannel.receive(1000); Message<Throwable> iaMessage = (Message<Throwable>) illegalArgumentChannel.receive(1000);
assertThat(iaMessage).isNotNull(); assertThat(iaMessage).isNotNull();
assertThat(iaMessage.getPayload() instanceof IllegalArgumentException).isTrue(); assertThat(iaMessage.getPayload() instanceof IllegalArgumentException).isTrue();
inputChannel.send(new GenericMessage<String>("Hello")); inputChannel.send(new GenericMessage<>("Hello"));
QueueChannel outputChannel = context.getBean("outputChannel", QueueChannel.class); QueueChannel outputChannel = this.context.getBean("outputChannel", QueueChannel.class);
assertThat(outputChannel.receive(1000)).isNotNull(); assertThat(outputChannel.receive(1000)).isNotNull();
context.close();
} }
} }

View File

@@ -33,8 +33,7 @@ import org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizingMe
import org.springframework.integration.metadata.SimpleMetadataStore; import org.springframework.integration.metadata.SimpleMetadataStore;
/** /**
* A {@link RemoteFileInboundChannelAdapterSpec} for a * A {@link RemoteFileInboundChannelAdapterSpec} for an {@link FtpInboundFileSynchronizingMessageSource}.
* {@link FtpInboundFileSynchronizingMessageSource}.
* *
* @author Artem Bilan * @author Artem Bilan
* *
@@ -71,7 +70,6 @@ public class FtpInboundChannelAdapterSpec
return filter(composeFilters(new FtpRegexPatternFileListFilter(regex))); return filter(composeFilters(new FtpRegexPatternFileListFilter(regex)));
} }
@SuppressWarnings("unchecked")
private CompositeFileListFilter<FTPFile> composeFilters(FileListFilter<FTPFile> fileListFilter) { private CompositeFileListFilter<FTPFile> composeFilters(FileListFilter<FTPFile> fileListFilter) {
CompositeFileListFilter<FTPFile> compositeFileListFilter = new CompositeFileListFilter<>(); CompositeFileListFilter<FTPFile> compositeFileListFilter = new CompositeFileListFilter<>();
compositeFileListFilter.addFilters(fileListFilter, compositeFileListFilter.addFilters(fileListFilter,

View File

@@ -33,9 +33,10 @@ import org.springframework.integration.sftp.inbound.SftpInboundFileSynchronizing
import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.ChannelSftp;
/** /**
* A {@link RemoteFileInboundChannelAdapterSpec} for a {@link SftpInboundFileSynchronizingMessageSource}. * A {@link RemoteFileInboundChannelAdapterSpec} for an {@link SftpInboundFileSynchronizingMessageSource}.
* *
* @author Artem Bilan * @author Artem Bilan
*
* @since 5.0 * @since 5.0
*/ */
public class SftpInboundChannelAdapterSpec public class SftpInboundChannelAdapterSpec
@@ -69,7 +70,6 @@ public class SftpInboundChannelAdapterSpec
return filter(composeFilters(new SftpRegexPatternFileListFilter(regex))); return filter(composeFilters(new SftpRegexPatternFileListFilter(regex)));
} }
@SuppressWarnings("unchecked")
private CompositeFileListFilter<ChannelSftp.LsEntry> composeFilters(FileListFilter<ChannelSftp.LsEntry> private CompositeFileListFilter<ChannelSftp.LsEntry> composeFilters(FileListFilter<ChannelSftp.LsEntry>
fileListFilter) { fileListFilter) {
CompositeFileListFilter<ChannelSftp.LsEntry> compositeFileListFilter = new CompositeFileListFilter<>(); CompositeFileListFilter<ChannelSftp.LsEntry> compositeFileListFilter = new CompositeFileListFilter<>();