use of org.springframework.data.mongodb.MongoDatabaseFactory in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testMongoTemplateFactory.
// DATAMONGO-140
@Test
public void testMongoTemplateFactory() {
assertThat(ctx.containsBean("mongoTemplate")).isTrue();
MongoOperations operations = (MongoOperations) ctx.getBean("mongoTemplate");
MongoDatabaseFactory dbf = (MongoDatabaseFactory) getField(operations, "mongoDbFactory");
assertThat(getField(dbf, "databaseName")).isEqualTo("database");
MongoConverter converter = (MongoConverter) getField(operations, "mongoConverter");
assertThat(converter).isNotNull();
}
use of org.springframework.data.mongodb.MongoDatabaseFactory in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testSecondMongoTemplateFactory.
// DATAMONGO-140
@Test
public void testSecondMongoTemplateFactory() {
assertThat(ctx.containsBean("anotherMongoTemplate")).isTrue();
MongoOperations operations = (MongoOperations) ctx.getBean("anotherMongoTemplate");
MongoDatabaseFactory dbf = (MongoDatabaseFactory) getField(operations, "mongoDbFactory");
assertThat(getField(dbf, "databaseName")).isEqualTo("database");
WriteConcern writeConcern = (WriteConcern) getField(operations, "writeConcern");
assertThat(writeConcern).isEqualTo(WriteConcern.ACKNOWLEDGED);
}
use of org.springframework.data.mongodb.MongoDatabaseFactory in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testSecondGridFsTemplateFactory.
// DATAMONGO-628
@Test
public void testSecondGridFsTemplateFactory() {
assertThat(ctx.containsBean("secondGridFsTemplate")).isTrue();
GridFsOperations operations = (GridFsOperations) ctx.getBean("secondGridFsTemplate");
MongoDatabaseFactory dbf = (MongoDatabaseFactory) getField(operations, "dbFactory");
assertThat(getField(dbf, "databaseName")).isEqualTo("database");
assertThat(getField(operations, "bucket")).isEqualTo(null);
MongoConverter converter = (MongoConverter) getField(operations, "converter");
assertThat(converter).isNotNull();
}
use of org.springframework.data.mongodb.MongoDatabaseFactory in project spring-data-mongodb by spring-projects.
the class MongoNamespaceTests method testSecondMongoDbFactory.
@Test
public void testSecondMongoDbFactory() {
assertThat(ctx.containsBean("secondMongoDbFactory")).isTrue();
MongoDatabaseFactory dbf = (MongoDatabaseFactory) ctx.getBean("secondMongoDbFactory");
MongoClient mongo = (MongoClient) getField(dbf, "mongoClient");
assertThat(mongo.getClusterDescription().getClusterSettings().getHosts()).containsExactly(new ServerAddress());
assertThat(getField(dbf, "databaseName")).isEqualTo("database");
}
use of org.springframework.data.mongodb.MongoDatabaseFactory in project spring-data-mongodb by spring-projects.
the class MongoDbFactoryParserIntegrationTests method usesConnectionStringToCreateClientClient.
// DATAMONGO-2384
@Test
public void usesConnectionStringToCreateClientClient() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("namespace/db-factory-bean.xml");
MongoDatabaseFactory dbFactory = ctx.getBean("with-connection-string", MongoDatabaseFactory.class);
assertThat(dbFactory).isInstanceOf(SimpleMongoClientDatabaseFactory.class);
assertThat(ReflectionTestUtils.getField(dbFactory, "mongoClient")).isInstanceOf(com.mongodb.client.MongoClient.class);
}
Aggregations