Commit bce6bd65 authored by Stephane Nicoll's avatar Stephane Nicoll

Polish

parent 7b5df365
......@@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.mongo;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.mongodb.MongoClient;
......@@ -209,7 +209,7 @@ public class MongoProperties {
}
String host = this.host == null ? "localhost" : this.host;
int port = determinePort(environment);
return new MongoClient(Arrays.asList(new ServerAddress(host, port)),
return new MongoClient(Collections.singletonList(new ServerAddress(host, port)),
credentials, options);
}
// The options and credentials are in the URI
......
......@@ -57,7 +57,6 @@ public class MongoAutoConfigurationTests {
assertThat(this.context.getBeanNamesForType(Mongo.class).length).isEqualTo(1);
}
@SuppressWarnings("deprecation")
@Test
public void optionsAdded() {
this.context = new AnnotationConfigApplicationContext();
......@@ -66,11 +65,10 @@ public class MongoAutoConfigurationTests {
this.context.register(OptionsConfig.class,
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(Mongo.class).getMongoOptions().getSocketTimeout())
.isEqualTo(300);
assertThat(this.context.getBean(MongoClient.class).getMongoClientOptions()
.getSocketTimeout()).isEqualTo(300);
}
@SuppressWarnings("deprecation")
@Test
public void optionsAddedButNoHost() {
this.context = new AnnotationConfigApplicationContext();
......@@ -79,8 +77,8 @@ public class MongoAutoConfigurationTests {
this.context.register(OptionsConfig.class,
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(Mongo.class).getMongoOptions().getSocketTimeout())
.isEqualTo(300);
assertThat(this.context.getBean(MongoClient.class).getMongoClientOptions()
.getSocketTimeout()).isEqualTo(300);
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment