Revert MongoDb driver 4 changes
* Bring Spring Data MongoDb back to `2.3`; essentially rely on Spring Data BOM for dependencies * Change `mongodb-driver-reactivestreams` driver version back to `1.12.0` * Upgrade to Spring Security 5.3 M1 * Fix MongoDb module to use `MongoDbFactory` class instead of new (not committed yet) `MongoDatabaseFactory` * Remove `uuidRepresentation()` configuration from the `MongoClients` factory usage - that is going to be MongoDb driver 4 feature
This commit is contained in:
committed by
Gary Russell
parent
be9d735c1c
commit
cfaabe2a8d
@@ -8,7 +8,7 @@
|
||||
http://www.springframework.org/schema/integration/mongodb https://www.springframework.org/schema/integration/mongodb/spring-integration-mongodb.xsd">
|
||||
|
||||
<bean id="mongoDbFactory" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.data.mongodb.MongoDatabaseFactory"/>
|
||||
<constructor-arg value="org.springframework.data.mongodb.MongoDbFactory"/>
|
||||
</bean>
|
||||
|
||||
<int-mongodb:inbound-channel-adapter id="minimalConfig"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -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.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
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 MongoDatabaseFactory mongoDbFactory;
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
|
||||
@Autowired
|
||||
private MongoConverter mongoConverter;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -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.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
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);
|
||||
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory 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 {
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
MongoDbFactory 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 {
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
MongoDbFactory 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'}");
|
||||
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
MongoDbFactory 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'}";
|
||||
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory("foo");
|
||||
MongoDbFactory 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);
|
||||
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
assertThat(template.find(new BasicQuery("{'name' : 'Bob'}"), Person.class, "data")).isNotNull();
|
||||
context.close();
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
</bean>
|
||||
|
||||
<bean id="mongoDbFactory" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.data.mongodb.MongoDatabaseFactory"/>
|
||||
<constructor-arg value="org.springframework.data.mongodb.MongoDbFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="mongoConverter"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -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.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.expression.spel.standard.SpelExpression;
|
||||
@@ -57,7 +57,7 @@ public class MongoDbOutboundGatewayParserTests {
|
||||
private ApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private MongoDatabaseFactory mongoDbFactory;
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
|
||||
@Autowired
|
||||
private MongoConverter mongoConverter;
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-mongodb="http://www.springframework.org/schema/integration/mongodb"
|
||||
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/data/mongo https://www.springframework.org/schema/data/mongo/spring-mongo.xsd
|
||||
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/mongodb https://www.springframework.org/schema/integration/mongodb/spring-integration-mongodb.xsd">
|
||||
|
||||
<bean id="mongoDbFactory" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.data.mongodb.MongoDatabaseFactory"/>
|
||||
<constructor-arg value="org.springframework.data.mongodb.MongoDbFactory"/>
|
||||
</bean>
|
||||
|
||||
<int-mongodb:outbound-channel-adapter id="minimalConfig"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -30,11 +30,10 @@ 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.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.BulkOperations;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
@@ -53,8 +52,6 @@ import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.mongodb.client.MongoClients;
|
||||
|
||||
/**
|
||||
* @author Xavier Padro
|
||||
* @author Gary Russell
|
||||
@@ -107,7 +104,7 @@ public class MongoDbTests extends MongoDbAvailableTests {
|
||||
private MongoOperations mongoTemplate;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
createPersons();
|
||||
}
|
||||
|
||||
@@ -325,8 +322,8 @@ public class MongoDbTests extends MongoDbAvailableTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MongoDatabaseFactory mongoDbFactory() {
|
||||
return new SimpleMongoClientDatabaseFactory(MongoClients.create(), "test");
|
||||
public MongoDbFactory mongoDbFactory() {
|
||||
return MONGO_DATABASE_FACTORY;
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 the original author or authors.
|
||||
* Copyright 2007-2020 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.
|
||||
@@ -30,7 +30,7 @@ import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
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((MongoDatabaseFactory) null, mock(Expression.class)));
|
||||
.isThrownBy(() -> new MongoDbMessageSource((MongoDbFactory) null, mock(Expression.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,13 +70,13 @@ public class MongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
@Test
|
||||
public void withNullQueryExpression() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new MongoDbMessageSource(mock(MongoDatabaseFactory.class), null));
|
||||
.isThrownBy(() -> new MongoDbMessageSource(mock(MongoDbFactory.class), null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@MongoDbAvailable
|
||||
public void validateSuccessfulQueryWithSingleElementIfOneInListAsDbObject() {
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory 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() {
|
||||
MongoDatabaseFactory mongoDbFactory = prepareMongoFactory();
|
||||
MongoDbFactory 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() {
|
||||
MongoDatabaseFactory mongoDbFactory = prepareMongoFactory();
|
||||
MongoDbFactory 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() {
|
||||
MongoDatabaseFactory mongoDbFactory = prepareMongoFactory();
|
||||
MongoDbFactory 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) {
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory 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() {
|
||||
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory 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() {
|
||||
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory 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() {
|
||||
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory 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() {
|
||||
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2020 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.
|
||||
@@ -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.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
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 MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory(DEFAULT_COLLECTION_NAME);
|
||||
final MongoDbFactory 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 MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory(collectionName);
|
||||
final MongoDbFactory 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 MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory(DEFAULT_COLLECTION_NAME);
|
||||
final MongoDbFactory 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 MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory(collectionName);
|
||||
final MongoDbFactory mongoDbFactory = this.prepareMongoFactory(collectionName);
|
||||
store = new MongoDbMetadataStore(mongoDbFactory, collectionName);
|
||||
testBasics();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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,7 +31,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.BulkOperations;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
@@ -74,7 +74,7 @@ public class MongoDbOutboundGatewayTests extends MongoDbAvailableTests {
|
||||
private MongoConverter mongoConverter;
|
||||
|
||||
@Autowired
|
||||
private MongoDatabaseFactory mongoDbFactory;
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -97,7 +97,7 @@ public class MongoDbOutboundGatewayTests extends MongoDbAvailableTests {
|
||||
public void testNoFactorySpecified() {
|
||||
|
||||
try {
|
||||
new MongoDbOutboundGateway((MongoDatabaseFactory) null);
|
||||
new MongoDbOutboundGateway((MongoDbFactory) null);
|
||||
fail("Expected the test case to throw an IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -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.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.mongodb.rules.MongoDbAvailable;
|
||||
@@ -53,7 +53,7 @@ public class MongoDbOutboundGatewayXmlTests extends MongoDbAvailableTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory);
|
||||
|
||||
mongoTemplate.save(this.createPerson("Artem"), COLLECTION_NAME);
|
||||
@@ -64,7 +64,7 @@ public class MongoDbOutboundGatewayXmlTests extends MongoDbAvailableTests {
|
||||
|
||||
@After
|
||||
public void cleanUp() throws Exception {
|
||||
MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory);
|
||||
|
||||
mongoTemplate.dropCollection(COLLECTION_NAME);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2019 the original author or authors.
|
||||
* Copyright 2007-2020 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.
|
||||
@@ -29,7 +29,7 @@ import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
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 MongoDatabaseFactory mongoDbFactory;
|
||||
private MongoDbFactory mongoDbFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -66,7 +66,7 @@ public class MongoDbStoringMessageHandlerTests extends MongoDbAvailableTests {
|
||||
@MongoDbAvailable
|
||||
public void withNullMongoDBFactory() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new MongoDbStoringMessageHandler((MongoDatabaseFactory) null));
|
||||
.isThrownBy(() -> new MongoDbStoringMessageHandler((MongoDbFactory) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,17 +19,16 @@ 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.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
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.SimpleMongoClientDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoClientDbFactory;
|
||||
import org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
@@ -60,13 +59,13 @@ public abstract class MongoDbAvailableTests {
|
||||
@Rule
|
||||
public MongoDbAvailableRule mongoDbAvailableRule = new MongoDbAvailableRule();
|
||||
|
||||
public static final MongoDatabaseFactory MONGO_DATABASE_FACTORY =
|
||||
new SimpleMongoClientDatabaseFactory(
|
||||
public static final MongoDbFactory MONGO_DATABASE_FACTORY =
|
||||
new SimpleMongoClientDbFactory(
|
||||
MongoClients.create(
|
||||
MongoClientSettings.builder().uuidRepresentation(UuidRepresentation.STANDARD).build()),
|
||||
MongoClientSettings.builder().build()),
|
||||
"test");
|
||||
|
||||
protected MongoDatabaseFactory prepareMongoFactory(String... additionalCollectionsToDrop) {
|
||||
protected MongoDbFactory prepareMongoFactory(String... additionalCollectionsToDrop) {
|
||||
cleanupCollections(MONGO_DATABASE_FACTORY, additionalCollectionsToDrop);
|
||||
return MONGO_DATABASE_FACTORY;
|
||||
}
|
||||
@@ -90,7 +89,7 @@ public abstract class MongoDbAvailableTests {
|
||||
}
|
||||
}
|
||||
|
||||
protected void cleanupCollections(MongoDatabaseFactory mongoDbFactory, String... additionalCollectionsToDrop) {
|
||||
protected void cleanupCollections(MongoDbFactory mongoDbFactory, String... additionalCollectionsToDrop) {
|
||||
MongoTemplate template = new MongoTemplate(mongoDbFactory);
|
||||
template.dropCollection("messages");
|
||||
template.dropCollection("configurableStoreMessages");
|
||||
@@ -185,7 +184,7 @@ public abstract class MongoDbAvailableTests {
|
||||
public static class TestMongoConverter extends MappingMongoConverter {
|
||||
|
||||
public TestMongoConverter(
|
||||
MongoDatabaseFactory mongoDbFactory,
|
||||
MongoDbFactory mongoDbFactory,
|
||||
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) {
|
||||
|
||||
super(new DefaultDbRefResolver(mongoDbFactory), mappingContext);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -417,7 +417,7 @@ public abstract class AbstractMongoDbMessageGroupStoreTests extends MongoDbAvail
|
||||
// @Test
|
||||
// @MongoDbAvailable
|
||||
// public void testConcurrentModifications() throws Exception{
|
||||
// MongoDatabaseFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
// MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
|
||||
// final MongoDbMessageStore store1 = new MongoDbMessageStore(mongoDbFactory);
|
||||
// final MongoDbMessageStore store2 = new MongoDbMessageStore(mongoDbFactory);
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user