Upgrade dependencies
* Gradle 6.1.1 * MongoDb 4.0 * Other Spring dependencies to `BUILD-SNAPSHOT` * Fix MongoDb tests according latest Spring Data * State in the docs that both MongoDb driver are `optional` now in the dependencies
This commit is contained in:
21
build.gradle
21
build.gradle
@@ -47,8 +47,8 @@ ext {
|
||||
apacheSshdVersion = '2.3.0'
|
||||
avroVersion = '1.9.1'
|
||||
aspectjVersion = '1.9.5'
|
||||
assertjVersion = '3.14.0'
|
||||
assertkVersion = '0.20'
|
||||
assertjVersion = '3.15.0'
|
||||
assertkVersion = '0.21'
|
||||
awaitilityVersion = '4.0.2'
|
||||
commonsDbcp2Version = '2.7.0'
|
||||
commonsIoVersion = '2.6'
|
||||
@@ -59,11 +59,11 @@ ext {
|
||||
googleJsr305Version = '3.0.2'
|
||||
groovyVersion = '2.5.9'
|
||||
hamcrestVersion = '2.2'
|
||||
hazelcastVersion = '3.12.5'
|
||||
hazelcastVersion = '3.12.6'
|
||||
hibernateVersion = '5.4.10.Final'
|
||||
hsqldbVersion = '2.5.0'
|
||||
h2Version = '1.4.200'
|
||||
jacksonVersion = '2.10.1'
|
||||
jacksonVersion = '2.10.2'
|
||||
javaxActivationVersion = '1.2.0'
|
||||
javaxMailVersion = '1.6.2'
|
||||
jmsApiVersion = '2.0.1'
|
||||
@@ -73,15 +73,15 @@ ext {
|
||||
jschVersion = '0.1.55'
|
||||
jsonpathVersion = '2.4.0'
|
||||
junit4Version = '4.13'
|
||||
junitJupiterVersion = '5.5.2'
|
||||
junitJupiterVersion = '5.6.0'
|
||||
jythonVersion = '2.7.0'
|
||||
kryoShadedVersion = '4.0.2'
|
||||
lettuceVersion = '5.2.1.RELEASE'
|
||||
log4jVersion = '2.13.0'
|
||||
micrometerVersion = '1.3.3'
|
||||
mockitoVersion = '3.2.4'
|
||||
mongoDriverVersion = '1.13.0'
|
||||
mysqlVersion = '8.0.18'
|
||||
mongoDriverVersion = '4.0.0-beta1'
|
||||
mysqlVersion = '8.0.19'
|
||||
pahoMqttClientVersion = '1.2.0'
|
||||
postgresVersion = '42.2.9'
|
||||
reactorVersion = 'Dysprosium-SR4'
|
||||
@@ -91,8 +91,8 @@ ext {
|
||||
servletApiVersion = '4.0.1'
|
||||
smackVersion = '4.3.4'
|
||||
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.2.3.RELEASE'
|
||||
springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : 'Neumann-M2'
|
||||
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '5.3.0.M1'
|
||||
springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : 'Neumann-BUILD-SNAPSHOT'
|
||||
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '5.3.0.BUILD-SNAPSHOT'
|
||||
springRetryVersion = '1.2.5.RELEASE'
|
||||
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.2.3.RELEASE'
|
||||
springWsVersion = '3.0.8.RELEASE'
|
||||
@@ -313,7 +313,7 @@ configure(javaProjects) { subproject ->
|
||||
|
||||
checkstyle {
|
||||
configFile = file("$rootDir/src/checkstyle/checkstyle.xml")
|
||||
toolVersion = project.hasProperty('checkstyleVersion') ? project.checkstyleVersion : '8.28'
|
||||
toolVersion = project.hasProperty('checkstyleVersion') ? project.checkstyleVersion : '8.29'
|
||||
}
|
||||
|
||||
jar {
|
||||
@@ -592,6 +592,7 @@ project('spring-integration-mongodb') {
|
||||
api ('org.springframework.data:spring-data-mongodb') {
|
||||
exclude group: 'org.springframework'
|
||||
}
|
||||
optionalApi "org.mongodb:mongodb-driver-sync:$mongoDriverVersion"
|
||||
optionalApi "org.mongodb:mongodb-driver-reactivestreams:$mongoDriverVersion"
|
||||
}
|
||||
}
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.integration.channel.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.willAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -181,7 +182,9 @@ public class ReactiveStreamsConsumerTests {
|
||||
BlockingQueue<Message<?>> messages = new LinkedBlockingQueue<>();
|
||||
|
||||
willAnswer(i -> {
|
||||
messages.put(i.getArgument(0));
|
||||
Message<?> message = i.getArgument(0);
|
||||
LOGGER.debug("Polled message: " + message);
|
||||
messages.put(message);
|
||||
return null;
|
||||
})
|
||||
.given(testSubscriber)
|
||||
@@ -220,6 +223,8 @@ public class ReactiveStreamsConsumerTests {
|
||||
|
||||
testChannel.send(testMessage2);
|
||||
|
||||
await().untilAsserted(() -> assertThat(messages).hasSizeGreaterThan(0));
|
||||
|
||||
LOGGER.debug("Messages to poll: " + messages);
|
||||
|
||||
message = messages.poll(10, TimeUnit.SECONDS);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.mongodb.dsl;
|
||||
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
|
||||
@@ -37,13 +37,13 @@ public final class MongoDb {
|
||||
|
||||
/**
|
||||
* Create a {@link MongoDbOutboundGatewaySpec} builder instance
|
||||
* based on the provided {@link MongoDbFactory} and {@link MongoConverter}.
|
||||
* @param mongoDbFactory the {@link MongoDbFactory} to use.
|
||||
* based on the provided {@link MongoDatabaseFactory} and {@link MongoConverter}.
|
||||
* @param mongoDbFactory the {@link MongoDatabaseFactory} to use.
|
||||
* @param mongoConverter the {@link MongoConverter} to use.
|
||||
* @return the {@link MongoDbOutboundGatewaySpec} instance
|
||||
*/
|
||||
public static MongoDbOutboundGatewaySpec outboundGateway(
|
||||
MongoDbFactory mongoDbFactory, MongoConverter mongoConverter) {
|
||||
MongoDatabaseFactory mongoDbFactory, MongoConverter mongoConverter) {
|
||||
|
||||
return new MongoDbOutboundGatewaySpec(mongoDbFactory, mongoConverter);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.mongodb.dsl;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
@@ -40,7 +40,7 @@ import org.springframework.messaging.Message;
|
||||
public class MongoDbOutboundGatewaySpec
|
||||
extends MessageHandlerSpec<MongoDbOutboundGatewaySpec, MongoDbOutboundGateway> {
|
||||
|
||||
MongoDbOutboundGatewaySpec(MongoDbFactory mongoDbFactory, MongoConverter mongoConverter) {
|
||||
MongoDbOutboundGatewaySpec(MongoDatabaseFactory mongoDbFactory, MongoConverter mongoConverter) {
|
||||
this.target = new MongoDbOutboundGateway(mongoDbFactory, mongoConverter);
|
||||
this.target.setRequiresReply(true);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.mongodb.inbound;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
@@ -67,7 +67,7 @@ import com.mongodb.DBObject;
|
||||
public class MongoDbMessageSource extends AbstractMessageSource<Object> {
|
||||
|
||||
@Nullable
|
||||
private final MongoDbFactory mongoDbFactory;
|
||||
private final MongoDatabaseFactory mongoDbFactory;
|
||||
|
||||
private final Expression queryExpression;
|
||||
|
||||
@@ -86,13 +86,13 @@ public class MongoDbMessageSource extends AbstractMessageSource<Object> {
|
||||
private volatile boolean initialized = false;
|
||||
|
||||
/**
|
||||
* Creates an instance with the provided {@link MongoDbFactory} and SpEL expression
|
||||
* Creates an instance with the provided {@link MongoDatabaseFactory} and SpEL expression
|
||||
* which should resolve to a MongoDb 'query' string (see https://www.mongodb.org/display/DOCS/Querying).
|
||||
* The 'queryExpression' will be evaluated on every call to the {@link #receive()} method.
|
||||
* @param mongoDbFactory The mongodb factory.
|
||||
* @param queryExpression The query expression.
|
||||
*/
|
||||
public MongoDbMessageSource(MongoDbFactory mongoDbFactory, Expression queryExpression) {
|
||||
public MongoDbMessageSource(MongoDatabaseFactory mongoDbFactory, Expression queryExpression) {
|
||||
Assert.notNull(mongoDbFactory, "'mongoDbFactory' must not be null");
|
||||
Assert.notNull(queryExpression, "'queryExpression' must not be null");
|
||||
this.mongoDbFactory = mongoDbFactory;
|
||||
@@ -154,7 +154,7 @@ public class MongoDbMessageSource extends AbstractMessageSource<Object> {
|
||||
/**
|
||||
* Allows you to provide a custom {@link MongoConverter} used to assist in deserialization
|
||||
* data read from MongoDb. Only allowed if this instance was constructed with a
|
||||
* {@link MongoDbFactory}.
|
||||
* {@link MongoDatabaseFactory}.
|
||||
* @param mongoConverter The mongo converter.
|
||||
*/
|
||||
public void setMongoConverter(MongoConverter mongoConverter) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Map;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.FindAndModifyOptions;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
@@ -58,21 +58,21 @@ public class MongoDbMetadataStore implements ConcurrentMetadataStore {
|
||||
private final String collectionName;
|
||||
|
||||
/**
|
||||
* Configure the MongoDbMetadataStore by provided {@link MongoDbFactory} and
|
||||
* Configure the MongoDbMetadataStore by provided {@link MongoDatabaseFactory} and
|
||||
* default collection name - {@link #DEFAULT_COLLECTION_NAME}.
|
||||
* @param factory the mongodb factory
|
||||
*/
|
||||
public MongoDbMetadataStore(MongoDbFactory factory) {
|
||||
public MongoDbMetadataStore(MongoDatabaseFactory factory) {
|
||||
this(factory, DEFAULT_COLLECTION_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the MongoDbMetadataStore by provided {@link MongoDbFactory} and
|
||||
* Configure the MongoDbMetadataStore by provided {@link MongoDatabaseFactory} and
|
||||
* collection name
|
||||
* @param factory the mongodb factory
|
||||
* @param collectionName the collection name where it persists the data
|
||||
*/
|
||||
public MongoDbMetadataStore(MongoDbFactory factory, String collectionName) {
|
||||
public MongoDbMetadataStore(MongoDatabaseFactory factory, String collectionName) {
|
||||
this(new MongoTemplate(factory), collectionName);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.mongodb.outbound;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
|
||||
@@ -46,7 +46,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class MongoDbOutboundGateway extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
private MongoDatabaseFactory mongoDbFactory;
|
||||
|
||||
private MongoConverter mongoConverter;
|
||||
|
||||
@@ -64,12 +64,12 @@ public class MongoDbOutboundGateway extends AbstractReplyProducingMessageHandler
|
||||
|
||||
private Expression collectionNameExpression;
|
||||
|
||||
public MongoDbOutboundGateway(MongoDbFactory mongoDbFactory) {
|
||||
public MongoDbOutboundGateway(MongoDatabaseFactory mongoDbFactory) {
|
||||
this(mongoDbFactory, new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory),
|
||||
new MongoMappingContext()));
|
||||
}
|
||||
|
||||
public MongoDbOutboundGateway(MongoDbFactory mongoDbFactory, MongoConverter mongoConverter) {
|
||||
public MongoDbOutboundGateway(MongoDatabaseFactory mongoDbFactory, MongoConverter mongoConverter) {
|
||||
Assert.notNull(mongoDbFactory, "mongoDatabaseFactory must not be null.");
|
||||
Assert.notNull(mongoConverter, "mongoConverter must not be null.");
|
||||
this.mongoDbFactory = mongoDbFactory;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.mongodb.outbound;
|
||||
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
@@ -42,7 +42,7 @@ public class MongoDbStoringMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
private volatile MongoOperations mongoTemplate;
|
||||
|
||||
private volatile MongoDbFactory mongoDbFactory;
|
||||
private volatile MongoDatabaseFactory mongoDbFactory;
|
||||
|
||||
private volatile MongoConverter mongoConverter;
|
||||
|
||||
@@ -53,11 +53,11 @@ public class MongoDbStoringMessageHandler extends AbstractMessageHandler {
|
||||
private volatile boolean initialized = false;
|
||||
|
||||
/**
|
||||
* Will construct this instance using provided {@link MongoDbFactory}
|
||||
* Will construct this instance using provided {@link MongoDatabaseFactory}
|
||||
*
|
||||
* @param mongoDbFactory The mongodb factory.
|
||||
*/
|
||||
public MongoDbStoringMessageHandler(MongoDbFactory mongoDbFactory) {
|
||||
public MongoDbStoringMessageHandler(MongoDatabaseFactory mongoDbFactory) {
|
||||
Assert.notNull(mongoDbFactory, "'mongoDbFactory' must not be null");
|
||||
|
||||
this.mongoDbFactory = mongoDbFactory;
|
||||
@@ -78,7 +78,7 @@ public class MongoDbStoringMessageHandler extends AbstractMessageHandler {
|
||||
/**
|
||||
* Allows you to provide custom {@link MongoConverter} used to assist in serialization
|
||||
* of data written to MongoDb. Only allowed if this instance was constructed with a
|
||||
* {@link MongoDbFactory}.
|
||||
* {@link MongoDatabaseFactory}.
|
||||
*
|
||||
* @param mongoConverter The mongo converter.
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.FindAndModifyOptions;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
|
||||
@@ -76,7 +76,7 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe
|
||||
|
||||
protected final String collectionName; // NOSONAR - final
|
||||
|
||||
protected final MongoDbFactory mongoDbFactory; // NOSONAR - final
|
||||
protected final MongoDatabaseFactory mongoDbFactory; // NOSONAR - final
|
||||
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@@ -94,11 +94,11 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe
|
||||
this.mongoDbFactory = null;
|
||||
}
|
||||
|
||||
public AbstractConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory, String collectionName) {
|
||||
public AbstractConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, String collectionName) {
|
||||
this(mongoDbFactory, null, collectionName);
|
||||
}
|
||||
|
||||
public AbstractConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory,
|
||||
public AbstractConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory,
|
||||
MappingMongoConverter mappingMongoConverter, String collectionName) {
|
||||
Assert.notNull(mongoDbFactory, "'mongoDbFactory' must not be null");
|
||||
Assert.hasText(collectionName, "'collectionName' must not be empty");
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
@@ -68,19 +68,19 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
super(mongoTemplate, collectionName);
|
||||
}
|
||||
|
||||
public ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory) {
|
||||
public ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory) {
|
||||
this(mongoDbFactory, null, DEFAULT_COLLECTION_NAME);
|
||||
}
|
||||
|
||||
public ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter) {
|
||||
public ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter) {
|
||||
this(mongoDbFactory, mappingMongoConverter, DEFAULT_COLLECTION_NAME);
|
||||
}
|
||||
|
||||
public ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory, String collectionName) {
|
||||
public ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, String collectionName) {
|
||||
this(mongoDbFactory, null, collectionName);
|
||||
}
|
||||
|
||||
public ConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter,
|
||||
public ConfigurableMongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter,
|
||||
String collectionName) {
|
||||
|
||||
super(mongoDbFactory, mappingMongoConverter, collectionName);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.integration.mongodb.store;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
import org.springframework.data.mongodb.core.index.Index;
|
||||
@@ -61,19 +61,19 @@ public class MongoDbChannelMessageStore extends AbstractConfigurableMongoDbMessa
|
||||
super(mongoTemplate, collectionName);
|
||||
}
|
||||
|
||||
public MongoDbChannelMessageStore(MongoDbFactory mongoDbFactory) {
|
||||
public MongoDbChannelMessageStore(MongoDatabaseFactory mongoDbFactory) {
|
||||
this(mongoDbFactory, null, DEFAULT_COLLECTION_NAME);
|
||||
}
|
||||
|
||||
public MongoDbChannelMessageStore(MongoDbFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter) {
|
||||
public MongoDbChannelMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter) {
|
||||
this(mongoDbFactory, mappingMongoConverter, DEFAULT_COLLECTION_NAME);
|
||||
}
|
||||
|
||||
public MongoDbChannelMessageStore(MongoDbFactory mongoDbFactory, String collectionName) {
|
||||
public MongoDbChannelMessageStore(MongoDatabaseFactory mongoDbFactory, String collectionName) {
|
||||
this(mongoDbFactory, null, collectionName);
|
||||
}
|
||||
|
||||
public MongoDbChannelMessageStore(MongoDbFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter,
|
||||
public MongoDbChannelMessageStore(MongoDatabaseFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter,
|
||||
String collectionName) {
|
||||
super(mongoDbFactory, mappingMongoConverter, collectionName);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.springframework.data.convert.ReadingConverter;
|
||||
import org.springframework.data.convert.WritingConverter;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.BulkOperations;
|
||||
import org.springframework.data.mongodb.core.FindAndModifyOptions;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
@@ -141,19 +141,19 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
|
||||
private String[] whiteListPatterns;
|
||||
|
||||
/**
|
||||
* Create a MongoDbMessageStore using the provided {@link MongoDbFactory}.and the default collection name.
|
||||
* Create a MongoDbMessageStore using the provided {@link MongoDatabaseFactory}.and the default collection name.
|
||||
* @param mongoDbFactory The mongodb factory.
|
||||
*/
|
||||
public MongoDbMessageStore(MongoDbFactory mongoDbFactory) {
|
||||
public MongoDbMessageStore(MongoDatabaseFactory mongoDbFactory) {
|
||||
this(mongoDbFactory, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MongoDbMessageStore using the provided {@link MongoDbFactory} and collection name.
|
||||
* Create a MongoDbMessageStore using the provided {@link MongoDatabaseFactory} and collection name.
|
||||
* @param mongoDbFactory The mongodb factory.
|
||||
* @param collectionName The collection name.
|
||||
*/
|
||||
public MongoDbMessageStore(MongoDbFactory mongoDbFactory, @Nullable String collectionName) {
|
||||
public MongoDbMessageStore(MongoDatabaseFactory mongoDbFactory, @Nullable String collectionName) {
|
||||
Assert.notNull(mongoDbFactory, "mongoDbFactory must not be null");
|
||||
this.converter = new MessageReadingMongoConverter(mongoDbFactory, new MongoMappingContext());
|
||||
this.template = new MongoTemplate(mongoDbFactory, this.converter);
|
||||
@@ -523,7 +523,7 @@ public class MongoDbMessageStore extends AbstractMessageGroupStore
|
||||
|
||||
private Object[] customConverters;
|
||||
|
||||
MessageReadingMongoConverter(MongoDbFactory mongoDbFactory,
|
||||
MessageReadingMongoConverter(MongoDatabaseFactory mongoDbFactory,
|
||||
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) {
|
||||
super(new DefaultDbRefResolver(mongoDbFactory), mappingContext);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
@@ -49,7 +49,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
public class MongoDbInboundChannelAdapterParserTests {
|
||||
|
||||
@Autowired
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
private MongoDatabaseFactory mongoDbFactory;
|
||||
|
||||
@Autowired
|
||||
private MongoConverter mongoConverter;
|
||||
|
||||
@@ -21,7 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.BasicQuery;
|
||||
import org.springframework.integration.mongodb.rules.MongoDbAvailable;
|
||||
@@ -49,7 +49,7 @@ public class MongoDbOutboundChannelAdapterIntegrationTests extends MongoDbAvaila
|
||||
Message<Person> message = new GenericMessage<MongoDbAvailableTests.Person>(this.createPerson("Bob"));
|
||||
channel.send(message);
|
||||
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
assertThat(template.find(new BasicQuery("{'name' : 'Bob'}"), Person.class, "data")).isNotNull();
|
||||
context.close();
|
||||
@@ -58,7 +58,7 @@ public class MongoDbOutboundChannelAdapterIntegrationTests extends MongoDbAvaila
|
||||
@Test
|
||||
@MongoDbAvailable
|
||||
public void testWithNamedCollection() throws Exception {
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
ClassPathXmlApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("outbound-adapter-config.xml", this.getClass());
|
||||
|
||||
@@ -77,7 +77,7 @@ public class MongoDbOutboundChannelAdapterIntegrationTests extends MongoDbAvaila
|
||||
@Test
|
||||
@MongoDbAvailable
|
||||
public void testWithTemplate() throws Exception {
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
ClassPathXmlApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("outbound-adapter-config.xml", this.getClass());
|
||||
|
||||
@@ -100,7 +100,7 @@ public class MongoDbOutboundChannelAdapterIntegrationTests extends MongoDbAvaila
|
||||
|
||||
BasicDBObject dbObject = BasicDBObject.parse("{'foo' : 'bar'}");
|
||||
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
ClassPathXmlApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("outbound-adapter-config.xml", this.getClass());
|
||||
|
||||
@@ -124,7 +124,7 @@ public class MongoDbOutboundChannelAdapterIntegrationTests extends MongoDbAvaila
|
||||
|
||||
String object = "{'foo' : 'bar'}";
|
||||
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
ClassPathXmlApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("outbound-adapter-config.xml", this.getClass());
|
||||
|
||||
@@ -152,7 +152,7 @@ public class MongoDbOutboundChannelAdapterIntegrationTests extends MongoDbAvaila
|
||||
Message<Person> message = new GenericMessage<MongoDbAvailableTests.Person>(this.createPerson("Bob"));
|
||||
channel.send(message);
|
||||
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
assertThat(template.find(new BasicQuery("{'name' : 'Bob'}"), Person.class, "data")).isNotNull();
|
||||
context.close();
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.expression.spel.standard.SpelExpression;
|
||||
@@ -55,7 +55,7 @@ public class MongoDbOutboundGatewayParserTests {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
private MongoDatabaseFactory mongoDbFactory;
|
||||
|
||||
@Autowired
|
||||
private MongoConverter mongoConverter;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.BulkOperations;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
@@ -345,7 +345,7 @@ public class MongoDbTests extends MongoDbAvailableTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MongoDbFactory mongoDbFactory() {
|
||||
public MongoDatabaseFactory mongoDbFactory() {
|
||||
return MONGO_DATABASE_FACTORY;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
@@ -58,7 +58,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@Test
|
||||
public void withNullMongoDBFactory() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new MongoDbMessageSource((MongoDbFactory) null, mock(Expression.class)));
|
||||
.isThrownBy(() -> new MongoDbMessageSource((MongoDatabaseFactory) null, mock(Expression.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,13 +70,13 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@Test
|
||||
public void withNullQueryExpression() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new MongoDbMessageSource(mock(MongoDbFactory.class), null));
|
||||
.isThrownBy(() -> new MongoDbMessageSource(mock(MongoDatabaseFactory.class), null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@MongoDbAvailable
|
||||
public void validateSuccessfulQueryWithSingleElementIfOneInListAsDbObject() {
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
template.save(this.createPerson(), "data");
|
||||
@@ -96,7 +96,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@Test
|
||||
@MongoDbAvailable
|
||||
public void validateSuccessfulQueryWithSingleElementIfOneInList() {
|
||||
MongoDbFactory mongoDbFactory = prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = prepareMongoFactory();
|
||||
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
template.save(this.createPerson(), "data");
|
||||
@@ -117,7 +117,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@Test
|
||||
@MongoDbAvailable
|
||||
public void validateSuccessfulQueryWithSingleElementIfOneInListAndSingleResult() {
|
||||
MongoDbFactory mongoDbFactory = prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = prepareMongoFactory();
|
||||
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
template.save(this.createPerson(), "data");
|
||||
@@ -138,7 +138,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@Test
|
||||
@MongoDbAvailable
|
||||
public void validateSuccessfulSubObjectQueryWithSingleElementIfOneInList() {
|
||||
MongoDbFactory mongoDbFactory = prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = prepareMongoFactory();
|
||||
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
template.save(this.createPerson(), "data");
|
||||
@@ -180,7 +180,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Person> queryMultipleElements(Expression queryExpression) {
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
template.save(this.createPerson("Manny"), "data");
|
||||
@@ -198,7 +198,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@MongoDbAvailable
|
||||
public void validateSuccessfulQueryWithNullReturn() {
|
||||
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
template.save(this.createPerson("Manny"), "data");
|
||||
@@ -217,7 +217,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@MongoDbAvailable
|
||||
public void validateSuccessfulQueryWithCustomConverter() {
|
||||
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
template.save(this.createPerson("Manny"), "data");
|
||||
@@ -243,7 +243,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@MongoDbAvailable
|
||||
public void validateSuccessfulQueryWithMongoTemplate() {
|
||||
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
|
||||
MappingMongoConverter converter = new TestMongoConverter(mongoDbFactory, new MongoMappingContext());
|
||||
converter.afterPropertiesSet();
|
||||
@@ -269,7 +269,7 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@MongoDbAvailable
|
||||
public void validatePipelineInModifyOut() {
|
||||
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.integration.mongodb.rules.MongoDbAvailable;
|
||||
import org.springframework.integration.mongodb.rules.MongoDbAvailableTests;
|
||||
@@ -45,7 +45,7 @@ public class MongoDbMetadataStoreTests extends MongoDbAvailableTests {
|
||||
|
||||
@Before
|
||||
public void configure() {
|
||||
final MongoDbFactory mongoDbFactory = this.prepareMongoFactory(DEFAULT_COLLECTION_NAME);
|
||||
final MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory(DEFAULT_COLLECTION_NAME);
|
||||
this.store = new MongoDbMetadataStore(mongoDbFactory);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MongoDbMetadataStoreTests extends MongoDbAvailableTests {
|
||||
@Test
|
||||
public void testConfigureCustomCollection() {
|
||||
final String collectionName = "testMetadataStore";
|
||||
final MongoDbFactory mongoDbFactory = this.prepareMongoFactory(collectionName);
|
||||
final MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory(collectionName);
|
||||
final MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
store = new MongoDbMetadataStore(template, collectionName);
|
||||
testBasics();
|
||||
@@ -62,7 +62,7 @@ public class MongoDbMetadataStoreTests extends MongoDbAvailableTests {
|
||||
@MongoDbAvailable
|
||||
@Test
|
||||
public void testConfigureFactory() {
|
||||
final MongoDbFactory mongoDbFactory = this.prepareMongoFactory(DEFAULT_COLLECTION_NAME);
|
||||
final MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory(DEFAULT_COLLECTION_NAME);
|
||||
store = new MongoDbMetadataStore(mongoDbFactory);
|
||||
testBasics();
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class MongoDbMetadataStoreTests extends MongoDbAvailableTests {
|
||||
@Test
|
||||
public void testConfigureFactorCustomCollection() {
|
||||
final String collectionName = "testMetadataStore";
|
||||
final MongoDbFactory mongoDbFactory = this.prepareMongoFactory(collectionName);
|
||||
final MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory(collectionName);
|
||||
store = new MongoDbMetadataStore(mongoDbFactory, collectionName);
|
||||
testBasics();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.mongodb.outbound;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -31,7 +32,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.BulkOperations;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
@@ -50,7 +51,7 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author Xavier Padr?
|
||||
* @author Xavier Padro
|
||||
* @author Gary Rssell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
@@ -74,7 +75,7 @@ public class MongoDbOutboundGatewayTests extends MongoDbAvailableTests {
|
||||
private MongoConverter mongoConverter;
|
||||
|
||||
@Autowired
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
private MongoDatabaseFactory mongoDbFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -95,14 +96,9 @@ public class MongoDbOutboundGatewayTests extends MongoDbAvailableTests {
|
||||
@Test
|
||||
@MongoDbAvailable
|
||||
public void testNoFactorySpecified() {
|
||||
|
||||
try {
|
||||
new MongoDbOutboundGateway((MongoDbFactory) null);
|
||||
fail("Expected the test case to throw an IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage()).isEqualTo("MongoDbFactory translator must not be null!");
|
||||
}
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new MongoDbOutboundGateway((MongoDatabaseFactory) null))
|
||||
.withMessage("MongoDbFactory translator must not be null!");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.mongodb.rules.MongoDbAvailable;
|
||||
@@ -55,7 +55,7 @@ public class MongoDbOutboundGatewayXmlTests extends MongoDbAvailableTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory);
|
||||
|
||||
mongoTemplate.save(this.createPerson("Artem"), COLLECTION_NAME);
|
||||
@@ -66,7 +66,7 @@ public class MongoDbOutboundGatewayXmlTests extends MongoDbAvailableTests {
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory);
|
||||
|
||||
mongoTemplate.dropCollection(COLLECTION_NAME);
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
@@ -53,7 +53,7 @@ public class MongoDbStoringMessageHandlerTests extends MongoDbAvailableTests {
|
||||
|
||||
private MongoTemplate template;
|
||||
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
private MongoDatabaseFactory mongoDbFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -66,7 +66,7 @@ public class MongoDbStoringMessageHandlerTests extends MongoDbAvailableTests {
|
||||
@MongoDbAvailable
|
||||
public void withNullMongoDBFactory() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new MongoDbStoringMessageHandler((MongoDbFactory) null));
|
||||
.isThrownBy(() -> new MongoDbStoringMessageHandler((MongoDatabaseFactory) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,16 +19,17 @@ package org.springframework.integration.mongodb.rules;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.bson.UuidRepresentation;
|
||||
import org.bson.conversions.Bson;
|
||||
import org.junit.Rule;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoClientDbFactory;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
@@ -38,6 +39,7 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
||||
import org.springframework.integration.mongodb.outbound.MessageCollectionCallback;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
import com.mongodb.MongoClientSettings;
|
||||
import com.mongodb.MongoException;
|
||||
import com.mongodb.client.MongoClients;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
@@ -58,14 +60,19 @@ public abstract class MongoDbAvailableTests {
|
||||
@Rule
|
||||
public MongoDbAvailableRule mongoDbAvailableRule = new MongoDbAvailableRule();
|
||||
|
||||
public static final MongoDbFactory MONGO_DATABASE_FACTORY =
|
||||
new SimpleMongoClientDbFactory(MongoClients.create(), "test");
|
||||
public static final MongoDatabaseFactory MONGO_DATABASE_FACTORY =
|
||||
new SimpleMongoClientDatabaseFactory(
|
||||
MongoClients.create(
|
||||
MongoClientSettings.builder().uuidRepresentation(UuidRepresentation.STANDARD).build()),
|
||||
"test");
|
||||
|
||||
public static final ReactiveMongoDatabaseFactory REACTIVE_MONGO_DATABASE_FACTORY =
|
||||
new SimpleReactiveMongoDatabaseFactory(
|
||||
com.mongodb.reactivestreams.client.MongoClients.create(), "test");
|
||||
com.mongodb.reactivestreams.client.MongoClients.create(
|
||||
MongoClientSettings.builder().uuidRepresentation(UuidRepresentation.STANDARD).build()),
|
||||
"test");
|
||||
|
||||
protected MongoDbFactory prepareMongoFactory(String... additionalCollectionsToDrop) {
|
||||
protected MongoDatabaseFactory prepareMongoFactory(String... additionalCollectionsToDrop) {
|
||||
cleanupCollections(MONGO_DATABASE_FACTORY, additionalCollectionsToDrop);
|
||||
return MONGO_DATABASE_FACTORY;
|
||||
}
|
||||
@@ -87,7 +94,7 @@ public abstract class MongoDbAvailableTests {
|
||||
}
|
||||
}
|
||||
|
||||
protected void cleanupCollections(MongoDbFactory mongoDbFactory, String... additionalCollectionsToDrop) {
|
||||
protected void cleanupCollections(MongoDatabaseFactory mongoDbFactory, String... additionalCollectionsToDrop) {
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
template.dropCollection("messages");
|
||||
template.dropCollection("configurableStoreMessages");
|
||||
@@ -182,7 +189,7 @@ public abstract class MongoDbAvailableTests {
|
||||
public static class TestMongoConverter extends MappingMongoConverter {
|
||||
|
||||
public TestMongoConverter(
|
||||
MongoDbFactory mongoDbFactory,
|
||||
MongoDatabaseFactory mongoDbFactory,
|
||||
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) {
|
||||
|
||||
super(new DefaultDbRefResolver(mongoDbFactory), mappingContext);
|
||||
|
||||
@@ -417,7 +417,7 @@ public abstract class AbstractMongoDbMessageGroupStoreTests extends MongoDbAvail
|
||||
// @Test
|
||||
// @MongoDbAvailable
|
||||
// public void testConcurrentModifications() throws Exception{
|
||||
// MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
// MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
// final MongoDbMessageStore store1 = new MongoDbMessageStore(mongoDbFactory);
|
||||
// final MongoDbMessageStore store2 = new MongoDbMessageStore(mongoDbFactory);
|
||||
//
|
||||
|
||||
@@ -39,68 +39,60 @@ To enable reactive support, add the MongoDB reactive streams driver to your depe
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-reactivestreams</artifactId>
|
||||
<version>1.12.0</version>
|
||||
</dependency>
|
||||
----
|
||||
|
||||
.Gradle
|
||||
[source, groovy, subs="normal"]
|
||||
----
|
||||
compile "org.mongodb:mongodb-driver-reactivestreams:1.12.0"
|
||||
compile "org.mongodb:mongodb-driver-reactivestreams"
|
||||
----
|
||||
|
||||
For regular synchronous client you need to add its respective driver into dependencies:
|
||||
|
||||
.Maven
|
||||
[source, xml, subs="normal"]
|
||||
----
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-sync</artifactId>
|
||||
</dependency>
|
||||
----
|
||||
|
||||
.Gradle
|
||||
[source, groovy, subs="normal"]
|
||||
----
|
||||
compile "org.mongodb:mongodb-driver-sync"
|
||||
----
|
||||
|
||||
Both of them are `optional` in the framework for better end-user choice support.
|
||||
|
||||
To begin interacting with MongoDB, you first need to connect to it.
|
||||
Spring Integration builds on the support provided by another Spring project, https://projects.spring.io/spring-data-mongodb/[Spring Data MongoDB].
|
||||
It provides factory classes called `MongoDbFactory` and `ReactiveMongoDatabaseFactory`, which simplify integration with the MongoDB Client API.
|
||||
It provides factory classes called `MongoDatabaseFactory` and `ReactiveMongoDatabaseFactory`, which simplify integration with the MongoDB Client API.
|
||||
|
||||
TIP: Spring Data provides provides the blocking MongoDB driver by default but you may opt-in for reactive usage by including the above dependency.
|
||||
|
||||
==== Using `MongoDbFactory`
|
||||
==== Using `MongoDatabaseFactory`
|
||||
|
||||
To connect to MongoDB you can use an implementation of the `MongoDbFactory` interface.
|
||||
The following listing shows the `MongoDbFactory` interface:
|
||||
To connect to MongoDB you can use an implementation of the `MongoDatabaseFactory` interface.
|
||||
|
||||
The following example shows how to use `SimpleMongoClientDatabaseFactory`, the out-of-the-box implementation, in Java:
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
public interface MongoDbFactory {
|
||||
|
||||
/**
|
||||
* Creates a default {@link DB} instance.
|
||||
*
|
||||
* @return the DB instance
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
DB getDb() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Creates a {@link DB} instance to access the database with the given name.
|
||||
*
|
||||
* @param dbName must not be {@literal null} or empty.
|
||||
*
|
||||
* @return the DB instance
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
DB getDb(String dbName) throws DataAccessException;
|
||||
}
|
||||
MongoDatabaseFactory mongoDbFactory =
|
||||
new SimpleMongoClientDatabaseFactory(com.mongodb.client.MongoClients.create(), "test");
|
||||
----
|
||||
====
|
||||
|
||||
The following example shows how to use `SimpleMongoDbFactory`, the out-of-the-box implementation, in Java:
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(com.mongodb.client.MongoClients.create(), "test");
|
||||
----
|
||||
====
|
||||
|
||||
The following example shows how to use `SimpleMongoDbFactory` in XML configuration:
|
||||
The following example shows how to use `SimpleMongoClientDatabaseFactory` in XML configuration:
|
||||
|
||||
====
|
||||
[source,xml]
|
||||
----
|
||||
<bean id="mongoDbFactory" class="o.s.data.mongodb.core.SimpleMongoDbFactory">
|
||||
<bean id="mongoDbFactory" class="o.s.data.mongodb.core.SimpleMongoClientDatabaseFactory">
|
||||
<constructor-arg>
|
||||
<bean class="com.mongodb.client.MongoClients" factory-method="create"/>
|
||||
</constructor-arg>
|
||||
@@ -109,7 +101,7 @@ The following example shows how to use `SimpleMongoDbFactory` in XML configurati
|
||||
----
|
||||
====
|
||||
|
||||
`SimpleMongoDbFactory` takes two arguments: a `Mongo` instance and a `String` that specifies the name of the database.
|
||||
`SimpleMongoClientDatabaseFactory` takes two arguments: a `MongoClient` instance and a `String` that specifies the name of the database.
|
||||
If you need to configure properties such as `host`, `port`, and others, you can pass those by using one of the constructors provided by the underlying `MongoClients` class.
|
||||
For more information on how to configure MongoDB, see the https://docs.spring.io/spring-data/data-mongo/docs/current/reference/html/[Spring-Data-MongoDB] reference.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user