Compatibility with the latest dependencies

* Upgrade to Gradle 3.5, SS-5.0, Hibernate-5.2.10, Mockito-2.7.22, Pah-1.1.1
And some other minor upgrades
* Fix deprecations for Mockito compatibility
* Fix `ServletWebSocketHandlerRegistry` deprecations
* Fix SD-Mongo deprecations
* Tweak JMX tests to avoid dangling threads after tests exist
* Increase timeouts in some polling tests
This commit is contained in:
Artem Bilan
2017-04-26 11:29:18 -04:00
parent 3c047c5076
commit 026484c382
16 changed files with 119 additions and 72 deletions

View File

@@ -87,28 +87,28 @@ subprojects { subproject ->
}
ext {
activeMqVersion = '5.14.3'
activeMqVersion = '5.14.5'
aspectjVersion = '1.8.9'
apacheSshdVersion = '1.4.0'
boonVersion = '0.33'
boonVersion = '0.34'
chronicleVersion = '3.5.3'
commonsDbcpVersion = '1.4'
commonsIoVersion = '2.4'
commonsNetVersion = '3.4'
commonsNetVersion = '3.5'
curatorVersion = '2.11.1'
derbyVersion = '10.11.1.1'
eclipseLinkVersion = '2.5.2'
derbyVersion = '10.13.1.1'
eclipseLinkVersion = '2.6.4'
ftpServerVersion = '1.0.6'
groovyVersion = '2.4.6'
guavaVersion = '19.0'
guavaVersion = '20.0'
hamcrestVersion = '1.3'
hazelcastVersion = '3.6.1'
hibernateVersion = '5.2.5.Final'
hsqldbVersion = '2.3.3'
h2Version = '1.4.180'
hazelcastVersion = '3.8'
hibernateVersion = '5.2.10.Final'
hsqldbVersion = '2.4.0'
h2Version = '1.4.194'
jackson2Version = '2.9.0.pr2'
javaxActivationVersion = '1.1.1'
javaxMailVersion = '1.5.6'
javaxMailVersion = '1.6.0-rc1'
jedisVersion = '2.9.0'
jmsApiVersion = '2.0.1'
jpa21ApiVersion = '1.0.0.Final'
@@ -120,27 +120,27 @@ subprojects { subproject ->
jythonVersion = '2.5.3'
kryoShadedVersion = '3.0.3'
log4jVersion = '1.2.17'
mockitoVersion = '2.5.4'
mysqlVersion = '5.1.34'
pahoMqttClientVersion = '1.0.2'
mockitoVersion = '2.7.22'
mysqlVersion = '5.1.41'
pahoMqttClientVersion = '1.1.1'
postgresVersion = '9.1-901-1.jdbc4'
reactorNettyVersion = '0.6.3.BUILD-SNAPSHOT'
reactorVersion = '3.1.0.BUILD-SNAPSHOT'
romeToolsVersion = '1.7.0'
romeToolsVersion = '1.7.2'
servletApiVersion = '3.1.0'
slf4jVersion = "1.7.21"
smackVersion = '4.1.7'
slf4jVersion = "1.7.25"
smackVersion = '4.1.9'
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.0.0.BUILD-SNAPSHOT'
springDataJpaVersion = '2.0.0.BUILD-SNAPSHOT'
springDataMongoVersion = '2.0.0.BUILD-SNAPSHOT'
springDataRedisVersion = '2.0.0.BUILD-SNAPSHOT'
springGemfireVersion = '2.0.0.BUILD-SNAPSHOT'
springSecurityVersion = '4.2.2.RELEASE'
springSecurityVersion = '5.0.0.BUILD-SNAPSHOT'
springSocialTwitterVersion = '2.0.0.M1'
springRetryVersion = '1.2.0.RELEASE'
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.0.0.BUILD-SNAPSHOT'
springWsVersion = '2.4.0.RELEASE'
tomcatVersion = "8.5.9"
tomcatVersion = "8.5.14"
xmlUnitVersion = '1.6'
xstreamVersion = '1.4.7'
}

Binary file not shown.

View File

@@ -1,6 +1,6 @@
#Thu Jan 05 11:36:34 EST 2017
#Wed Apr 26 10:11:04 EDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip

View File

@@ -27,6 +27,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -312,7 +313,7 @@ public class AmqpOutboundChannelAdapterParserTests {
AmqpOutboundEndpoint handler = new AmqpOutboundEndpoint(amqpTemplate);
Log logger = spy(TestUtils.getPropertyValue(handler, "logger", Log.class));
new DirectFieldAccessor(handler).setPropertyValue("logger", logger);
doAnswer(new DoesNothing()).when(logger).error("Failed to eagerly establish the connection.", toBeThrown);
doNothing().when(logger).error("Failed to eagerly establish the connection.", toBeThrown);
ApplicationContext context = mock(ApplicationContext.class);
handler.setApplicationContext(context);
handler.setBeanFactory(context);

View File

@@ -85,7 +85,7 @@ public class GatewayParserTests {
TestService service = (TestService) context.getBean("oneWay");
service.oneWay("foo");
PollableChannel channel = (PollableChannel) context.getBean("requestChannel");
Message<?> result = channel.receive(1000);
Message<?> result = channel.receive(10000);
assertEquals("foo", result.getPayload());
}
@@ -94,7 +94,7 @@ public class GatewayParserTests {
TestService service = (TestService) context.getBean("methodOverride");
service.oneWay("foo");
PollableChannel channel = (PollableChannel) context.getBean("otherRequestChannel");
Message<?> result = channel.receive(1000);
Message<?> result = channel.receive(10000);
assertEquals("fiz", result.getPayload());
assertEquals("bar", result.getHeaders().get("foo"));
assertEquals("qux", result.getHeaders().get("baz"));
@@ -133,7 +133,7 @@ public class GatewayParserTests {
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("async", TestService.class);
Future<Message<?>> result = service.async("foo");
Message<?> reply = result.get(1, TimeUnit.SECONDS);
Message<?> reply = result.get(10, TimeUnit.SECONDS);
assertEquals("foo", reply.getPayload());
assertEquals("testExecutor", reply.getHeaders().get("executor"));
assertNotNull(TestUtils.getPropertyValue(context.getBean("&async"), "asyncExecutor"));
@@ -146,7 +146,7 @@ public class GatewayParserTests {
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("asyncOff", TestService.class);
Future<Message<?>> result = service.async("futureSync");
Message<?> reply = result.get(1, TimeUnit.SECONDS);
Message<?> reply = result.get(10, TimeUnit.SECONDS);
assertEquals("futureSync", reply.getPayload());
Object serviceBean = context.getBean("&asyncOff");
assertNull(TestUtils.getPropertyValue(serviceBean, "asyncExecutor"));
@@ -220,7 +220,7 @@ public class GatewayParserTests {
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("completableNoAsync", TestService.class);
CompletableFuture<String> result = service.completable("flowCompletable");
String reply = result.get(1, TimeUnit.SECONDS);
String reply = result.get(10, TimeUnit.SECONDS);
assertEquals("SYNC_COMPLETABLE", reply);
assertEquals(Thread.currentThread(), thread.get());
assertNull(TestUtils.getPropertyValue(context.getBean("&completableNoAsync"), "asyncExecutor"));
@@ -243,7 +243,7 @@ public class GatewayParserTests {
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("completableNoAsync", TestService.class);
MyCompletableFuture result = service.customCompletable("flowCustomCompletable");
String reply = result.get(1, TimeUnit.SECONDS);
String reply = result.get(10, TimeUnit.SECONDS);
assertEquals("SYNC_CUSTOM_COMPLETABLE", reply);
assertEquals(Thread.currentThread(), thread.get());
assertNull(TestUtils.getPropertyValue(context.getBean("&completableNoAsync"), "asyncExecutor"));
@@ -270,7 +270,7 @@ public class GatewayParserTests {
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("customCompletableAttemptAsync", TestService.class);
MyCompletableFuture result = service.customCompletable("flowCustomCompletable");
String reply = result.get(1, TimeUnit.SECONDS);
String reply = result.get(10, TimeUnit.SECONDS);
assertEquals("SYNC_CUSTOM_COMPLETABLE", reply);
assertEquals(Thread.currentThread(), thread.get());
assertNotNull(TestUtils.getPropertyValue(gateway, "asyncExecutor"));
@@ -296,7 +296,7 @@ public class GatewayParserTests {
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("asyncCompletable", TestService.class);
CompletableFuture<Message<?>> result = service.completableReturnsMessage("foo");
Message<?> reply = result.get(1, TimeUnit.SECONDS);
Message<?> reply = result.get(10, TimeUnit.SECONDS);
assertEquals("foo", reply.getPayload());
assertThat(thread.get().getName(), startsWith("testExec-"));
assertNotNull(TestUtils.getPropertyValue(context.getBean("&asyncCompletable"), "asyncExecutor"));
@@ -319,7 +319,7 @@ public class GatewayParserTests {
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("completableNoAsync", TestService.class);
CompletableFuture<Message<?>> result = service.completableReturnsMessage("flowCompletableM");
Message<?> reply = result.get(1, TimeUnit.SECONDS);
Message<?> reply = result.get(10, TimeUnit.SECONDS);
assertEquals("flowCompletableM", reply.getPayload());
assertEquals(Thread.currentThread(), thread.get());
assertNull(TestUtils.getPropertyValue(context.getBean("&completableNoAsync"), "asyncExecutor"));
@@ -342,7 +342,7 @@ public class GatewayParserTests {
this.startResponder(requestChannel, replyChannel);
TestService service = context.getBean("completableNoAsync", TestService.class);
MyCompletableMessageFuture result = service.customCompletableReturnsMessage("flowCustomCompletableM");
Message<?> reply = result.get(1, TimeUnit.SECONDS);
Message<?> reply = result.get(10, TimeUnit.SECONDS);
assertEquals("flowCustomCompletableM", reply.getPayload());
assertEquals(Thread.currentThread(), thread.get());
assertNull(TestUtils.getPropertyValue(context.getBean("&completableNoAsync"), "asyncExecutor"));

View File

@@ -29,7 +29,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -53,7 +53,6 @@ import org.hamcrest.Matchers;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.internal.stubbing.answers.DoesNothing;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.ApplicationEvent;
@@ -67,7 +66,6 @@ import org.springframework.integration.ip.tcp.TcpSendingMessageHandler;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.GenericMessage;
@@ -76,6 +74,8 @@ import org.springframework.util.SocketUtils;
/**
* @author Gary Russell
* @author Artyem Bilan
*
* @since 3.0
*
*/
@@ -112,7 +112,8 @@ public class ConnectionEventTests {
conn.send(new GenericMessage<String>("bar"));
fail("Expected exception");
}
catch (Exception e) { }
catch (Exception e) {
}
assertTrue(theEvent.size() > 0);
assertNotNull(theEvent.get(0));
assertTrue(theEvent.get(0) instanceof TcpConnectionExceptionEvent);
@@ -150,6 +151,7 @@ public class ConnectionEventTests {
@Override
public void run() {
}
};
final AtomicReference<ApplicationEvent> theEvent = new AtomicReference<ApplicationEvent>();
scf.setApplicationEventPublisher(new ApplicationEventPublisher() {
@@ -206,13 +208,7 @@ public class ConnectionEventTests {
});
gw.setConnectionFactory(scf);
DirectChannel requestChannel = new DirectChannel();
requestChannel.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
((MessageChannel) message.getHeaders().getReplyChannel()).send(message);
}
});
requestChannel.subscribe(message -> ((MessageChannel) message.getHeaders().getReplyChannel()).send(message));
gw.setRequestChannel(requestChannel);
gw.start();
Message<String> message = MessageBuilder.withPayload("foo")
@@ -229,6 +225,7 @@ public class ConnectionEventTests {
public void testOutboundGatewayNoConnectionEvents() {
TcpOutboundGateway gw = new TcpOutboundGateway();
AbstractClientConnectionFactory ccf = new AbstractClientConnectionFactory("localhost", 0) {
};
final AtomicReference<ApplicationEvent> theEvent = new AtomicReference<ApplicationEvent>();
ccf.setApplicationEventPublisher(new ApplicationEventPublisher() {
@@ -296,7 +293,7 @@ public class ConnectionEventTests {
factory.setBeanName("sf");
factory.registerListener(message -> false);
Log logger = spy(TestUtils.getPropertyValue(factory, "logger", Log.class));
doAnswer(new DoesNothing()).when(logger).error(anyString(), any(Throwable.class));
doNothing().when(logger).error(anyString(), any(Throwable.class));
new DirectFieldAccessor(factory).setPropertyValue("logger", logger);
factory.start();

View File

@@ -21,7 +21,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -31,7 +31,6 @@ import javax.jms.Session;
import org.apache.commons.logging.Log;
import org.junit.Test;
import org.mockito.internal.stubbing.answers.DoesNothing;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanFactory;
@@ -74,7 +73,7 @@ public class ChannelPublishingJmsMessageListenerTests {
final QueueChannel requestChannel = new QueueChannel();
ChannelPublishingJmsMessageListener listener = new ChannelPublishingJmsMessageListener();
Log logger = spy(TestUtils.getPropertyValue(listener, "logger", Log.class));
doAnswer(new DoesNothing()).when(logger).error(anyString(), any(Throwable.class));
doNothing().when(logger).error(anyString(), any(Throwable.class));
new DirectFieldAccessor(listener).setPropertyValue("logger", logger);
listener.setRequestChannel(requestChannel);
QueueChannel errorChannel = new QueueChannel();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2015 the original author or authors.
* Copyright 2013-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.
@@ -45,6 +45,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Stuart Williams
* @author Gary Russell
* @author Artem Bilan
*
*/
@ContextConfiguration
@@ -140,7 +141,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
assertTrue(beans.containsKey("java.lang:type=Runtime"));
adapterDefault.stop();
adapterInner.stop();
}
@Test
@@ -165,7 +166,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
assertTrue(beans.containsKey("java.lang:type=Runtime"));
adapterDefault.stop();
adapterQueryName.stop();
}
@Test
@@ -184,7 +185,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
assertFalse(beans.containsKey("java.lang:type=Runtime"));
adapterDefault.stop();
adapterQueryNameBean.stop();
}
@Test
@@ -203,7 +204,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
assertFalse(beans.containsKey("java.lang:type=OperatingSystem"));
assertTrue(beans.containsKey("java.lang:type=Runtime"));
adapterDefault.stop();
adapterQueryExprBean.stop();
}
@Test
@@ -222,7 +223,7 @@ public class MBeanTreePollingChannelAdapterParserTests {
assertTrue(beans.containsKey("java.lang:type=OperatingSystem"));
assertTrue(beans.containsKey("java.lang:type=Runtime"));
adapterDefault.stop();
adapterConverter.stop();
assertSame(converter, TestUtils.getPropertyValue(adapterConverter, "source.converter"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009-2016 the original author or authors.
* Copyright 2009-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.
@@ -218,6 +218,7 @@ public class MessageChannelsMonitorIntegrationTests {
}
public static class Service {
private int counter;
private volatile CountDownLatch latch;
@@ -241,10 +242,12 @@ public class MessageChannelsMonitorIntegrationTests {
@Aspect
public static class TestChannelInterceptor {
@Before("execution(* *..MessageChannel+.send(*)) && args(input)")
public void around(Message<?> input) {
logger.debug("Handling: " + input);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-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.
@@ -18,6 +18,7 @@ package org.springframework.integration.monitor;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -39,10 +40,13 @@ import org.springframework.util.ClassUtils;
* @author Dave Syer
* @author Gary Russell
* @author Artem Bilan
*
* @since 2.0.4
*/
public class MessageMetricsAdviceTests {
private GenericApplicationContext applicationContext;
private ConfigurableListableBeanFactory beanFactory;
private IntegrationMBeanExporter mBeanExporter;
@@ -53,11 +57,11 @@ public class MessageMetricsAdviceTests {
@Before
public void setUp() throws Exception {
GenericApplicationContext applicationContext = TestUtils.createTestApplicationContext();
this.beanFactory = applicationContext.getBeanFactory();
this.applicationContext = TestUtils.createTestApplicationContext();
this.beanFactory = this.applicationContext.getBeanFactory();
this.channel = new NullChannel();
this.mBeanExporter = new IntegrationMBeanExporter();
this.mBeanExporter.setApplicationContext(applicationContext);
this.mBeanExporter.setApplicationContext(this.applicationContext);
this.mBeanExporter.setBeanFactory(this.beanFactory);
this.mBeanExporter.setBeanClassLoader(ClassUtils.getDefaultClassLoader());
this.mBeanExporter.afterPropertiesSet();
@@ -65,6 +69,13 @@ public class MessageMetricsAdviceTests {
applicationContext.refresh();
}
@After
public void tearDown() throws Exception {
if (this.applicationContext != null) {
this.applicationContext.close();
}
}
@Test
public void exportAdvisedHandler() throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009-2016 the original author or authors.
* Copyright 2009-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.
@@ -19,10 +19,16 @@ package org.springframework.integration.monitor;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.messaging.PollableChannel;
/**
* @author Dave Syer
* @author Gary Russell
* @author Artem Bilan
*/
public class MessageSourceMonitoringIntegrationTests {
private PollableChannel channel;
@@ -74,17 +80,21 @@ public class MessageSourceMonitoringIntegrationTests {
private ClassPathXmlApplicationContext createContext(String config, String channelName) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config, getClass());
context.getAutowireCapableBeanFactory().autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
context.getAutowireCapableBeanFactory()
.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
channel = context.getBean(channelName, PollableChannel.class);
return context;
}
public interface Service {
String execute() throws Exception;
int getCounter();
}
public static class SimpleService implements Service {
private int counter;
public String execute() throws Exception {
@@ -96,6 +106,7 @@ public class MessageSourceMonitoringIntegrationTests {
public int getCounter() {
return counter;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-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.
@@ -39,6 +39,7 @@ import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
import org.springframework.integration.scheduling.PollerMetadata;
import org.springframework.jmx.support.MBeanServerFactoryBean;
import org.springframework.messaging.PollableChannel;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
/**
@@ -47,6 +48,7 @@ import org.springframework.test.context.junit4.SpringRunner;
*
*/
@RunWith(SpringRunner.class)
@DirtiesContext
public class MessageSourceTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-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,7 +16,7 @@
package org.springframework.integration.mail;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -34,7 +34,6 @@ import javax.mail.Store;
import javax.mail.URLName;
import org.junit.Test;
import org.mockito.internal.stubbing.answers.DoesNothing;
import org.springframework.beans.DirectFieldAccessor;
@@ -66,7 +65,7 @@ public class MailReceiverTests {
when(folder.exists()).thenReturn(true);
when(folder.isOpen()).thenReturn(false);
doReturn(folder).when(store).getFolder((URLName) null);
doAnswer(new DoesNothing()).when(store).connect();
doNothing().when(store).connect();
receiver.openFolder();
receiver.openFolder();
verify(store, times(2)).connect();

View File

@@ -36,9 +36,9 @@ import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.IndexOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.CustomConversions;
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
import org.springframework.data.mongodb.core.index.Index;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.core.query.Criteria;
@@ -134,7 +134,7 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe
List<Object> customConverters = new ArrayList<Object>();
customConverters.add(new MessageToBinaryConverter());
customConverters.add(new BinaryToMessageConverter());
this.mappingMongoConverter.setCustomConversions(new CustomConversions(customConverters));
this.mappingMongoConverter.setCustomConversions(new MongoCustomConversions(customConverters));
this.mappingMongoConverter.afterPropertiesSet();
}
this.mongoTemplate = new MongoTemplate(this.mongoDbFactory, this.mappingMongoConverter);

View File

@@ -51,9 +51,9 @@ import org.springframework.data.mongodb.core.BulkOperations;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.IndexOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.CustomConversions;
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
import org.springframework.data.mongodb.core.index.Index;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
@@ -94,6 +94,7 @@ import com.mongodb.DBObject;
* @author Jodie StJohn
* @author Gary Russell
* @author Artem Bilan
*
* @since 2.1
*/
public class MongoDbMessageStore extends AbstractMessageGroupStore
@@ -506,7 +507,7 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
customConverters.add(new DocumentToErrorMessageConverter());
customConverters.add(new DocumentToAdviceMessageConverter());
customConverters.add(new ThrowableToBytesConverter());
this.setCustomConversions(new CustomConversions(customConverters));
this.setCustomConversions(new MongoCustomConversions(customConverters));
super.afterPropertiesSet();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-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.
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.integration.config.IntegrationConfigurationInitializer;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.HandlerMapping;
@@ -44,6 +45,7 @@ import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
*
* @author Artem Bilan
* @author Gary Russell
*
* @since 4.1
*/
public class WebSocketIntegrationConfigurationInitializer implements IntegrationConfigurationInitializer {
@@ -111,12 +113,15 @@ public class WebSocketIntegrationConfigurationInitializer implements Integration
private static class WebSocketHandlerMappingFactoryBean extends AbstractFactoryBean<HandlerMapping>
implements ApplicationContextAware {
private ServletWebSocketHandlerRegistry registry;
private final IntegrationServletWebSocketHandlerRegistry registry =
new IntegrationServletWebSocketHandlerRegistry();
private ThreadPoolTaskScheduler sockJsTaskScheduler;
private ApplicationContext applicationContext;
public void setSockJsTaskScheduler(ThreadPoolTaskScheduler sockJsTaskScheduler) {
this.registry = new ServletWebSocketHandlerRegistry(sockJsTaskScheduler);
this.sockJsTaskScheduler = sockJsTaskScheduler;
}
@Override
@@ -131,6 +136,9 @@ public class WebSocketIntegrationConfigurationInitializer implements Integration
for (WebSocketConfigurer configurer : webSocketConfigurers) {
configurer.registerWebSocketHandlers(this.registry);
}
if (this.registry.requiresTaskScheduler()) {
this.registry.setTaskScheduler(this.sockJsTaskScheduler);
}
AbstractHandlerMapping handlerMapping = this.registry.getHandlerMapping();
handlerMapping.setApplicationContext(this.applicationContext);
return handlerMapping;
@@ -143,4 +151,18 @@ public class WebSocketIntegrationConfigurationInitializer implements Integration
}
private static class IntegrationServletWebSocketHandlerRegistry extends ServletWebSocketHandlerRegistry {
@Override
public boolean requiresTaskScheduler() {
return super.requiresTaskScheduler();
}
@Override
public void setTaskScheduler(TaskScheduler scheduler) {
super.setTaskScheduler(scheduler);
}
}
}