|
|
@ -22,10 +22,12 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import com.mongodb.MongoClient;
|
|
|
|
import com.mongodb.MongoClient;
|
|
|
|
import de.flapdoodle.embed.mongo.MongodExecutable;
|
|
|
|
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.IMongodConfig;
|
|
|
|
import de.flapdoodle.embed.mongo.config.Storage;
|
|
|
|
import de.flapdoodle.embed.mongo.config.Storage;
|
|
|
|
import de.flapdoodle.embed.mongo.distribution.Feature;
|
|
|
|
import de.flapdoodle.embed.mongo.distribution.Feature;
|
|
|
|
import de.flapdoodle.embed.mongo.distribution.Version;
|
|
|
|
import de.flapdoodle.embed.mongo.distribution.Version;
|
|
|
|
|
|
|
|
import de.flapdoodle.embed.process.config.IRuntimeConfig;
|
|
|
|
import org.bson.Document;
|
|
|
|
import org.bson.Document;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
@ -43,6 +45,7 @@ import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
import org.springframework.util.FileSystemUtils;
|
|
|
|
import org.springframework.util.FileSystemUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatCode;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tests for {@link EmbeddedMongoAutoConfiguration}.
|
|
|
|
* Tests for {@link EmbeddedMongoAutoConfiguration}.
|
|
|
@ -50,6 +53,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
* @author Henryk Konsek
|
|
|
|
* @author Henryk Konsek
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
|
|
|
|
* @author Issam El-atif
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
public class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
@ -171,6 +175,11 @@ public class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
assertThat(this.context.getBean(MongodExecutable.class).isRegisteredJobKiller()).isFalse();
|
|
|
|
assertThat(this.context.getBean(MongodExecutable.class).isRegisteredJobKiller()).isFalse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void customMongoServerConfiguration() {
|
|
|
|
|
|
|
|
assertThatCode(() -> load(CustomMongoConfiguration.class)).doesNotThrowAnyException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void assertVersionConfiguration(String configuredVersion, String expectedVersion) {
|
|
|
|
private void assertVersionConfiguration(String configuredVersion, String expectedVersion) {
|
|
|
|
this.context = new AnnotationConfigApplicationContext();
|
|
|
|
this.context = new AnnotationConfigApplicationContext();
|
|
|
|
TestPropertyValues.of("spring.data.mongodb.port=0").applyTo(this.context);
|
|
|
|
TestPropertyValues.of("spring.data.mongodb.port=0").applyTo(this.context);
|
|
|
@ -216,4 +225,15 @@ public class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
|
|
|
static class CustomMongoConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean(initMethod = "start", destroyMethod = "stop")
|
|
|
|
|
|
|
|
public MongodExecutable customMongoServer(IRuntimeConfig runtimeConfig, IMongodConfig mongodConfig) {
|
|
|
|
|
|
|
|
MongodStarter mongodStarter = MongodStarter.getInstance(runtimeConfig);
|
|
|
|
|
|
|
|
return mongodStarter.prepare(mongodConfig);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|