From aa895e73650089710a9d402518ca7597e20ee2e0 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 4 Dec 2019 13:06:04 -0500 Subject: [PATCH] Upgrade dependencies; prepare for release * Fix MongoDB tests for changed return type from Spring Data MongoDB --- build.gradle | 24 +++---- .../channel/FluxMessageChannel.java | 30 +++++---- ...InboundChannelAdapterIntegrationTests.java | 37 +++++------ .../inbound/MongoDbMessageSourceTests.java | 65 +++++++++---------- 4 files changed, 77 insertions(+), 79 deletions(-) diff --git a/build.gradle b/build.gradle index 67e92f2435..312a2bb97c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlinVersion = '1.3.50' + ext.kotlinVersion = '1.3.60' repositories { maven { url 'https://repo.spring.io/plugins-release' } } @@ -42,15 +42,15 @@ ext { modifiedFiles = files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') || f.name.endsWith('.kt') } - activeMqVersion = '5.15.10' + activeMqVersion = '5.15.11' apacheSshdVersion = '2.3.0' avroVersion = '1.9.1' - aspectjVersion = '1.9.4' + aspectjVersion = '1.9.5' assertjVersion = '3.14.0' assertkVersion = '0.20' awaitilityVersion = '4.0.1' boonVersion = '0.34' - commonsDbcp2Version = '2.6.0' + commonsDbcp2Version = '2.7.0' commonsIoVersion = '2.6' commonsNetVersion = '3.6' curatorVersion = '4.2.0' @@ -59,17 +59,17 @@ ext { googleJsr305Version = '3.0.2' groovyVersion = '2.5.8' hamcrestVersion = '2.2' - hazelcastVersion = '3.12.3' - hibernateVersion = '5.4.7.Final' + hazelcastVersion = '3.12.4' + hibernateVersion = '5.4.9.Final' hsqldbVersion = '2.5.0' h2Version = '1.4.200' - jacksonVersion = '2.10.0' + jacksonVersion = '2.10.1' javaxActivationVersion = '1.2.0' javaxMailVersion = '1.6.2' jmsApiVersion = '2.0.1' jpa21ApiVersion = '1.0.2.Final' jpaApiVersion = '2.2.1' - jrubyVersion = '9.2.8.0' + jrubyVersion = '9.2.9.0' jschVersion = '0.1.55' jsonpathVersion = '2.4.0' junit4Version = '4.12' @@ -78,8 +78,8 @@ ext { kryoShadedVersion = '4.0.2' lettuceVersion = '5.2.1.RELEASE' log4jVersion = '2.12.1' - micrometerVersion = '1.3.1' - mockitoVersion = '3.1.0' + micrometerVersion = '1.3.2' + mockitoVersion = '3.2.0' mysqlVersion = '8.0.18' pahoMqttClientVersion = '1.2.0' postgresVersion = '42.2.8' @@ -95,7 +95,7 @@ ext { springRetryVersion = '1.2.4.RELEASE' springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.2.2.RELEASE' springWsVersion = '3.0.8.RELEASE' - tomcatVersion = "9.0.27" + tomcatVersion = "9.0.29" xstreamVersion = '1.4.11.1' } @@ -330,7 +330,7 @@ subprojects { subproject -> checkstyle { configFile = file("$rootDir/src/checkstyle/checkstyle.xml") - toolVersion = '8.25' + toolVersion = '8.26' } artifacts { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/FluxMessageChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/FluxMessageChannel.java index d50760b91c..14b9b449a8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/FluxMessageChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/FluxMessageChannel.java @@ -22,6 +22,8 @@ import org.reactivestreams.Subscriber; import org.springframework.messaging.Message; import org.springframework.util.Assert; +import reactor.core.Disposable; +import reactor.core.Disposables; import reactor.core.publisher.EmitterProcessor; import reactor.core.publisher.Flux; import reactor.core.publisher.FluxSink; @@ -47,6 +49,8 @@ public class FluxMessageChannel extends AbstractMessageChannel private final ReplayProcessor subscribedSignal = ReplayProcessor.create(1); + private final Disposable.Composite upstreamSubscriptions = Disposables.composite(); + public FluxMessageChannel() { this.processor = EmitterProcessor.create(1, false); this.sink = this.processor.sink(FluxSink.OverflowStrategy.BUFFER); @@ -70,23 +74,25 @@ public class FluxMessageChannel extends AbstractMessageChannel @Override public void subscribeTo(Publisher> publisher) { - Flux.from(publisher) - .delaySubscription(this.subscribedSignal.filter(Boolean::booleanValue).next()) - .publishOn(Schedulers.boundedElastic()) - .doOnNext((message) -> { - try { - send(message); - } - catch (Exception e) { - logger.warn("Error during processing event: " + message, e); - } - }) - .subscribe(); + this.upstreamSubscriptions.add( + Flux.from(publisher) + .delaySubscription(this.subscribedSignal.filter(Boolean::booleanValue).next()) + .publishOn(Schedulers.boundedElastic()) + .doOnNext((message) -> { + try { + send(message); + } + catch (Exception e) { + logger.warn("Error during processing event: " + message, e); + } + }) + .subscribe()); } @Override public void destroy() { this.subscribedSignal.onNext(false); + this.upstreamSubscriptions.dispose(); this.processor.onComplete(); super.destroy(); } diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbInboundChannelAdapterIntegrationTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbInboundChannelAdapterIntegrationTests.java index 704cae56ce..b4b8877276 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbInboundChannelAdapterIntegrationTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbInboundChannelAdapterIntegrationTests.java @@ -20,7 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.List; -import org.bson.Document; import org.junit.Test; import org.junit.runner.RunWith; @@ -40,8 +39,9 @@ import org.springframework.integration.mongodb.rules.MongoDbAvailable; import org.springframework.integration.mongodb.rules.MongoDbAvailableTests; import org.springframework.messaging.Message; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; + +import com.mongodb.BasicDBObject; /** * @author Oleg Zhurakousky @@ -50,8 +50,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * * @since 2.2 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(SpringRunner.class) @DirtiesContext public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailableTests { @@ -102,7 +101,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test @MongoDbAvailable - public void testWithDefaultMongoFactory() throws Exception { + public void testWithDefaultMongoFactory() { this.mongoTemplate.save(createPerson("Bob"), "data"); this.mongoInboundAdapter.start(); @@ -119,13 +118,13 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test @MongoDbAvailable - public void testWithNamedMongoFactory() throws Exception { + public void testWithNamedMongoFactory() { this.mongoTemplate.save(this.createPerson("Bob"), "data"); this.mongoInboundAdapterNamedFactory.start(); @SuppressWarnings("unchecked") - Message> message = (Message>) replyChannel.receive(10000); + Message> message = (Message>) replyChannel.receive(10000); assertThat(message).isNotNull(); assertThat(message.getPayload().get(0).get("name")).isEqualTo("Bob"); @@ -135,7 +134,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test @MongoDbAvailable - public void testWithMongoTemplate() throws Exception { + public void testWithMongoTemplate() { this.mongoTemplate.save(this.createPerson("Bob"), "data"); this.mongoInboundAdapterWithTemplate.start(); @@ -151,7 +150,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test @MongoDbAvailable - public void testWithNamedCollection() throws Exception { + public void testWithNamedCollection() { this.mongoTemplate.save(this.createPerson("Bob"), "foo"); this.mongoInboundAdapterWithNamedCollection.start(); @@ -167,7 +166,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test @MongoDbAvailable - public void testWithQueryExpression() throws Exception { + public void testWithQueryExpression() { this.mongoTemplate.save(this.createPerson("Bob"), "foo"); this.mongoTemplate.save(this.createPerson("Bob"), "foo"); this.mongoInboundAdapterWithQueryExpression.start(); @@ -181,7 +180,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test @MongoDbAvailable - public void testWithStringQueryExpression() throws Exception { + public void testWithStringQueryExpression() { this.mongoTemplate.save(this.createPerson("Bob"), "foo"); this.mongoInboundAdapterWithStringQueryExpression.start(); @SuppressWarnings("unchecked") @@ -193,7 +192,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test @MongoDbAvailable - public void testWithNamedCollectionExpression() throws Exception { + public void testWithNamedCollectionExpression() { this.mongoTemplate.save(this.createPerson("Bob"), "foo"); this.mongoInboundAdapterWithNamedCollectionExpression.start(); @@ -209,7 +208,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test @MongoDbAvailable - public void testWithOnSuccessDisposition() throws Exception { + public void testWithOnSuccessDisposition() { this.mongoTemplate.save(createPerson("Bob"), "data"); this.inboundAdapterWithOnSuccessDisposition.start(); @@ -227,7 +226,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test @MongoDbAvailable - public void testWithMongoConverter() throws Exception { + public void testWithMongoConverter() { this.mongoTemplate.save(this.createPerson("Bob"), "data"); this.mongoInboundAdapterWithConverter.start(); @@ -244,25 +243,25 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab @Test(expected = BeanDefinitionParsingException.class) @MongoDbAvailable - public void testFailureWithQueryAndQueryExpression() throws Exception { + public void testFailureWithQueryAndQueryExpression() { new ClassPathXmlApplicationContext("inbound-fail-q-qex.xml", this.getClass()).close(); } @Test(expected = BeanDefinitionParsingException.class) @MongoDbAvailable - public void testFailureWithFactoryAndTemplate() throws Exception { + public void testFailureWithFactoryAndTemplate() { new ClassPathXmlApplicationContext("inbound-fail-factory-template.xml", this.getClass()).close(); } @Test(expected = BeanDefinitionParsingException.class) @MongoDbAvailable - public void testFailureWithCollectionAndCollectionExpression() throws Exception { + public void testFailureWithCollectionAndCollectionExpression() { new ClassPathXmlApplicationContext("inbound-fail-c-cex.xml", this.getClass()).close(); } @Test(expected = BeanDefinitionParsingException.class) @MongoDbAvailable - public void testFailureWithTemplateAndConverter() throws Exception { + public void testFailureWithTemplateAndConverter() { new ClassPathXmlApplicationContext("inbound-fail-converter-template.xml", this.getClass()).close(); } diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/MongoDbMessageSourceTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/MongoDbMessageSourceTests.java index 995877eb91..e6ace19105 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/MongoDbMessageSourceTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/MongoDbMessageSourceTests.java @@ -17,6 +17,7 @@ package org.springframework.integration.mongodb.inbound; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -24,7 +25,6 @@ import static org.mockito.Mockito.verify; import java.util.List; -import org.bson.Document; import org.bson.conversions.Bson; import org.junit.Test; import org.mockito.Mockito; @@ -55,31 +55,27 @@ import com.mongodb.BasicDBObject; */ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { - /** - * Tests by providing a null MongoDB Factory - * - */ - @Test(expected = IllegalArgumentException.class) + @Test public void withNullMongoDBFactory() { - Expression expression = mock(Expression.class); - new MongoDbMessageSource((MongoDbFactory) null, expression); + assertThatIllegalArgumentException() + .isThrownBy(() -> new MongoDbMessageSource((MongoDbFactory) null, mock(Expression.class))); } - @Test(expected = IllegalArgumentException.class) + @Test public void withNullMongoTemplate() { - Expression expression = mock(Expression.class); - new MongoDbMessageSource((MongoOperations) null, expression); + assertThatIllegalArgumentException() + .isThrownBy(() -> new MongoDbMessageSource((MongoOperations) null, mock(Expression.class))); } - @Test(expected = IllegalArgumentException.class) + @Test public void withNullQueryExpression() { - MongoDbFactory mongoDbFactory = mock(MongoDbFactory.class); - new MongoDbMessageSource(mongoDbFactory, null); + assertThatIllegalArgumentException() + .isThrownBy(() -> new MongoDbMessageSource(mock(MongoDbFactory.class), null)); } @Test @MongoDbAvailable - public void validateSuccessfulQueryWithSingleElementIfOneInListAsDbObject() throws Exception { + public void validateSuccessfulQueryWithSingleElementIfOneInListAsDbObject() { MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); MongoTemplate template = new MongoTemplate(mongoDbFactory); @@ -90,18 +86,17 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { messageSource.setBeanFactory(mock(BeanFactory.class)); messageSource.afterPropertiesSet(); @SuppressWarnings("unchecked") - List results = ((List) messageSource.receive().getPayload()); + List results = ((List) messageSource.receive().getPayload()); assertThat(results.size()).isEqualTo(1); - Document resultObject = results.get(0); + BasicDBObject resultObject = results.get(0); assertThat(resultObject.get("name")).isEqualTo("Oleg"); } @Test @MongoDbAvailable - public void validateSuccessfulQueryWithSingleElementIfOneInList() throws Exception { - - MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); + public void validateSuccessfulQueryWithSingleElementIfOneInList() { + MongoDbFactory mongoDbFactory = prepareMongoFactory(); MongoTemplate template = new MongoTemplate(mongoDbFactory); template.save(this.createPerson(), "data"); @@ -121,9 +116,8 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { @Test @MongoDbAvailable - public void validateSuccessfulQueryWithSingleElementIfOneInListAndSingleResult() throws Exception { - - MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); + public void validateSuccessfulQueryWithSingleElementIfOneInListAndSingleResult() { + MongoDbFactory mongoDbFactory = prepareMongoFactory(); MongoTemplate template = new MongoTemplate(mongoDbFactory); template.save(this.createPerson(), "data"); @@ -143,9 +137,8 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { @Test @MongoDbAvailable - public void validateSuccessfulSubObjectQueryWithSingleElementIfOneInList() throws Exception { - - MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); + public void validateSuccessfulSubObjectQueryWithSingleElementIfOneInList() { + MongoDbFactory mongoDbFactory = prepareMongoFactory(); MongoTemplate template = new MongoTemplate(mongoDbFactory); template.save(this.createPerson(), "data"); @@ -164,14 +157,14 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { @Test @MongoDbAvailable - public void validateSuccessfulQueryWithMultipleElements() throws Exception { + public void validateSuccessfulQueryWithMultipleElements() { List persons = queryMultipleElements(new LiteralExpression("{'address.state' : 'PA'}")); assertThat(persons.size()).isEqualTo(3); } @Test @MongoDbAvailable - public void validateSuccessfulStringQueryExpressionWithMultipleElements() throws Exception { + public void validateSuccessfulStringQueryExpressionWithMultipleElements() { List persons = queryMultipleElements(new SpelExpressionParser() .parseExpression("\"{'address.state' : 'PA'}\"")); assertThat(persons.size()).isEqualTo(3); @@ -179,14 +172,14 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { @Test @MongoDbAvailable - public void validateSuccessfulBasicQueryExpressionWithMultipleElements() throws Exception { + public void validateSuccessfulBasicQueryExpressionWithMultipleElements() { List persons = queryMultipleElements(new SpelExpressionParser() .parseExpression("new BasicQuery(\"{'address.state' : 'PA'}\").limit(2)")); assertThat(persons.size()).isEqualTo(2); } @SuppressWarnings("unchecked") - private List queryMultipleElements(Expression queryExpression) throws Exception { + private List queryMultipleElements(Expression queryExpression) { MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); MongoTemplate template = new MongoTemplate(mongoDbFactory); @@ -203,7 +196,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { @Test @MongoDbAvailable - public void validateSuccessfulQueryWithNullReturn() throws Exception { + public void validateSuccessfulQueryWithNullReturn() { MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); @@ -222,7 +215,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { @SuppressWarnings("unchecked") @Test @MongoDbAvailable - public void validateSuccessfulQueryWithCustomConverter() throws Exception { + public void validateSuccessfulQueryWithCustomConverter() { MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); @@ -248,7 +241,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { @SuppressWarnings("unchecked") @Test @MongoDbAvailable - public void validateSuccessfulQueryWithMongoTemplate() throws Exception { + public void validateSuccessfulQueryWithMongoTemplate() { MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); @@ -274,7 +267,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { @Test @MongoDbAvailable - public void validatePipelineInModifyOut() throws Exception { + public void validatePipelineInModifyOut() { MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); @@ -287,11 +280,11 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests { messageSource.setExpectSingleResult(true); messageSource.setBeanFactory(mock(BeanFactory.class)); messageSource.afterPropertiesSet(); - Document result = (Document) messageSource.receive().getPayload(); + BasicDBObject result = (BasicDBObject) messageSource.receive().getPayload(); Object id = result.get("_id"); result.put("company", "PepBoys"); template.save(result, "data"); - result = (Document) messageSource.receive().getPayload(); + result = (BasicDBObject) messageSource.receive().getPayload(); assertThat(result.get("_id")).isEqualTo(id); }