pull/6154/merge
Stephane Nicoll 9 years ago
parent 7b5df365d8
commit bce6bd6594

@ -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

Loading…
Cancel
Save