use of com.mongodb.MongoClientSettings in project spring-data-mongodb by spring-projects.
the class MongoClientNamespaceTests method clientWithUUidSettings.
// DATAMONGO-2427
@Test
public void clientWithUUidSettings() {
assertThat(ctx.containsBean("client-with-uuid-settings")).isTrue();
MongoClientFactoryBean factoryBean = ctx.getBean("&client-with-uuid-settings", MongoClientFactoryBean.class);
MongoClientSettings settings = (MongoClientSettings) getField(factoryBean, "mongoClientSettings");
assertThat(settings.getUuidRepresentation()).isEqualTo(UuidRepresentation.STANDARD);
}
use of com.mongodb.MongoClientSettings in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testMongoSingletonWithAttributes.
@Test
public void testMongoSingletonWithAttributes() throws Exception {
assertThat(ctx.containsBean("defaultMongo")).isTrue();
MongoClientFactoryBean mfb = (MongoClientFactoryBean) ctx.getBean("&defaultMongo");
String host = (String) getField(mfb, "host");
Integer port = (Integer) getField(mfb, "port");
assertThat(host).isEqualTo("localhost");
assertThat(port).isEqualTo(new Integer(27017));
MongoClientSettings options = (MongoClientSettings) getField(mfb, "mongoClientSettings");
assertThat(options).isNull();
}
use of com.mongodb.MongoClientSettings in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testMongoSingletonWithSslEnabled.
// DATAMONGO-764
@Test
public void testMongoSingletonWithSslEnabled() throws Exception {
assertThat(ctx.containsBean("mongoSsl")).isTrue();
MongoClientFactoryBean mfb = (MongoClientFactoryBean) ctx.getBean("&mongoSsl");
MongoClientSettings options = (MongoClientSettings) getField(mfb, "mongoClientSettings");
assertThat(options.getSslSettings().getContext().getSocketFactory() instanceof SSLSocketFactory).as("socketFactory should be a SSLSocketFactory").isTrue();
}
use of com.mongodb.MongoClientSettings in project rocketmq-externals by apache.
the class MongoFactoryTest method getSettings.
private MongoClientSettings getSettings() {
try {
client = (MongoClientImpl) mongoClientFactory.createMongoClient(replicaSetConfig);
Field field = MongoClientImpl.class.getDeclaredField("settings");
field.setAccessible(true);
return (MongoClientSettings) field.get(client);
} catch (Exception e) {
}
return null;
}
use of com.mongodb.MongoClientSettings in project pinpoint by naver.
the class MongoDriverConnectInterceptor3_7 method getHostList.
private List<String> getHostList(Object arg) {
if (!(arg instanceof MongoClientSettings)) {
return Collections.emptyList();
}
final MongoClientSettings mongoClientSettings = (MongoClientSettings) arg;
List<ServerAddress> lists = mongoClientSettings.getClusterSettings().getHosts();
final List<String> hostList = new ArrayList<>();
for (ServerAddress sa : lists) {
final String hostAddress = HostAndPort.toHostAndPortString(sa.getHost(), sa.getPort());
hostList.add(hostAddress);
}
return hostList;
}
Aggregations