TCP Connection Factory FactoryBean Improvements

Add ctor argument so that early `getObjectType()` calls can return
a narrower type (server Vs. client CF).
This commit is contained in:
Gary Russell
2016-03-25 11:22:59 -04:00
committed by Artem Bilan
parent 69ee423ce2
commit 0fd72d2d18
3 changed files with 42 additions and 8 deletions

View File

@@ -55,6 +55,7 @@ import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.integration.channel.NullChannel;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.ip.config.TcpConnectionFactoryFactoryBean;
import org.springframework.integration.ip.event.IpIntegrationEvent;
import org.springframework.integration.ip.tcp.TcpReceivingChannelAdapter;
import org.springframework.integration.test.support.LogAdjustingTestSupport;
@@ -71,6 +72,16 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
*/
public class ConnectionFactoryTests extends LogAdjustingTestSupport {
@Test
public void factoryBeanTests() {
TcpConnectionFactoryFactoryBean fb = new TcpConnectionFactoryFactoryBean("client");
assertEquals(AbstractClientConnectionFactory.class, fb.getObjectType());
fb = new TcpConnectionFactoryFactoryBean("server");
assertEquals(AbstractServerConnectionFactory.class, fb.getObjectType());
fb = new TcpConnectionFactoryFactoryBean();
assertEquals(AbstractConnectionFactory.class, fb.getObjectType());
}
@Test
public void testObtainConnectionIdsNet() throws Exception {
TcpNetServerConnectionFactory serverFactory = new TcpNetServerConnectionFactory(0);