Upgrade to Reactor 3.1.2 and some polishing

* Fix TCP/IP `ParserUnitTests.testInUdpMulticast()` do not check
the port.
No guarantee with the OS selection port that it is always going
to be `> 5100`
* Optimize `RmiInboundGatewayParserTests` to load application context
only once - `@RunWith(SpringRunner.class)`
This commit is contained in:
Artem Bilan
2017-11-17 12:31:25 -05:00
parent 1244c6c22a
commit 41a47171c2
4 changed files with 41 additions and 51 deletions

View File

@@ -123,8 +123,8 @@ subprojects { subproject ->
mysqlVersion = '6.0.6'
pahoMqttClientVersion = '1.2.0'
postgresVersion = '42.0.0'
reactorNettyVersion = '0.7.1.RELEASE'
reactorVersion = '3.1.1.RELEASE'
reactorNettyVersion = '0.7.2.RELEASE'
reactorVersion = '3.1.2.RELEASE'
romeToolsVersion = '1.8.0'
servletApiVersion = '3.1.0'
slf4jVersion = "1.7.25"

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -84,6 +84,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Gary Russell
* @author Oleg Zhurakousky
* @author Artem Bilan
*
* @since 2.0
*/
@ContextConfiguration
@@ -301,7 +302,6 @@ public class ParserUnitTests {
@Test
public void testInUdpMulticast() {
DirectFieldAccessor dfa = new DirectFieldAccessor(udpInMulticast);
assertTrue(udpInMulticast.getPort() >= 5100);
assertEquals("225.6.7.8", dfa.getPropertyValue("group"));
assertEquals(27, dfa.getPropertyValue("poolSize"));
assertEquals(29, dfa.getPropertyValue("receiveBufferSize"));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2017 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.
@@ -16,93 +16,83 @@
package org.springframework.integration.rmi.config;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.rmi.RmiInboundGateway;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageChannel;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
*/
@RunWith(SpringRunner.class)
@DirtiesContext
public class RmiInboundGatewayParserTests {
@Autowired
@Qualifier("testChannel")
private MessageChannel channel;
@Autowired
private ApplicationContext context;
@Test
public void gatewayWithDefaultsAndHistory() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"rmiInboundGatewayParserTests.xml", this.getClass());
MessageChannel channel = (MessageChannel) context.getBean("testChannel");
RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithDefaults");
RmiInboundGateway gateway = (RmiInboundGateway) this.context.getBean("gatewayWithDefaults");
assertEquals("gatewayWithDefaults", gateway.getComponentName());
assertEquals("rmi:inbound-gateway", gateway.getComponentType());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(true, accessor.getPropertyValue("expectReply"));
assertEquals(channel, accessor.getPropertyValue("requestChannel"));
MessagingTemplate template = (MessagingTemplate)
accessor.getPropertyValue("messagingTemplate");
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(template);
assertEquals(1000L, templateAccessor.getPropertyValue("sendTimeout"));
assertEquals(1000L, templateAccessor.getPropertyValue("receiveTimeout"));
context.close();
assertTrue(TestUtils.getPropertyValue(gateway, "expectReply", Boolean.class));
assertSame(this.channel, TestUtils.getPropertyValue(gateway, "requestChannel"));
assertEquals(1000L, TestUtils.getPropertyValue(gateway, "messagingTemplate.sendTimeout"));
assertEquals(1000L, TestUtils.getPropertyValue(gateway, "messagingTemplate.receiveTimeout"));
}
@Test
public void gatewayWithCustomProperties() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"rmiInboundGatewayParserTests.xml", this.getClass());
MessageChannel channel = (MessageChannel) context.getBean("testChannel");
RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithCustomProperties");
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(false, accessor.getPropertyValue("expectReply"));
assertEquals(channel, accessor.getPropertyValue("requestChannel"));
MessagingTemplate template = (MessagingTemplate)
accessor.getPropertyValue("messagingTemplate");
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(template);
assertEquals(123L, templateAccessor.getPropertyValue("sendTimeout"));
assertEquals(456L, templateAccessor.getPropertyValue("receiveTimeout"));
context.close();
assertFalse(TestUtils.getPropertyValue(gateway, "expectReply", Boolean.class));
assertSame(this.channel, TestUtils.getPropertyValue(gateway, "requestChannel"));
assertEquals(123L, TestUtils.getPropertyValue(gateway, "messagingTemplate.sendTimeout"));
assertEquals(456L, TestUtils.getPropertyValue(gateway, "messagingTemplate.receiveTimeout"));
}
@Test
public void gatewayWithHost() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"rmiInboundGatewayParserTests.xml", this.getClass());
RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithHostAndErrorChannel");
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals("localhost", accessor.getPropertyValue("registryHost"));
assertSame(context.getBean("testErrorChannel"),
TestUtils.getPropertyValue(gateway, "errorChannel"));
context.close();
assertEquals("localhost", TestUtils.getPropertyValue(gateway, "registryHost"));
assertSame(context.getBean("testErrorChannel"), TestUtils.getPropertyValue(gateway, "errorChannel"));
}
@Test
public void gatewayWithPort() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"rmiInboundGatewayParserTests.xml", this.getClass());
RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithPort");
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(1234, accessor.getPropertyValue("registryPort"));
context.close();
assertEquals(1234, TestUtils.getPropertyValue(gateway, "registryPort"));
}
@Test
public void gatewayWithRemoteInvocationExecutorReference() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"rmiInboundGatewayParserTests.xml", this.getClass());
RmiInboundGateway gateway = (RmiInboundGateway) context.getBean("gatewayWithExecutorRef");
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
Object remoteInvocationExecutor = accessor.getPropertyValue("remoteInvocationExecutor");
Object remoteInvocationExecutor = TestUtils.getPropertyValue(gateway, "remoteInvocationExecutor");
assertNotNull(remoteInvocationExecutor);
assertEquals(StubRemoteInvocationExecutor.class, remoteInvocationExecutor.getClass());
context.close();
assertThat(remoteInvocationExecutor, instanceOf(StubRemoteInvocationExecutor.class));
}
}