|
|
|
@ -19,11 +19,11 @@ package org.springframework.boot.autoconfigure.mongo.embedded;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
|
|
|
|
|
|
import com.mongodb.CommandResult;
|
|
|
|
|
import com.mongodb.MongoClient;
|
|
|
|
|
import de.flapdoodle.embed.mongo.config.IMongodConfig;
|
|
|
|
|
import de.flapdoodle.embed.mongo.config.Storage;
|
|
|
|
|
import de.flapdoodle.embed.mongo.distribution.Feature;
|
|
|
|
|
import org.bson.Document;
|
|
|
|
|
import org.junit.After;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
@ -82,8 +82,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
|
load();
|
|
|
|
|
assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1);
|
|
|
|
|
MongoClient client = this.context.getBean(MongoClient.class);
|
|
|
|
|
Integer mongoPort = Integer.valueOf(
|
|
|
|
|
this.context.getEnvironment().getProperty("local.mongo.port"));
|
|
|
|
|
Integer mongoPort = Integer
|
|
|
|
|
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
|
|
|
|
|
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -92,8 +92,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
|
load("spring.data.mongodb.port=0");
|
|
|
|
|
assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1);
|
|
|
|
|
MongoClient client = this.context.getBean(MongoClient.class);
|
|
|
|
|
Integer mongoPort = Integer.valueOf(
|
|
|
|
|
this.context.getEnvironment().getProperty("local.mongo.port"));
|
|
|
|
|
Integer mongoPort = Integer
|
|
|
|
|
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
|
|
|
|
|
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -101,8 +101,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
|
public void randomlyAllocatedPortIsAvailableWhenCreatingMongoClient() {
|
|
|
|
|
load(MongoClientConfiguration.class);
|
|
|
|
|
MongoClient client = this.context.getBean(MongoClient.class);
|
|
|
|
|
Integer mongoPort = Integer.valueOf(
|
|
|
|
|
this.context.getEnvironment().getProperty("local.mongo.port"));
|
|
|
|
|
Integer mongoPort = Integer
|
|
|
|
|
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
|
|
|
|
|
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -172,7 +172,7 @@ public class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
|
MongoDataAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class);
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
MongoTemplate mongo = this.context.getBean(MongoTemplate.class);
|
|
|
|
|
CommandResult buildInfo = mongo.executeCommand("{ buildInfo: 1 }");
|
|
|
|
|
Document buildInfo = mongo.executeCommand("{ buildInfo: 1 }");
|
|
|
|
|
|
|
|
|
|
assertThat(buildInfo.getString("version")).isEqualTo(expectedVersion);
|
|
|
|
|
}
|
|
|
|
@ -187,8 +187,7 @@ public class EmbeddedMongoAutoConfigurationTests {
|
|
|
|
|
ctx.register(config);
|
|
|
|
|
}
|
|
|
|
|
EnvironmentTestUtils.addEnvironment(ctx, environment);
|
|
|
|
|
ctx.register(EmbeddedMongoAutoConfiguration.class,
|
|
|
|
|
MongoAutoConfiguration.class,
|
|
|
|
|
ctx.register(EmbeddedMongoAutoConfiguration.class, MongoAutoConfiguration.class,
|
|
|
|
|
PropertyPlaceholderAutoConfiguration.class);
|
|
|
|
|
ctx.refresh();
|
|
|
|
|
this.context = ctx;
|
|
|
|
|