Search in sources :

Example 1 with MongoOperations

use of org.springframework.data.mongodb.core.MongoOperations in project spring-data-mongodb by spring-projects.

the class MongoNamespaceTests method testSecondMongoTemplateFactory.

// DATAMONGO-140
@Test
public void testSecondMongoTemplateFactory() {
    assertTrue(ctx.containsBean("anotherMongoTemplate"));
    MongoOperations operations = (MongoOperations) ctx.getBean("anotherMongoTemplate");
    MongoDbFactory dbf = (MongoDbFactory) getField(operations, "mongoDbFactory");
    assertEquals("database", getField(dbf, "databaseName"));
    WriteConcern writeConcern = (WriteConcern) getField(operations, "writeConcern");
    assertEquals(WriteConcern.SAFE, writeConcern);
}
Also used : MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) WriteConcern(com.mongodb.WriteConcern) MongoOperations(org.springframework.data.mongodb.core.MongoOperations) Test(org.junit.Test)

Example 2 with MongoOperations

use of org.springframework.data.mongodb.core.MongoOperations in project spring-data-mongodb by spring-projects.

the class MongoNamespaceTests method testMongoTemplateFactory.

// DATAMONGO-140
@Test
public void testMongoTemplateFactory() {
    assertTrue(ctx.containsBean("mongoTemplate"));
    MongoOperations operations = (MongoOperations) ctx.getBean("mongoTemplate");
    MongoDbFactory dbf = (MongoDbFactory) getField(operations, "mongoDbFactory");
    assertEquals("database", getField(dbf, "databaseName"));
    MongoConverter converter = (MongoConverter) getField(operations, "mongoConverter");
    assertNotNull(converter);
}
Also used : MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) MongoOperations(org.springframework.data.mongodb.core.MongoOperations) MongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 MongoDbFactory (org.springframework.data.mongodb.MongoDbFactory)2 MongoOperations (org.springframework.data.mongodb.core.MongoOperations)2 WriteConcern (com.mongodb.WriteConcern)1 MongoConverter (org.springframework.data.mongodb.core.convert.MongoConverter)1