INT-2404 Fix Auto-Created Channel; Event, TCP, UDP

The AbstractChannelAdapterParser creates an implicit DirectChannel
if the adapter has no 'channel' attribute.

The Event, TCP, and UDP channel adapter parsers did not bind
this channel to the adapter and AC initialization failed with
'outputChannel is required'.

Further, the event schema marked the channel as being 'required',
precluding this feature.

INT-2407 Remove Channel use="required"

Parsers automatically generate the channel when none is provided.

- JMX
- JDBC
- SFTP
- Redis
- Feed
- XMPP
- Mail
- FTP
- HTTP
This commit is contained in:
Gary Russell
2012-01-17 09:23:35 -05:00
committed by Mark Fisher
parent e7b514a1e4
commit 292aa90599
47 changed files with 457 additions and 130 deletions

View File

@@ -71,4 +71,12 @@
<task:executor id="executor" pool-size="5"/>
<mail:imap-idle-channel-adapter
id="autoChannel"
store-uri="imap:foo"
auto-startup="false"
should-delete-messages="true"/>
<integration:bridge input-channel="autoChannel" output-channel="nullChannel" />
</beans>

View File

@@ -28,9 +28,12 @@ import org.junit.Test;
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.context.ApplicationContext;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.mail.ImapIdleChannelAdapter;
import org.springframework.integration.mail.ImapMailReceiver;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -46,6 +49,11 @@ public class ImapIdleChannelAdapterParserTests {
@Autowired
private ApplicationContext context;
@Autowired
private MessageChannel autoChannel;
@Autowired @Qualifier("autoChannel.adapter")
private ImapIdleChannelAdapter autoChannelAdapter;
@Test
public void simpleAdapter() {
@@ -140,4 +148,9 @@ public class ImapIdleChannelAdapterParserTests {
assertEquals("bar", properties.getProperty("foo"));
assertEquals(Boolean.FALSE, receiverAccessor.getPropertyValue("shouldDeleteMessages"));
}
@Test
public void testAutoChannel() {
assertSame(autoChannel, TestUtils.getPropertyValue(autoChannelAdapter, "outputChannel"));
}
}

View File

@@ -98,6 +98,11 @@
<mail:inbound-channel-adapter id="imapShouldMarkAsReadTrue" channel="testChannel" protocol="imap" should-delete-messages="false" auto-startup="false" should-mark-messages-as-read="true"/>
<!-- INT-2407 -->
<mail:inbound-channel-adapter id="autoChannel" protocol="pop3" should-delete-messages="false" auto-startup="false"/>
<si:bridge input-channel="autoChannel" output-channel="nullChannel"/>
<!-- COMMON CONFIGURATION -->

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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.
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -27,19 +28,22 @@ import javax.mail.Authenticator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.xml.sax.SAXParseException;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
import org.springframework.integration.mail.AbstractMailReceiver;
import org.springframework.integration.mail.ImapIdleChannelAdapter;
import org.springframework.integration.mail.ImapMailReceiver;
import org.springframework.integration.mail.Pop3MailReceiver;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.xml.sax.SAXParseException;
/**
* @author Mark Fisher
@@ -53,6 +57,11 @@ public class InboundChannelAdapterParserTests {
@Autowired
private ApplicationContext context;
@Autowired
private MessageChannel autoChannel;
@Autowired @Qualifier("autoChannel.adapter")
private SourcePollingChannelAdapter autoChannelAdapter;
//==================== INT-982 =====================
@@ -283,4 +292,9 @@ public class InboundChannelAdapterParserTests {
return (AbstractMailReceiver) new DirectFieldAccessor(target).getPropertyValue("mailReceiver");
}
@Test
public void testAutoChannel() {
assertSame(autoChannel, TestUtils.getPropertyValue(autoChannelAdapter, "outputChannel"));
}
}