|
|
|
|
@ -20,10 +20,12 @@ import java.io.File;
@@ -20,10 +20,12 @@ import java.io.File;
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
import java.util.EnumSet; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
import com.mongodb.MongoClient; |
|
|
|
|
import de.flapdoodle.embed.mongo.MongodExecutable; |
|
|
|
|
import de.flapdoodle.embed.mongo.MongodStarter; |
|
|
|
|
import de.flapdoodle.embed.mongo.config.IMongodConfig; |
|
|
|
|
import de.flapdoodle.embed.mongo.config.Storage; |
|
|
|
|
import de.flapdoodle.embed.mongo.distribution.Feature; |
|
|
|
|
@ -37,6 +39,7 @@ import org.junit.jupiter.api.io.TempDir;
@@ -37,6 +39,7 @@ import org.junit.jupiter.api.io.TempDir;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.DirectFieldAccessor; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.beans.factory.config.BeanDefinition; |
|
|
|
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; |
|
|
|
|
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration; |
|
|
|
|
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; |
|
|
|
|
@ -56,6 +59,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@@ -56,6 +59,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
* @author Henryk Konsek |
|
|
|
|
* @author Andy Wilkinson |
|
|
|
|
* @author Stephane Nicoll |
|
|
|
|
* @author Issam El-atif |
|
|
|
|
*/ |
|
|
|
|
class EmbeddedMongoAutoConfigurationTests { |
|
|
|
|
|
|
|
|
|
@ -186,6 +190,16 @@ class EmbeddedMongoAutoConfigurationTests {
@@ -186,6 +190,16 @@ class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
|
assertThat(this.context.getBean(MongodExecutable.class).isRegisteredJobKiller()).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void customMongoServerConfiguration() { |
|
|
|
|
load(CustomMongoConfiguration.class); |
|
|
|
|
Map<String, MongoClient> mongoClients = this.context.getBeansOfType(MongoClient.class); |
|
|
|
|
for (String mongoClientBeanName : mongoClients.keySet()) { |
|
|
|
|
BeanDefinition beanDefinition = this.context.getBeanFactory().getBeanDefinition(mongoClientBeanName); |
|
|
|
|
assertThat(beanDefinition.getDependsOn()).contains("customMongoServer"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void assertVersionConfiguration(String configuredVersion, String expectedVersion) { |
|
|
|
|
this.context = new AnnotationConfigApplicationContext(); |
|
|
|
|
TestPropertyValues.of("spring.data.mongodb.port=0").applyTo(this.context); |
|
|
|
|
@ -248,4 +262,15 @@ class EmbeddedMongoAutoConfigurationTests {
@@ -248,4 +262,15 @@ class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
static class CustomMongoConfiguration { |
|
|
|
|
|
|
|
|
|
@Bean(initMethod = "start", destroyMethod = "stop") |
|
|
|
|
MongodExecutable customMongoServer(IRuntimeConfig runtimeConfig, IMongodConfig mongodConfig) { |
|
|
|
|
MongodStarter mongodStarter = MongodStarter.getInstance(runtimeConfig); |
|
|
|
|
return mongodStarter.prepare(mongodConfig); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|