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

@@ -30,4 +30,13 @@
<bean id="testBean1" class="org.springframework.integration.jmx.config.TestBean"/>
<jmx:attribute-polling-channel-adapter id="autoChannel"
object-name="org.springframework.integration.jmx.config:type=TestBean,name=testBean1"
attribute-name="FirstMessage"
auto-startup="false">
<si:poller max-messages-per-poll="1" fixed-rate="2000"/>
</jmx:attribute-polling-channel-adapter>
<si:bridge input-channel="autoChannel" output-channel="nullChannel" />
</beans>

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.
@@ -18,19 +18,23 @@ package org.springframework.integration.jmx.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
* @author Gary Russell
* @since 2.0
*/
@ContextConfiguration
@@ -46,6 +50,11 @@ public class AttributePollingChannelAdapterParserTests {
@Autowired
private TestBean testBean;
@Autowired
private MessageChannel autoChannel;
@Autowired @Qualifier("autoChannel.adapter")
private SourcePollingChannelAdapter autoChannelAdapter;
@Test
public void pollForAttribute() throws Exception {
@@ -56,4 +65,9 @@ public class AttributePollingChannelAdapterParserTests {
assertEquals("foo", result.getPayload());
}
@Test
public void testAutoChannel() {
assertSame(autoChannel, TestUtils.getPropertyValue(autoChannelAdapter, "outputChannel"));
}
}

View File

@@ -26,4 +26,9 @@
<bean id="testPublisher" class="org.springframework.integration.jmx.config.TestPublisher"/>
<jmx:notification-listening-channel-adapter id="autoChannel"
object-name="org.springframework.integration.jmx.config:type=TestPublisher,name=testPublisher"/>
<si:bridge input-channel="autoChannel" output-channel="nullChannel" />
</beans>

View File

@@ -19,14 +19,19 @@ package org.springframework.integration.jmx.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import javax.management.Notification;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.jmx.NotificationListeningMessageProducer;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -44,6 +49,11 @@ public class NotificationListeningChannelAdapterParserTests {
@Autowired
private TestPublisher testPublisher;
@Autowired
private MessageChannel autoChannel;
@Autowired @Qualifier("autoChannel.adapter")
private NotificationListeningMessageProducer autoChannelAdapter;
@Test
public void receiveNotification() throws Exception {
@@ -55,4 +65,9 @@ public class NotificationListeningChannelAdapterParserTests {
assertEquals("ABC", ((Notification) message.getPayload()).getMessage());
}
@Test
public void testAutoChannel() {
assertSame(autoChannel, TestUtils.getPropertyValue(autoChannelAdapter, "outputChannel"));
}
}